Skip to content

Commit

Permalink
improvements based on suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
bormilan committed Nov 20, 2024
1 parent 0dca68f commit ee75d79
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/elvis_style.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1205,13 +1205,7 @@ ms_transform_included(Config, Target, RuleConfig) ->

FunctionCalls = get_fun_2_ms_calls(Root),

IsIncluded =
case length(FunctionCalls) > 0 of
true ->
is_include_ms_transform(Root);
false ->
false
end,
IsIncluded = FunctionCalls /= [] andalso has_include_ms_transform(Root),

ResultFun =
fun(Location) ->
Expand Down Expand Up @@ -1245,8 +1239,8 @@ is_ets_fun2ms(Node) ->

ets == ktn_code:attr(value, Module) andalso fun2ms == ktn_code:attr(value, Fun2).

-spec is_include_ms_transform(ktn_code:tree_node()) -> boolean().
is_include_ms_transform(Root) ->
-spec has_include_ms_transform(ktn_code:tree_node()) -> boolean().
has_include_ms_transform(Root) ->
Fun = fun(Node) ->
ktn_code:type(Node) == include_lib
andalso ktn_code:attr(value, Node) == "stdlib/include/ms_transform.hrl"
Expand Down
13 changes: 13 additions & 0 deletions test/examples/used_ignored_variable_in_macro.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-module(used_ignored_variable_in_macro).

-include_lib("stdlib/include/assert.hrl").

-define(MYMACRO(X), fun(X) -> ok end).

-export([do/0]).

do() ->
List = [{a, b}, {c, d}],
{_Key, b} = lists:keyfind(a, 1, List),
?assertMatch({_K, _}, lists:keyfind(a, 1, List)),
?MYMACRO({_P1, _}).

0 comments on commit ee75d79

Please sign in to comment.