Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

{xref_ignores} now properly works on module, #2497

Merged
merged 3 commits into from
Jun 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/rebar_prv_xref.erl
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,6 @@ get_behaviour_callbacks(exports_not_used, Attributes) ->
get_behaviour_callbacks(_XrefCheck, _Attributes) ->
[].

parse_xref_result({_, MFAt}) -> MFAt;
parse_xref_result(MFAt) -> MFAt.

filter_xref_results(XrefCheck, XrefIgnores, XrefResults) ->
SearchModules = lists:usort(
lists:map(
Expand All @@ -194,10 +191,16 @@ filter_xref_results(XrefCheck, XrefIgnores, XrefResults) ->
Ignores = XrefIgnores ++ lists:flatmap(fun(Module) ->
get_xref_ignorelist(Module, XrefCheck)
end, SearchModules),
lists:filter( fun(Result) -> pred_xref_result(Result, Ignores) end, XrefResults).

pred_xref_result({Src, Dest}, Ignores) -> pred_xref_result1(Src, Ignores)
andalso pred_xref_result1(Dest, Ignores);
pred_xref_result(Vertex, Ignores) -> pred_xref_result1(Vertex, Ignores).

[Result || Result <- XrefResults,
not lists:member(element(1, Result), Ignores)
andalso not lists:member(parse_xref_result(Result), Ignores)].
pred_xref_result1(Vertex, Ignores) ->
Mod = case Vertex of {Module, _Func, _Arity} -> Module;
_ -> Vertex end,
not lists:member(Vertex, Ignores) andalso not lists:member(Mod, Ignores).

display_results(XrefResults, QueryResults) ->
[lists:map(fun display_xref_results_for_type/1, XrefResults),
Expand Down
4 changes: 2 additions & 2 deletions test/rebar_xref_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ get_module_body(ignoremod, AppName, IgnoreXref) ->
"localfunc1(A, B) -> {A, B}.\n", % used local
"localfunc2() -> ok.\n", % unused local
"fdeprecated() -> ok.\n" % deprecated function

"undef_call() -> non_existent_mod:func().\n" % undef function call
];
get_module_body(ignoremod2, AppName, IgnoreXref) ->
["-module(", AppName, "_ignoremod2).\n",
Expand All @@ -241,7 +241,7 @@ get_module_body(ignoremod2, AppName, IgnoreXref) ->
"localfunc1(A, B) -> {A, B}.\n", % used local
"localfunc2() -> ok.\n", % unused local
"fdeprecated() -> ok.\n" % deprecated function

"undef_call() -> non_existent_mod:func().\n" % undef function call
];
get_module_body(othermod, AppName, IgnoreXref) ->
["-module(", AppName, "_othermod).\n",
Expand Down