mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Do not report expanded arguments in ShadowingOuterLocalVar
rule
This commit is contained in:
parent
5aac63ea74
commit
30e3816ed1
2 changed files with 31 additions and 4 deletions
|
@ -31,6 +31,30 @@ module Ameba::Rule::Lint
|
|||
CRYSTAL
|
||||
end
|
||||
|
||||
pending "reports if there is a shadowing in an unpacked variable in a block" do
|
||||
expect_issue subject, <<-CRYSTAL
|
||||
def some_method
|
||||
foo = 1
|
||||
|
||||
[{3}].each do |(foo)|
|
||||
# ^ error: Shadowing outer local variable `foo`
|
||||
end
|
||||
end
|
||||
CRYSTAL
|
||||
end
|
||||
|
||||
pending "reports if there is a shadowing in an unpacked variable in a block (2)" do
|
||||
expect_issue subject, <<-CRYSTAL
|
||||
def some_method
|
||||
foo = 1
|
||||
|
||||
[{[3]}].each do |((foo))|
|
||||
# ^ error: Shadowing outer local variable `foo`
|
||||
end
|
||||
end
|
||||
CRYSTAL
|
||||
end
|
||||
|
||||
it "does not report outer vars declared below shadowed block" do
|
||||
expect_no_issues subject, <<-CRYSTAL
|
||||
methods = klass.methods.select { |m| m.annotation(MyAnn) }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue