mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Lint/UnusedArgument: fails to recognized used argument inside macro
closes #117
This commit is contained in:
parent
677c75716f
commit
904b5beec2
2 changed files with 16 additions and 1 deletions
|
@ -228,6 +228,21 @@ module Ameba::Rule::Lint
|
|||
)
|
||||
subject.catch(s).should be_valid
|
||||
end
|
||||
|
||||
it "doesn't report used args in macro literals" do
|
||||
s = Source.new %(
|
||||
def print(f : Array(U)) forall U
|
||||
f.size.times do |i|
|
||||
{% if U == Float64 %}
|
||||
puts f[i].round(3)
|
||||
{% else %}
|
||||
puts f[i]
|
||||
{% end %}
|
||||
end
|
||||
end
|
||||
)
|
||||
subject.catch(s).should be_valid
|
||||
end
|
||||
end
|
||||
|
||||
context "properties" do
|
||||
|
|
|
@ -55,7 +55,7 @@ module Ameba::Rule::Lint
|
|||
|
||||
private def find_unused_arguments(source, scope)
|
||||
scope.arguments.each do |argument|
|
||||
next if argument.ignored? || scope.references?(argument.variable)
|
||||
next if argument.ignored? || scope.references?(argument.variable) || argument.variable.used_in_macro?
|
||||
|
||||
name_suggestion = scope.node.is_a?(Crystal::Block) ? '_' : "_#{argument.name}"
|
||||
issue_for argument.node, MSG % {argument.name, name_suggestion}
|
||||
|
|
Loading…
Reference in a new issue