You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Gentoo Linux using desktop/plasma profile for version 23.0 and with kernel version 6.6.41.
What were you trying to do?
Replaced if condition by true for debug ABCSize check
ifmatch?({:fn,_meta,_args},ast)do# …end
Expected outcome
No idea how much points are expected, but 5 is definitely too much as just 6 lines with such a simple match? call would reach a limit.
The ABC size describes a metric based on assignments, branches and conditions.
Since ast is assigned above if condition I guess it should not count, right?
Branches are dot calls (like: mod.fun(…), right? Maybe it counts as +1 because of AST expansion to Kernel.match?(…) form …
Kernel.match?/2 is not a condition (if, unless, for, try, case, cond, and, or, &&, ||)
If that's correct then it should count as +1 for size. Not sure from where 5 comes - it does not match even if we count skipped patterns (_some_name) and ast with match? call would give at most 4 points. If you agree it would be awesome to count is as just +1 size, but as above I may be wrong here …
Actual outcome
Such a change decreases size by 5:
# afteriftruedo# …end
The text was updated successfully, but these errors were encountered:
Eiji7
changed the title
Using Kernel.match?2 to check if variable contains anonymous function AST increases size by 5 in Credo.Check.Refactor.ABCSize
Using Kernel.match?/2 to check if variable contains anonymous function AST increases size by 5 in Credo.Check.Refactor.ABCSizeNov 5, 2024
Environment
mix credo -v
):elixir -v
):What were you trying to do?
Replaced
if
condition bytrue
for debugABCSize
checkExpected outcome
No idea how much points are expected, but 5 is definitely too much as just 6 lines with such a simple
match?
call would reach a limit.ast
is assigned aboveif
condition I guess it should not count, right?dot
calls (like:mod.fun(…)
, right? Maybe it counts as+1
because of AST expansion toKernel.match?(…)
form …Kernel.match?/2
is not a condition (if
,unless
,for
,try
,case
,cond
,and
,or
,&&
,||
)If that's correct then it should count as +1 for size. Not sure from where
5
comes - it does not match even if we count skipped patterns (_some_name
) andast
withmatch?
call would give at most4
points. If you agree it would be awesome to count is as just+1
size, but as above I may be wrong here …Actual outcome
Such a change decreases size by 5:
The text was updated successfully, but these errors were encountered: