Просмотр исходного кода

xref: Also ignore targets where applicable

Loïc Hoguin 3 лет назад
Родитель
Сommit
bf7a194b0b
2 измененных файлов с 17 добавлено и 12 удалено
  1. 5 4
      plugins/xref.mk
  2. 12 8
      test/plugin_xref.mk

+ 5 - 4
plugins/xref.mk

@@ -107,9 +107,9 @@ define xref.erl
 			true -> Res0;
 			true -> Res0;
 			false ->
 			false ->
 				lists:filter(fun(R) ->
 				lists:filter(fun(R) ->
-					{Mod, MFA} = case R of
-						{MFA0 = {M, _, _}, _} -> {M, MFA0};
-						{M, _, _} -> {M, R}
+					{Mod, InMFA, MFA} = case R of
+						{InMFA0 = {M, _, _}, MFA0} -> {M, InMFA0, MFA0};
+						{M, _, _} -> {M, R, R}
 					end,
 					end,
 					Attrs = try
 					Attrs = try
 						Mod:module_info(attributes)
 						Mod:module_info(attributes)
@@ -147,7 +147,8 @@ define xref.erl
 						true -> [$(XREF_IGNORE)]
 						true -> [$(XREF_IGNORE)]
 					end,
 					end,
 					Ignores = InlineIgnores ++ BuiltinIgnores ++ CallbackIgnores ++ WideIgnores,
 					Ignores = InlineIgnores ++ BuiltinIgnores ++ CallbackIgnores ++ WideIgnores,
-					not (lists:member(MFA, Ignores)
+					not (lists:member(InMFA, Ignores)
+					orelse lists:member(MFA, Ignores)
 					orelse lists:member({Mod, '_', '_'}, Ignores))
 					orelse lists:member({Mod, '_', '_'}, Ignores))
 				end, Res0)
 				end, Res0)
 		end,
 		end,

+ 12 - 8
test/plugin_xref.mk

@@ -215,7 +215,7 @@ xref-ignore-inline-fa: init
 		"-module(bad)." \
 		"-module(bad)." \
 		"-export([f/0])." \
 		"-export([f/0])." \
 		"-ignore_xref([{f,0}])." \
 		"-ignore_xref([{f,0}])." \
-		"f() -> this_module:does_not_exist()." \
+		"f() -> f_module:f_not_exist()." \
 		> $(APP)/src/bad.erl
 		> $(APP)/src/bad.erl
 
 
 	$i "Run the Xref plugin, expect success"
 	$i "Run the Xref plugin, expect success"
@@ -228,12 +228,14 @@ xref-ignore-inline-mfa: init
 	$t cp ../erlang.mk $(APP)/
 	$t cp ../erlang.mk $(APP)/
 	$t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
 	$t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
 
 
-	$i "Create a module with an undefined function call and an inline ignore"
+	$i "Create a module with undefined function calls and inline ignores"
 	$t printf "%s\n" \
 	$t printf "%s\n" \
 		"-module(bad)." \
 		"-module(bad)." \
-		"-export([f/0])." \
+		"-export([f/0, g/0])." \
 		"-ignore_xref([{bad,f,0}])." \
 		"-ignore_xref([{bad,f,0}])." \
-		"f() -> this_module:does_not_exist()." \
+		"-ignore_xref({g_module,g_not_exist,0})." \
+		"f() -> f_module:f_not_exist()." \
+		"g() -> g_module:g_not_exist()." \
 		> $(APP)/src/bad.erl
 		> $(APP)/src/bad.erl
 
 
 	$i "Run the Xref plugin, expect success"
 	$i "Run the Xref plugin, expect success"
@@ -246,12 +248,14 @@ xref-ignore-inline-mod: init
 	$t cp ../erlang.mk $(APP)/
 	$t cp ../erlang.mk $(APP)/
 	$t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
 	$t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
 
 
-	$i "Create a module with an undefined function call and an inline ignore"
+	$i "Create a module with undefined function calls and inline ignores"
 	$t printf "%s\n" \
 	$t printf "%s\n" \
 		"-module(bad)." \
 		"-module(bad)." \
-		"-export([f/0])." \
-		"-ignore_xref(?MODULE)." \
-		"f() -> this_module:does_not_exist()." \
+		"-export([f/0, g/0])." \
+		"-ignore_xref([?MODULE])." \
+		"-ignore_xref(g_module)." \
+		"f() -> f_module:f_not_exist()." \
+		"g() -> g_module:g_not_exist()." \
 		> $(APP)/src/bad.erl
 		> $(APP)/src/bad.erl
 
 
 	$i "Run the Xref plugin, expect success"
 	$i "Run the Xref plugin, expect success"