Show unused include warning only for files that are never used
This commit is contained in:
parent
1b8be7a749
commit
e6e6df9d21
@ -377,9 +377,15 @@ lookup_env(Env, Kind, Ann, Name) ->
|
|||||||
[Res = {_, {AnnR, _}}] ->
|
[Res = {_, {AnnR, _}}] ->
|
||||||
when_warning(warn_unused_includes,
|
when_warning(warn_unused_includes,
|
||||||
fun() ->
|
fun() ->
|
||||||
case proplists:get_value(include_type, Ann, none) of
|
%% If a file is used from a different file, we
|
||||||
none -> used_include(AnnR);
|
%% can then mark it as used
|
||||||
_ -> ok
|
F1 = proplists:get_value(file, Ann, no_file),
|
||||||
|
F2 = proplists:get_value(file, AnnR, no_file),
|
||||||
|
if
|
||||||
|
F1 /= F2 ->
|
||||||
|
used_include(AnnR);
|
||||||
|
true ->
|
||||||
|
ok
|
||||||
end
|
end
|
||||||
end),
|
end),
|
||||||
Res;
|
Res;
|
||||||
@ -859,13 +865,8 @@ infer1(Env, [{Contract, Ann, ConName, Code} | Rest], Acc, Options)
|
|||||||
infer1(Env, [{namespace, Ann, Name, Code} | Rest], Acc, Options) ->
|
infer1(Env, [{namespace, Ann, Name, Code} | Rest], Acc, Options) ->
|
||||||
when_warning(warn_unused_includes,
|
when_warning(warn_unused_includes,
|
||||||
fun() ->
|
fun() ->
|
||||||
case proplists:get_value(include_type, Ann, none) of
|
|
||||||
direct ->
|
|
||||||
SrcFile = proplists:get_value(src_file, Options, no_file),
|
SrcFile = proplists:get_value(src_file, Options, no_file),
|
||||||
potential_unused_include(Ann, SrcFile);
|
potential_unused_include(Ann, SrcFile)
|
||||||
_ ->
|
|
||||||
ok
|
|
||||||
end
|
|
||||||
end),
|
end),
|
||||||
check_scope_name_clash(Env, namespace, Name),
|
check_scope_name_clash(Env, namespace, Name),
|
||||||
{Env1, Code1} = infer_contract_top(push_scope(namespace, Name, Env), namespace, Code, Options),
|
{Env1, Code1} = infer_contract_top(push_scope(namespace, Name, Env), namespace, Code, Options),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user