Skip to content

Commit 80d528f

Browse files
authoredMar 18, 2025··
Merge pull request #1185 from Eiji7/patch-1
Fix false positive for NestedFunctionCalls
2 parents 20e62ee + f622c24 commit 80d528f

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed
 

‎lib/credo/check/readability/nested_function_calls.ex

+3-2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ 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
71+
# We don't look into typespec attributes
72+
defp traverse({:@, _, [{attr_name, _, _args}]}, acc, _issue)
73+
when attr_name in ~w[callback macrocallback opaque spec type typep]a do
7374
{nil, acc}
7475
end
7576

‎test/credo/check/readability/nested_function_calls_test.exs

+5-3
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ 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+
@callback callback_name :: Keyword.t(Some.remote(some_arg))
14+
@macrocallback macrocallback_name :: Keyword.t(Some.remote(some_arg))
15+
@spec spec_name :: Keyword.t(Some.remote(some_arg))
16+
@opaque opaque_name :: Keyword.t(Some.remote(some_arg))
1317
@type type_name :: Keyword.t(Some.remote(some_arg))
14-
def some_code(_foo) do
15-
Enum.shuffle([1,2,3])
16-
end
18+
@typep typep_name :: Keyword.t(Some.remote(some_arg))
1719
end
1820
"""
1921
|> to_source_file()

0 commit comments

Comments
 (0)
Please sign in to comment.