Skip to content

Commit 3d9dae8

Browse files
committed
Do not count pin operator for ABC size
Refs #1155
1 parent 599a7d8 commit 3d9dae8

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/credo/check/refactor/abc_size.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ defmodule Credo.Check.Refactor.ABCSize do
2727
@def_ops [:def, :defp, :defmacro]
2828
@branch_ops [:.]
2929
@condition_ops [:if, :unless, :for, :try, :case, :cond, :and, :or, :&&, :||]
30-
@non_calls [:==, :fn, :__aliases__, :__block__, :if, :or, :|>, :%{}]
30+
@non_calls [:==, :fn, :__aliases__, :__block__, :if, :or, :|>, :%{}, :^]
3131

3232
@doc false
3333
@impl true

test/credo/check/refactor/abc_size_test.exs

+14
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,20 @@ defmodule Credo.Check.Refactor.ABCSizeTest do
336336
assert rounded_abc_size(source) == 3
337337
end
338338

339+
test "it should NOT count pin operators (^) for abc size" do
340+
source = """
341+
def test(param, foo) do
342+
case param do
343+
^foo -> foo.bar
344+
"bar" -> bar.baz
345+
"baz" -> bux.bus
346+
end
347+
end
348+
"""
349+
350+
assert rounded_abc_size(source) == 6
351+
end
352+
339353
test "it should NOT count functions given to ignore for abc size" do
340354
source = """
341355
def fun() do

0 commit comments

Comments
 (0)