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:
|
# :nodoc:
|
||||||
def visit(node : Crystal::Case)
|
def visit(node : Crystal::Case)
|
||||||
|
return true if macro_condition
|
||||||
|
|
||||||
# Count the complexity of an exhaustive `Case` as 1
|
# Count the complexity of an exhaustive `Case` as 1
|
||||||
# Otherwise count the number of `When`s
|
# Otherwise count the number of `When`s
|
||||||
case_complexity = node.exhaustive? ? 1 : node.whens.size
|
@complexity += node.exhaustive? ? 1 : node.whens.size
|
||||||
@complexity += case_complexity unless macro_condition
|
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue