Skip to content

Commit

Permalink
Add test to assert NestedFunctionCalls does not warn for calls in a p…
Browse files Browse the repository at this point in the history
…ipeline
  • Loading branch information
Stratus3D committed Dec 16, 2022
1 parent 1c1b99e commit ca8fb52
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion test/credo/check/readability/nested_function_calls_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,22 @@ defmodule Credo.Check.Readability.NestedFunctionCallsTest do
|> refute_issues()
end

test "it should NOT two nested functions calls when the inner function call takes no arguments" do
test "it should NOT report nested function calls when the outer function is already in a pipeline" do
"""
defmodule CredoSampleModule do
def some_code do
[1,2,3,4]
|> Test.test()
|> Enum.map(SomeMod.some_fun(argument))
end
end
"""
|> to_source_file()
|> run_check(NestedFunctionCalls)
|> refute_issues()
end

test "it should NOT report two nested functions calls when the inner function call takes no arguments" do
"""
defmodule CredoSampleModule do
def some_code do
Expand Down Expand Up @@ -158,4 +173,21 @@ defmodule Credo.Check.Readability.NestedFunctionCallsTest do
|> run_check(NestedFunctionCalls, min_pipeline_length: 3)
|> refute_issues()
end

test "it should report nested function calls inside a pipeline when the inner function calls could be a pipeline of their own" do
"""
defmodule CredoSampleModule do
def some_code do
[1,2,3,4]
|> Test.test()
|> Enum.map(fn(item) ->
SomeMod.some_fun(another_fun(item))
end)
end
end
"""
|> to_source_file()
|> run_check(NestedFunctionCalls)
|> assert_issue()
end
end

0 comments on commit ca8fb52

Please sign in to comment.