mirror of
https://github.com/correl/rebar.git
synced 2024-12-18 03:00:17 +00:00
Dialyzer related cleanups
This commit is contained in:
parent
93f77b50fc
commit
e024778599
12 changed files with 65 additions and 57 deletions
|
@ -285,7 +285,7 @@ arg_spec_type(Type) when is_atom(Type) ->
|
||||||
|
|
||||||
|
|
||||||
%% @doc Convert an argument string to its corresponding data type.
|
%% @doc Convert an argument string to its corresponding data type.
|
||||||
-spec to_type(atom(), string()) -> arg_value().
|
-spec to_type(arg_type(), string()) -> arg_value().
|
||||||
to_type(binary, Arg) ->
|
to_type(binary, Arg) ->
|
||||||
list_to_binary(Arg);
|
list_to_binary(Arg);
|
||||||
to_type(atom, Arg) ->
|
to_type(atom, Arg) ->
|
||||||
|
@ -327,7 +327,7 @@ is_arg_false(Arg) ->
|
||||||
(Arg =:= "0").
|
(Arg =:= "0").
|
||||||
|
|
||||||
|
|
||||||
-spec is_valid_arg(arg_spec() | arg_type(), string()) -> boolean().
|
-spec is_valid_arg(arg_spec(), nonempty_string()) -> boolean().
|
||||||
is_valid_arg({Type, _DefaultArg}, Arg) ->
|
is_valid_arg({Type, _DefaultArg}, Arg) ->
|
||||||
is_valid_arg(Type, Arg);
|
is_valid_arg(Type, Arg);
|
||||||
is_valid_arg(boolean, Arg) ->
|
is_valid_arg(boolean, Arg) ->
|
||||||
|
|
|
@ -47,7 +47,7 @@ compile(Mod) ->
|
||||||
|
|
||||||
compile(Mod, File) ->
|
compile(Mod, File) ->
|
||||||
code:purge(Mod),
|
code:purge(Mod),
|
||||||
code:load_file(Mod),
|
{module, _} = code:load_file(Mod),
|
||||||
{ok, TemplateBin} = file:read_file(File),
|
{ok, TemplateBin} = file:read_file(File),
|
||||||
Template = re:replace(TemplateBin, "\"", "\\\\\"", [global, {return,list}]),
|
Template = re:replace(TemplateBin, "\"", "\\\\\"", [global, {return,list}]),
|
||||||
State = #mstate{mod = Mod},
|
State = #mstate{mod = Mod},
|
||||||
|
|
|
@ -36,5 +36,4 @@
|
||||||
clean(Config, _AppFile) ->
|
clean(Config, _AppFile) ->
|
||||||
%% Get a list of files to delete from config and remove them
|
%% Get a list of files to delete from config and remove them
|
||||||
FilesToClean = rebar_config:get(Config, clean_files, []),
|
FilesToClean = rebar_config:get(Config, clean_files, []),
|
||||||
[rebar_file_utils:rm_rf(F) || F <- FilesToClean],
|
lists:foreach(fun (F) -> rebar_file_utils:rm_rf(F) end, FilesToClean).
|
||||||
ok.
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ run(RawArgs) ->
|
||||||
Commands = parse_args(RawArgs),
|
Commands = parse_args(RawArgs),
|
||||||
|
|
||||||
%% Make sure crypto is running
|
%% Make sure crypto is running
|
||||||
crypto:start(),
|
ok = crypto:start(),
|
||||||
|
|
||||||
%% Initialize logging system
|
%% Initialize logging system
|
||||||
rebar_log:init(),
|
rebar_log:init(),
|
||||||
|
@ -286,10 +286,10 @@ process_commands([]) ->
|
||||||
end;
|
end;
|
||||||
process_commands([Command | Rest]) ->
|
process_commands([Command | Rest]) ->
|
||||||
%% Reset skip dirs
|
%% Reset skip dirs
|
||||||
[erlang:erase({skip_dir, D}) || D <- skip_dirs()],
|
lists:foreach(fun (D) -> erlang:erase({skip_dir, D}) end, skip_dirs()),
|
||||||
Operations = erlang:get(operations),
|
Operations = erlang:get(operations),
|
||||||
|
|
||||||
process_dir(rebar_utils:get_cwd(), rebar_config:new(), Command, sets:new()),
|
_ = process_dir(rebar_utils:get_cwd(), rebar_config:new(), Command, sets:new()),
|
||||||
case erlang:get(operations) of
|
case erlang:get(operations) of
|
||||||
Operations ->
|
Operations ->
|
||||||
%% This command didn't do anything
|
%% This command didn't do anything
|
||||||
|
|
|
@ -68,7 +68,9 @@ preprocess(Config, _) ->
|
||||||
%% WILL run (and we want it to) for transitivity purposes.
|
%% WILL run (and we want it to) for transitivity purposes.
|
||||||
case rebar_config:get_global(skip_deps, false) of
|
case rebar_config:get_global(skip_deps, false) of
|
||||||
"true" ->
|
"true" ->
|
||||||
[rebar_core:skip_dir(D#dep.dir) || D <- AvailableDeps];
|
lists:foreach(fun (#dep{dir = Dir}) ->
|
||||||
|
rebar_core:skip_dir(Dir)
|
||||||
|
end, AvailableDeps);
|
||||||
_ ->
|
_ ->
|
||||||
ok
|
ok
|
||||||
end,
|
end,
|
||||||
|
@ -97,9 +99,10 @@ compile(Config, AppFile) ->
|
||||||
%% No missing deps
|
%% No missing deps
|
||||||
ok;
|
ok;
|
||||||
{_, MissingDeps} ->
|
{_, MissingDeps} ->
|
||||||
[?CONSOLE("Dependency not available: ~p-~s (~p)\n",
|
lists:foreach(fun (#dep{app=App, vsn_regex=Vsn, source=Src}) ->
|
||||||
[D#dep.app, D#dep.vsn_regex, D#dep.source]) ||
|
?CONSOLE("Dependency not available: ~p-~s (~p)\n",
|
||||||
D <- MissingDeps],
|
[App, Vsn, Src])
|
||||||
|
end, MissingDeps),
|
||||||
?FAIL
|
?FAIL
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -121,8 +124,8 @@ compile(Config, AppFile) ->
|
||||||
DepsDir = get_deps_dir(),
|
DepsDir = get_deps_dir(),
|
||||||
Deps = rebar_config:get_local(Config, deps, []),
|
Deps = rebar_config:get_local(Config, deps, []),
|
||||||
{AvailableDeps, _} = find_deps(Deps),
|
{AvailableDeps, _} = find_deps(Deps),
|
||||||
[delete_dep(D) || D <- AvailableDeps,
|
_ = [delete_dep(D) || D <- AvailableDeps,
|
||||||
lists:prefix(DepsDir, D#dep.dir) == true],
|
lists:prefix(DepsDir, D#dep.dir) == true],
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
|
|
||||||
|
@ -149,9 +152,9 @@ update_deps_code_path([]) ->
|
||||||
update_deps_code_path([Dep | Rest]) ->
|
update_deps_code_path([Dep | Rest]) ->
|
||||||
case is_app_available(Dep#dep.app, Dep#dep.vsn_regex, Dep#dep.dir) of
|
case is_app_available(Dep#dep.app, Dep#dep.vsn_regex, Dep#dep.dir) of
|
||||||
{true, _} ->
|
{true, _} ->
|
||||||
code:add_patha(filename:join(Dep#dep.dir, "ebin"));
|
true = code:add_patha(filename:join(Dep#dep.dir, "ebin"));
|
||||||
false ->
|
false ->
|
||||||
ok
|
true
|
||||||
end,
|
end,
|
||||||
update_deps_code_path(Rest).
|
update_deps_code_path(Rest).
|
||||||
|
|
||||||
|
@ -246,9 +249,9 @@ use_source(Dep, Count) ->
|
||||||
%% Already downloaded -- verify the versioning matches up with our regex
|
%% Already downloaded -- verify the versioning matches up with our regex
|
||||||
case is_app_available(Dep#dep.app, Dep#dep.vsn_regex, Dep#dep.dir) of
|
case is_app_available(Dep#dep.app, Dep#dep.vsn_regex, Dep#dep.dir) of
|
||||||
{true, _} ->
|
{true, _} ->
|
||||||
%% Available version matches up -- we're good to go; add the
|
%% Available version matches up -- we're good to go;
|
||||||
%% app dir to our code path
|
%% add the app dir to our code path
|
||||||
code:add_patha(filename:join(Dep#dep.dir, "ebin")),
|
true = code:add_patha(filename:join(Dep#dep.dir, "ebin")),
|
||||||
Dep;
|
Dep;
|
||||||
false ->
|
false ->
|
||||||
%% The app that was downloaded doesn't match up (or had
|
%% The app that was downloaded doesn't match up (or had
|
||||||
|
|
|
@ -147,7 +147,7 @@ include_path(Source, Config) ->
|
||||||
ErlOpts = rebar_config:get(Config, erl_opts, []),
|
ErlOpts = rebar_config:get(Config, erl_opts, []),
|
||||||
["include", filename:dirname(Source)] ++ proplists:get_all_values(i, ErlOpts).
|
["include", filename:dirname(Source)] ++ proplists:get_all_values(i, ErlOpts).
|
||||||
|
|
||||||
-spec inspect(Source::string(), IncludePath::[string()]) -> {string(), [string()]}.
|
-spec inspect(Source::string(), IncludePath::[string(),...]) -> {string(), [string()]}.
|
||||||
inspect(Source, IncludePath) ->
|
inspect(Source, IncludePath) ->
|
||||||
ModuleDefault = filename:basename(Source, ".erl"),
|
ModuleDefault = filename:basename(Source, ".erl"),
|
||||||
case epp:open(Source, IncludePath) of
|
case epp:open(Source, IncludePath) of
|
||||||
|
@ -281,7 +281,7 @@ gather_src([], Srcs) ->
|
||||||
gather_src([Dir|Rest], Srcs) ->
|
gather_src([Dir|Rest], Srcs) ->
|
||||||
gather_src(Rest, Srcs ++ rebar_utils:find_files(Dir, ".*\\.erl\$")).
|
gather_src(Rest, Srcs ++ rebar_utils:find_files(Dir, ".*\\.erl\$")).
|
||||||
|
|
||||||
-spec src_dirs(SrcDirs::[string()]) -> [string()].
|
-spec src_dirs(SrcDirs::[string()]) -> [string(),...].
|
||||||
src_dirs([]) ->
|
src_dirs([]) ->
|
||||||
["src"];
|
["src"];
|
||||||
src_dirs(SrcDirs) ->
|
src_dirs(SrcDirs) ->
|
||||||
|
|
|
@ -123,7 +123,7 @@ eunit(Config, AppFile) ->
|
||||||
end,
|
end,
|
||||||
|
|
||||||
%% Restore code path
|
%% Restore code path
|
||||||
code:set_path(CodePath),
|
true = code:set_path(CodePath),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
clean(_Config, _File) ->
|
clean(_Config, _File) ->
|
||||||
|
@ -148,12 +148,12 @@ perform_eunit(Config, Modules) ->
|
||||||
%% Move down into ?EUNIT_DIR while we run tests so any generated files
|
%% Move down into ?EUNIT_DIR while we run tests so any generated files
|
||||||
%% are created there (versus in the source dir)
|
%% are created there (versus in the source dir)
|
||||||
Cwd = rebar_utils:get_cwd(),
|
Cwd = rebar_utils:get_cwd(),
|
||||||
file:set_cwd(?EUNIT_DIR),
|
ok = file:set_cwd(?EUNIT_DIR),
|
||||||
|
|
||||||
EunitResult = perform_eunit(EunitOpts, Modules, Suite),
|
EunitResult = perform_eunit(EunitOpts, Modules, Suite),
|
||||||
|
|
||||||
%% Return to original working dir
|
%% Return to original working dir
|
||||||
file:set_cwd(Cwd),
|
ok = file:set_cwd(Cwd),
|
||||||
|
|
||||||
EunitResult.
|
EunitResult.
|
||||||
|
|
||||||
|
@ -225,7 +225,9 @@ cover_analyze(Config, Modules, SrcModules) ->
|
||||||
cover_write_index(lists:sort(Coverage), SrcModules),
|
cover_write_index(lists:sort(Coverage), SrcModules),
|
||||||
|
|
||||||
%% Write coverage details for each file
|
%% Write coverage details for each file
|
||||||
[{ok, _} = cover:analyze_to_file(M, cover_file(M), [html]) || {M, _, _} <- Coverage],
|
lists:foreach(fun({M, _, _}) ->
|
||||||
|
{ok, _} = cover:analyze_to_file(M, cover_file(M), [html])
|
||||||
|
end, Coverage),
|
||||||
|
|
||||||
Index = filename:join([rebar_utils:get_cwd(), ?EUNIT_DIR, "index.html"]),
|
Index = filename:join([rebar_utils:get_cwd(), ?EUNIT_DIR, "index.html"]),
|
||||||
?CONSOLE("Cover analysis: ~s\n", [Index]),
|
?CONSOLE("Cover analysis: ~s\n", [Index]),
|
||||||
|
@ -255,11 +257,11 @@ cover_init(true, BeamFiles) ->
|
||||||
_ ->
|
_ ->
|
||||||
%% At least one module compiled successfully
|
%% At least one module compiled successfully
|
||||||
|
|
||||||
%% It's not an error for cover compilation to fail partially, but we do want
|
%% It's not an error for cover compilation to fail partially,
|
||||||
%% to warn about them
|
%% but we do want to warn about them
|
||||||
[?CONSOLE("Cover compilation warning for ~p: ~p", [Beam, Desc]) || {Beam, {error, Desc}} <- Compiled]
|
_ = [?CONSOLE("Cover compilation warning for ~p: ~p", [Beam, Desc]) || {Beam, {error, Desc}} <- Compiled],
|
||||||
end,
|
ok
|
||||||
ok;
|
end;
|
||||||
cover_init(Config, BeamFiles) ->
|
cover_init(Config, BeamFiles) ->
|
||||||
cover_init(rebar_config:get(Config, cover_enabled, false), BeamFiles).
|
cover_init(rebar_config:get(Config, cover_enabled, false), BeamFiles).
|
||||||
|
|
||||||
|
@ -313,7 +315,7 @@ cover_write_index(Coverage, SrcModules) ->
|
||||||
cover_write_index_section(F, "Source", SrcCoverage),
|
cover_write_index_section(F, "Source", SrcCoverage),
|
||||||
cover_write_index_section(F, "Test", TestCoverage),
|
cover_write_index_section(F, "Test", TestCoverage),
|
||||||
ok = file:write(F, "</body></html>"),
|
ok = file:write(F, "</body></html>"),
|
||||||
file:close(F).
|
ok = file:close(F).
|
||||||
|
|
||||||
cover_write_index_section(_F, _SectionName, []) ->
|
cover_write_index_section(_F, _SectionName, []) ->
|
||||||
ok;
|
ok;
|
||||||
|
@ -329,9 +331,10 @@ cover_write_index_section(F, SectionName, Coverage) ->
|
||||||
ok = file:write(F, ?FMT("<h3>Total: ~s</h3>\n", [TotalCoverage])),
|
ok = file:write(F, ?FMT("<h3>Total: ~s</h3>\n", [TotalCoverage])),
|
||||||
ok = file:write(F, "<table><tr><th>Module</th><th>Coverage %</th></tr>\n"),
|
ok = file:write(F, "<table><tr><th>Module</th><th>Coverage %</th></tr>\n"),
|
||||||
|
|
||||||
[ok = file:write(F, ?FMT("<tr><td><a href='~s.COVER.html'>~s</a></td><td>~s</td>\n",
|
lists:foreach(fun({Module, Cov, NotCov}) ->
|
||||||
[Module, Module, percentage(Cov, NotCov)])) ||
|
ok = file:write(F, ?FMT("<tr><td><a href='~s.COVER.html'>~s</a></td><td>~s</td>\n",
|
||||||
{Module, Cov, NotCov} <- Coverage],
|
[Module, Module, percentage(Cov, NotCov)]))
|
||||||
|
end, Coverage),
|
||||||
ok = file:write(F, "</table>\n").
|
ok = file:write(F, "</table>\n").
|
||||||
|
|
||||||
cover_print_coverage(Coverage) ->
|
cover_print_coverage(Coverage) ->
|
||||||
|
@ -352,8 +355,10 @@ cover_print_coverage(Coverage) ->
|
||||||
|
|
||||||
%% Print the output the console
|
%% Print the output the console
|
||||||
?CONSOLE("~nCode Coverage:~n", []),
|
?CONSOLE("~nCode Coverage:~n", []),
|
||||||
[?CONSOLE("~*s : ~3s~n",
|
lists:foreach(fun({Mod, C, N}) ->
|
||||||
[Width, Mod, percentage(C, N)]) || {Mod, C, N} <- Coverage],
|
?CONSOLE("~*s : ~3s~n",
|
||||||
|
[Width, Mod, percentage(C, N)])
|
||||||
|
end, Coverage),
|
||||||
?CONSOLE("~n~*s : ~s~n", [Width, "Total", TotalCoverage]).
|
?CONSOLE("~n~*s : ~s~n", [Width, "Total", TotalCoverage]).
|
||||||
|
|
||||||
cover_file(Module) ->
|
cover_file(Module) ->
|
||||||
|
|
|
@ -68,8 +68,7 @@ clean(_Config, File) ->
|
||||||
%% If the app file is a .app.src, delete the generated .app file
|
%% If the app file is a .app.src, delete the generated .app file
|
||||||
case rebar_app_utils:is_app_src(File) of
|
case rebar_app_utils:is_app_src(File) of
|
||||||
true ->
|
true ->
|
||||||
file:delete(rebar_app_utils:app_src_to_app(File)),
|
file:delete(rebar_app_utils:app_src_to_app(File));
|
||||||
ok;
|
|
||||||
false ->
|
false ->
|
||||||
ok
|
ok
|
||||||
end.
|
end.
|
||||||
|
@ -94,7 +93,7 @@ preprocess(AppSrcFile) ->
|
||||||
ok = file:write_file(AppFile, Spec),
|
ok = file:write_file(AppFile, Spec),
|
||||||
|
|
||||||
%% Make certain that the ebin/ directory is available on the code path
|
%% Make certain that the ebin/ directory is available on the code path
|
||||||
code:add_path(filename:absname(filename:dirname(AppFile))),
|
true = code:add_path(filename:absname(filename:dirname(AppFile))),
|
||||||
|
|
||||||
AppFile;
|
AppFile;
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,7 @@ compile_each([{Proto, Beam, Hrl} | Rest]) ->
|
||||||
%% into the ebin/ and include/ directories respectively
|
%% into the ebin/ and include/ directories respectively
|
||||||
%% TODO: Protobuffs really needs to be better about this...sigh.
|
%% TODO: Protobuffs really needs to be better about this...sigh.
|
||||||
[] = os:cmd(?FMT("mv ~s ebin", [Beam])),
|
[] = os:cmd(?FMT("mv ~s ebin", [Beam])),
|
||||||
filelib:ensure_dir(filename:join("include", Hrl)),
|
ok = filelib:ensure_dir(filename:join("include", Hrl)),
|
||||||
[] = os:cmd(?FMT("mv ~s include", [Hrl])),
|
[] = os:cmd(?FMT("mv ~s include", [Hrl])),
|
||||||
ok;
|
ok;
|
||||||
Other ->
|
Other ->
|
||||||
|
|
|
@ -267,7 +267,7 @@ execute_overlay([], _Vars, _BaseDir, _TargetDir) ->
|
||||||
ok;
|
ok;
|
||||||
execute_overlay([{mkdir, Out} | Rest], Vars, BaseDir, TargetDir) ->
|
execute_overlay([{mkdir, Out} | Rest], Vars, BaseDir, TargetDir) ->
|
||||||
OutFile = render(filename:join([TargetDir, Out, "dummy"]), Vars),
|
OutFile = render(filename:join([TargetDir, Out, "dummy"]), Vars),
|
||||||
filelib:ensure_dir(OutFile),
|
ok = filelib:ensure_dir(OutFile),
|
||||||
?DEBUG("Created dir ~s\n", [filename:dirname(OutFile)]),
|
?DEBUG("Created dir ~s\n", [filename:dirname(OutFile)]),
|
||||||
execute_overlay(Rest, Vars, BaseDir, TargetDir);
|
execute_overlay(Rest, Vars, BaseDir, TargetDir);
|
||||||
execute_overlay([{copy, In} | Rest], _Vars, BaseDir, TargetDir) ->
|
execute_overlay([{copy, In} | Rest], _Vars, BaseDir, TargetDir) ->
|
||||||
|
|
|
@ -58,8 +58,10 @@
|
||||||
%% Build a list of available templates
|
%% Build a list of available templates
|
||||||
AvailTemplates = find_disk_templates() ++ find_escript_templates(),
|
AvailTemplates = find_disk_templates() ++ find_escript_templates(),
|
||||||
?CONSOLE("Available templates:\n", []),
|
?CONSOLE("Available templates:\n", []),
|
||||||
[?CONSOLE("\t* ~s: ~s (~p)\n", [filename:basename(F, ".template"), F, Type]) ||
|
_ = [begin
|
||||||
{Type, F} <- AvailTemplates],
|
BaseName = filename:basename(F, ".template"),
|
||||||
|
?CONSOLE("\t* ~s: ~s (~p)\n", [BaseName, F, Type])
|
||||||
|
end || {Type, F} <- AvailTemplates],
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
|
|
||||||
|
@ -244,7 +246,7 @@ write_file(Output, Data, Force) ->
|
||||||
%% otherwise just process the next template
|
%% otherwise just process the next template
|
||||||
if
|
if
|
||||||
Force =:= "1"; FileExists =:= false ->
|
Force =:= "1"; FileExists =:= false ->
|
||||||
filelib:ensure_dir(Output),
|
ok = filelib:ensure_dir(Output),
|
||||||
if
|
if
|
||||||
{Force, FileExists} =:= {"1", true} ->
|
{Force, FileExists} =:= {"1", true} ->
|
||||||
?CONSOLE("Writing ~s (forcibly overwriting)~n",
|
?CONSOLE("Writing ~s (forcibly overwriting)~n",
|
||||||
|
|
|
@ -50,7 +50,7 @@ xref(Config, _) ->
|
||||||
|
|
||||||
%% Save the code path prior to doing anything
|
%% Save the code path prior to doing anything
|
||||||
OrigPath = code:get_path(),
|
OrigPath = code:get_path(),
|
||||||
code:add_path(filename:join(rebar_utils:get_cwd(), "ebin")),
|
true = code:add_path(filename:join(rebar_utils:get_cwd(), "ebin")),
|
||||||
|
|
||||||
%% Get list of xref checks we want to run
|
%% Get list of xref checks we want to run
|
||||||
XrefChecks = rebar_config:get(Config, xref_checks, [exports_not_used,
|
XrefChecks = rebar_config:get(Config, xref_checks, [exports_not_used,
|
||||||
|
@ -73,7 +73,7 @@ xref(Config, _) ->
|
||||||
end,
|
end,
|
||||||
|
|
||||||
%% Restore the original code path
|
%% Restore the original code path
|
||||||
code:set_path(OrigPath),
|
true = code:set_path(OrigPath),
|
||||||
|
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
|
@ -93,9 +93,10 @@ check_undefined_function_calls(_Config) ->
|
||||||
{ok, UndefinedCalls0} = xref:analyze(xref, undefined_function_calls),
|
{ok, UndefinedCalls0} = xref:analyze(xref, undefined_function_calls),
|
||||||
UndefinedCalls = [{find_mfa_source(Caller), format_fa(Caller), format_mfa(Target)} ||
|
UndefinedCalls = [{find_mfa_source(Caller), format_fa(Caller), format_mfa(Target)} ||
|
||||||
{Caller, Target} <- UndefinedCalls0],
|
{Caller, Target} <- UndefinedCalls0],
|
||||||
[?CONSOLE("~s:~w: Warning ~s calls undefined function ~s\n",
|
lists:foreach(fun({{Source, Line}, FunStr, Target}) ->
|
||||||
[Source, Line, FunStr, Target]) ||
|
?CONSOLE("~s:~w: Warning ~s calls undefined function ~s\n",
|
||||||
{{Source, Line}, FunStr, Target} <- UndefinedCalls],
|
[Source, Line, FunStr, Target])
|
||||||
|
end, UndefinedCalls),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
|
|
||||||
|
@ -114,19 +115,18 @@ filter_away_ignored(UnusedExports) ->
|
||||||
%% any functions marked to ignore. We then use this list to mask any functions
|
%% any functions marked to ignore. We then use this list to mask any functions
|
||||||
%% marked as unused exports by xref
|
%% marked as unused exports by xref
|
||||||
F = fun(Mod) ->
|
F = fun(Mod) ->
|
||||||
Attrs = ks(attributes, Mod:module_info()),
|
Attrs = kf(attributes, Mod:module_info()),
|
||||||
Ignore = ks(ignore_xref, Attrs),
|
Ignore = kf(ignore_xref, Attrs),
|
||||||
Callbacks = [B:behaviour_info(callbacks) || B <- ks(behaviour, Attrs)],
|
Callbacks = [B:behaviour_info(callbacks) || B <- kf(behaviour, Attrs)],
|
||||||
[{Mod, F, A} || {F, A} <- Ignore ++ lists:flatten(Callbacks)]
|
[{Mod, F, A} || {F, A} <- Ignore ++ lists:flatten(Callbacks)]
|
||||||
end,
|
end,
|
||||||
AttrIgnore = lists:flatten(lists:map(F, lists:usort([M || {M, _, _} <- UnusedExports]))),
|
AttrIgnore = lists:flatten(lists:map(F, lists:usort([M || {M, _, _} <- UnusedExports]))),
|
||||||
[X || X <- UnusedExports, not(lists:member(X, AttrIgnore))].
|
[X || X <- UnusedExports, not(lists:member(X, AttrIgnore))].
|
||||||
|
|
||||||
|
|
||||||
|
kf(Key, List) ->
|
||||||
ks(Key, List) ->
|
case lists:keyfind(Key, 1, List) of
|
||||||
case lists:keysearch(Key, 1, List) of
|
{Key, Value} ->
|
||||||
{value, {Key, Value}} ->
|
|
||||||
Value;
|
Value;
|
||||||
false ->
|
false ->
|
||||||
[]
|
[]
|
||||||
|
|
Loading…
Reference in a new issue