summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFred Hebert <mononcqc@ferd.ca>2016-04-30 10:12:34 -0400
committerFred Hebert <mononcqc@ferd.ca>2016-04-30 10:12:34 -0400
commitc9cc58d2b885249da3ad7f738f922a83bfb302d1 (patch)
treee130ef95260d29d81bdf059089c5710624401788 /src
parent98751fa3fdd12d497ecda7da14f93214c6a09c53 (diff)
parent77b5181299d3cbcc0a1080ef13123eb56b971070 (diff)
Merge pull request #1056 from lpgauth/xref_ignores
Add support for xref_ignores
Diffstat (limited to 'src')
-rw-r--r--src/rebar_prv_xref.erl22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/rebar_prv_xref.erl b/src/rebar_prv_xref.erl
index f600273..45badd3 100644
--- a/src/rebar_prv_xref.erl
+++ b/src/rebar_prv_xref.erl
@@ -38,10 +38,10 @@ init(State) ->
do(State) ->
code:add_pathsa(rebar_state:code_paths(State, all_deps)),
XrefChecks = prepare(State),
-
+ XrefIgnores = rebar_state:get(State, xref_ignores, []),
%% Run xref checks
?INFO("Running cross reference analysis...", []),
- XrefResults = xref_checks(XrefChecks),
+ XrefResults = xref_checks(XrefChecks, XrefIgnores),
%% Run custom queries
QueryChecks = rebar_state:get(State, xref_queries, []),
@@ -110,16 +110,18 @@ prepare(State) ->
sets:from_list(ConfXrefChecks))),
XrefChecks.
-xref_checks(XrefChecks) ->
- lists:foldl(fun run_xref_check/2, [], XrefChecks).
+xref_checks(XrefChecks, XrefIgnores) ->
+ run_xref_checks(XrefChecks, XrefIgnores, []).
-run_xref_check(XrefCheck, Acc) ->
+run_xref_checks([], _XrefIgnores, Acc) ->
+ Acc;
+run_xref_checks([XrefCheck | T], XrefIgnores, Acc) ->
{ok, Results} = xref:analyze(xref, XrefCheck),
- case filter_xref_results(XrefCheck, Results) of
+ case filter_xref_results(XrefCheck, XrefIgnores, Results) of
[] ->
- Acc;
+ run_xref_checks(T, XrefIgnores, Acc);
FilterResult ->
- [{XrefCheck, FilterResult} | Acc]
+ run_xref_checks(T, XrefIgnores, [{XrefCheck, FilterResult} | Acc])
end.
check_query({Query, Value}, Acc) ->
@@ -170,7 +172,7 @@ get_behaviour_callbacks(_XrefCheck, _Attributes) ->
parse_xref_result({_, MFAt}) -> MFAt;
parse_xref_result(MFAt) -> MFAt.
-filter_xref_results(XrefCheck, XrefResults) ->
+filter_xref_results(XrefCheck, XrefIgnores, XrefResults) ->
SearchModules = lists:usort(
lists:map(
fun({Mt,_Ft,_At}) -> Mt;
@@ -178,7 +180,7 @@ filter_xref_results(XrefCheck, XrefResults) ->
(_) -> undefined
end, XrefResults)),
- Ignores = lists:flatmap(fun(Module) ->
+ Ignores = XrefIgnores ++ lists:flatmap(fun(Module) ->
get_xref_ignorelist(Module, XrefCheck)
end, SearchModules),