mirror of
https://github.com/correl/rebar.git
synced 2024-12-18 03:00:17 +00:00
Make sure to add ebin/ to the code path as well so that xref can properly determine source/line of code.
This commit is contained in:
parent
8f85d70897
commit
0add7acdbf
1 changed files with 9 additions and 2 deletions
|
@ -48,6 +48,10 @@ xref(Config, _) ->
|
||||||
{verbose, rebar_config:is_verbose()}]),
|
{verbose, rebar_config:is_verbose()}]),
|
||||||
{ok, _} = xref:add_directory(xref, "ebin"),
|
{ok, _} = xref:add_directory(xref, "ebin"),
|
||||||
|
|
||||||
|
%% Save the code path prior to doing anything
|
||||||
|
OrigPath = code:get_path(),
|
||||||
|
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,
|
||||||
undefined_function_calls]),
|
undefined_function_calls]),
|
||||||
|
@ -68,6 +72,9 @@ xref(Config, _) ->
|
||||||
ok
|
ok
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
%% Restore the original code path
|
||||||
|
code:set_path(OrigPath),
|
||||||
|
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
foobar() ->
|
foobar() ->
|
||||||
|
@ -87,7 +94,6 @@ check_exports_not_used(_Config) ->
|
||||||
|
|
||||||
check_undefined_function_calls(_Config) ->
|
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",
|
[?CONSOLE("~s:~w: Warning ~s calls undefined function ~s\n",
|
||||||
|
@ -98,7 +104,7 @@ check_undefined_function_calls(_Config) ->
|
||||||
|
|
||||||
code_path() ->
|
code_path() ->
|
||||||
[P || P <- code:get_path(),
|
[P || P <- code:get_path(),
|
||||||
filelib:is_dir(P)].
|
filelib:is_dir(P)] ++ [filename:join(rebar_utils:get_cwd(), "ebin")].
|
||||||
|
|
||||||
%%
|
%%
|
||||||
%% Ignore behaviour functions, and explicitly marked functions
|
%% Ignore behaviour functions, and explicitly marked functions
|
||||||
|
@ -182,3 +188,4 @@ find_mfa_source({M, F, A}) ->
|
||||||
Source = abstract_code_source_file(Code),
|
Source = abstract_code_source_file(Code),
|
||||||
Line = abstract_code_function_line(Code, F, A),
|
Line = abstract_code_function_line(Code, F, A),
|
||||||
{Source, Line}.
|
{Source, Line}.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue