Skip to content

Commit

Permalink
Do not count pin operator for ABC size
Browse files Browse the repository at this point in the history
Refs #1155
  • Loading branch information
rrrene committed Oct 20, 2024
1 parent 599a7d8 commit 3d9dae8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/credo/check/refactor/abc_size.ex
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ defmodule Credo.Check.Refactor.ABCSize do
@def_ops [:def, :defp, :defmacro]
@branch_ops [:.]
@condition_ops [:if, :unless, :for, :try, :case, :cond, :and, :or, :&&, :||]
@non_calls [:==, :fn, :__aliases__, :__block__, :if, :or, :|>, :%{}]
@non_calls [:==, :fn, :__aliases__, :__block__, :if, :or, :|>, :%{}, :^]

@doc false
@impl true
Expand Down
14 changes: 14 additions & 0 deletions test/credo/check/refactor/abc_size_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,20 @@ defmodule Credo.Check.Refactor.ABCSizeTest do
assert rounded_abc_size(source) == 3
end

test "it should NOT count pin operators (^) for abc size" do
source = """
def test(param, foo) do
case param do
^foo -> foo.bar
"bar" -> bar.baz
"baz" -> bux.bus
end
end
"""

assert rounded_abc_size(source) == 6
end

test "it should NOT count functions given to ignore for abc size" do
source = """
def fun() do
Expand Down

0 comments on commit 3d9dae8

Please sign in to comment.