Skip to content

Commit 3bb32b4

Browse files
committed
Fix false positive for NestedFunctionCalls
Refs #1170
1 parent 94a735e commit 3bb32b4

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lib/credo/check/readability/nested_function_calls.ex

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ defmodule Credo.Check.Readability.NestedFunctionCalls do
6868
{nil, acc}
6969
end
7070

71+
# We don't look into @type attributes
72+
defp traverse({:@, _, [{:type, _, _args}]}, acc, _issue) do
73+
{nil, acc}
74+
end
75+
7176
# Any call
7277
defp traverse(
7378
{{_name, _loc, call}, meta, args} = ast,
@@ -137,7 +142,7 @@ defmodule Credo.Check.Readability.NestedFunctionCalls do
137142
:"<|>",
138143
:"^^^",
139144
:"~~~",
140-
:"..//"
145+
:..//
141146
]
142147

143148
def cannot_be_in_pipeline?(

test/credo/check/readability/nested_function_calls_test.exs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ defmodule Credo.Check.Readability.NestedFunctionCallsTest do
1010
test "it should NOT report code with no nested function calls" do
1111
"""
1212
defmodule CredoSampleModule do
13-
def some_code do
13+
@type type_name :: Keyword.t(Some.remote(some_arg))
14+
def some_code(_foo) do
1415
Enum.shuffle([1,2,3])
1516
end
1617
end

0 commit comments

Comments
 (0)