mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Do not report unused block arguments in Lint/UnusedArgument
rule
This commit is contained in:
parent
858557bc07
commit
7f6bd2289e
2 changed files with 8 additions and 4 deletions
|
@ -115,21 +115,21 @@ module Ameba::Rule::Lint
|
|||
subject.catch(s).should be_valid
|
||||
end
|
||||
|
||||
it "reports if block arg is not used" do
|
||||
it "doesn't report if block arg is not used" do
|
||||
s = Source.new %(
|
||||
def method(&block)
|
||||
end
|
||||
)
|
||||
subject.catch(s).should_not be_valid
|
||||
subject.catch(s).should be_valid
|
||||
end
|
||||
|
||||
it "reports if unused and there is yield" do
|
||||
it "doesn't report if unused and there is yield" do
|
||||
s = Source.new %(
|
||||
def method(&block)
|
||||
yield 1
|
||||
end
|
||||
)
|
||||
subject.catch(s).should_not be_valid
|
||||
subject.catch(s).should be_valid
|
||||
end
|
||||
|
||||
it "doesn't report if it's an anonymous block" do
|
||||
|
|
|
@ -50,6 +50,10 @@ module Ameba::Rule::Lint
|
|||
end
|
||||
|
||||
def test(source, node : Crystal::Def, scope : AST::Scope)
|
||||
# `Lint/UnusedBlockArgument` rule covers this case explicitly
|
||||
if block_arg = node.block_arg
|
||||
scope.arguments.reject!(&.node.== block_arg)
|
||||
end
|
||||
ignore_defs? || find_unused_arguments source, scope
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue