mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Stop calculating cyclomatic complexity for methods which have Macro conditions (#99)
This commit is contained in:
parent
a0da393429
commit
c95ea297bd
2 changed files with 36 additions and 2 deletions
|
@ -18,6 +18,32 @@ module Ameba::AST
|
|||
visitor.count.should eq 1
|
||||
end
|
||||
|
||||
it "is 1 if there is Macro::For" do
|
||||
code = %(
|
||||
def initialize()
|
||||
{% for c in ALL_NODES %}
|
||||
true || false
|
||||
{% end %}
|
||||
end
|
||||
)
|
||||
node = Crystal::Parser.new(code).parse
|
||||
visitor = CountingVisitor.new node
|
||||
visitor.count.should eq 1
|
||||
end
|
||||
|
||||
it "is 1 if there is Macro::If" do
|
||||
code = %(
|
||||
def initialize()
|
||||
{% if foo.bar? %}
|
||||
true || false
|
||||
{% end %}
|
||||
end
|
||||
)
|
||||
node = Crystal::Parser.new(code).parse
|
||||
visitor = CountingVisitor.new node
|
||||
visitor.count.should eq 1
|
||||
end
|
||||
|
||||
{% for pair in [
|
||||
{code: "if true; end", description: "conditional"},
|
||||
{code: "while true; end", description: "while loop"},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue