Current section

Files

Jump to
cleam src cleam.erl
Raw

src/cleam.erl

-module(cleam).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([main/0]).
-spec main() -> nil.
main() ->
Ast_info = internal@ast:files_paths_with_ast(
{files_dir, <<"src"/utf8>>},
{some, {files_dir, <<"test"/utf8>>}}
),
Not_used_fun = internal@checker:not_used_functions(
{files_dir, <<"src"/utf8>>},
Ast_info
),
gleam@list:each(
Not_used_fun,
fun(Not_used_fun@1) ->
{{public_fun, Public_fun}, {file_path, File_path}} = case Not_used_fun@1 of
{{public_fun, _}, {file_path, _}} -> Not_used_fun@1;
_assert_fail ->
erlang:error(#{gleam_error => let_assert,
message => <<"Assertion pattern match failed"/utf8>>,
value => _assert_fail,
module => <<"cleam"/utf8>>,
function => <<"main"/utf8>>,
line => 13})
end,
gleam@io:println_error(
<<<<<<"Function not used: "/utf8, Public_fun/binary>>/binary,
"; File path: "/utf8>>/binary,
File_path/binary>>
)
end
),
Not_used_const = internal@checker:not_used_const(
{files_dir, <<"src"/utf8>>},
Ast_info
),
gleam@list:each(
Not_used_const,
fun(Not_used_const@1) ->
{{public_const, Pub_const}, {file_path, File_path@1}} = case Not_used_const@1 of
{{public_const, _}, {file_path, _}} -> Not_used_const@1;
_assert_fail@1 ->
erlang:error(#{gleam_error => let_assert,
message => <<"Assertion pattern match failed"/utf8>>,
value => _assert_fail@1,
module => <<"cleam"/utf8>>,
function => <<"main"/utf8>>,
line => 20})
end,
gleam@io:println_error(
<<<<<<"Const not used: "/utf8, Pub_const/binary>>/binary,
"; File path: "/utf8>>/binary,
File_path@1/binary>>
)
end
),
Not_used_types = internal@checker:not_used_types(
{files_dir, <<"src"/utf8>>},
Ast_info
),
gleam@list:each(
Not_used_types,
fun(Not_used_type) ->
{{public_type, Pub_type}, {file_path, File_path@2}} = case Not_used_type of
{{public_type, _}, {file_path, _}} -> Not_used_type;
_assert_fail@2 ->
erlang:error(#{gleam_error => let_assert,
message => <<"Assertion pattern match failed"/utf8>>,
value => _assert_fail@2,
module => <<"cleam"/utf8>>,
function => <<"main"/utf8>>,
line => 27})
end,
gleam@io:println_error(
<<<<<<"Type not used: "/utf8, Pub_type/binary>>/binary,
"; File path: "/utf8>>/binary,
File_path@2/binary>>
)
end
),
case ((gleam@list:length(Not_used_fun) > 0) orelse (gleam@list:length(
Not_used_const
)
> 0))
orelse (gleam@list:length(Not_used_types) > 0) of
true ->
erlang:halt(1);
false ->
erlang:halt(0)
end.