mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Early return in CountVisitor if macro node
Co-authored-by: Sijawusz Pur Rahnama <sija@sija.pl>
This commit is contained in:
parent
0ea6238dc6
commit
c49c69ed9f
1 changed files with 4 additions and 2 deletions
|
@ -32,10 +32,12 @@ module Ameba::AST
|
|||
|
||||
# :nodoc:
|
||||
def visit(node : Crystal::Case)
|
||||
return true if macro_condition
|
||||
|
||||
# Count the complexity of an exhaustive `Case` as 1
|
||||
# Otherwise count the number of `When`s
|
||||
case_complexity = node.exhaustive? ? 1 : node.whens.size
|
||||
@complexity += case_complexity unless macro_condition
|
||||
@complexity += node.exhaustive? ? 1 : node.whens.size
|
||||
|
||||
true
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue