Skip to content
Permalink
Browse files

Merge pull request #713 from TheFirstAvenger/mb-pipe-chain-start-nil

Fix logic issue with PipeChainStart, excluding :atoms, and nil. Fixes #712
  • Loading branch information
rrrene committed Nov 26, 2019
2 parents 4ba9e9b + 39cee26 commit 4ed2f402d240281a4cbe803a04b3ab4548385361
@@ -205,9 +205,10 @@ defmodule Credo.Check.Refactor.PipeChainStart do
function_name = to_function_call_name(ast)

found_argument_types =
arguments
|> List.first()
|> argument_type()
case arguments do
[nil | _] -> [:atom]
x -> x |> List.first() |> argument_type()
end

Enum.member?(excluded_functions, function_name) ||
Enum.any?(
@@ -312,6 +312,22 @@ defmodule Credo.Check.Refactor.PipeChainStartTest do
|> refute_issues(@described_check, excluded_argument_types: [:number])
end

test "it should NOT report a violation for an excluded argument type /7" do
"""
insert(:event) |> schedule_events()
"""
|> to_source_file
|> refute_issues(@described_check, excluded_argument_types: [:atom])
end

test "it should NOT report a violation for an excluded argument type /8" do
"""
foo(nil) |> bar()
"""
|> to_source_file
|> refute_issues(@described_check, excluded_argument_types: [:atom])
end

#
# cases raising issues
#

0 comments on commit 4ed2f40

Please sign in to comment.
You can’t perform that action at this time.