Lint/UselessAssign: ignore transformed assignemnts by the compiler

closes #127
This commit is contained in:
Vitalii Elenhaupt 2020-01-11 23:50:42 +02:00
parent 976f9729d5
commit 74dfa0b934
No known key found for this signature in database
GPG key ID: CD0BF17825928BC0
4 changed files with 82 additions and 1 deletions

View file

@ -225,6 +225,34 @@ module Ameba::Rule::Lint
subject.catch(s).should be_valid
end
context "when transformed" do
it "does not report if the first arg is transformed and not used" do
s = Source.new %(
collection.each do |(a, b)|
puts b
end
)
subject.catch(s).should be_valid
end
it "does not report if the second arg is transformed and not used" do
s = Source.new %(
collection.each do |(a, b)|
puts a
end
)
subject.catch(s).should be_valid
end
it "does not report if all transformed args are not used in a block" do
s = Source.new %(
collection.each do |(foo, bar), (baz, _qux), index, object|
end
)
subject.catch(s).should be_valid
end
end
it "does not report if global var" do
s = Source.new %(
def method