mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Do not report shadowing outer local var is var is declared below the
shadowed var closes #144
This commit is contained in:
parent
99c65b5a28
commit
458c492730
5 changed files with 80 additions and 8 deletions
|
@ -34,6 +34,14 @@ module Ameba::Rule::Lint
|
|||
subject.catch(source).should_not be_valid
|
||||
end
|
||||
|
||||
it "does not report outer vars declared below shadowed block" do
|
||||
source = Source.new %(
|
||||
methods = klass.methods.select { |m| m.annotation(MyAnn) }
|
||||
m = methods.last
|
||||
)
|
||||
subject.catch(source).should be_valid
|
||||
end
|
||||
|
||||
it "reports if there is a shadowing in a proc" do
|
||||
source = Source.new %(
|
||||
def some_method
|
||||
|
@ -176,7 +184,7 @@ module Ameba::Rule::Lint
|
|||
end
|
||||
|
||||
context "macro" do
|
||||
it "does not report shadowed vars A" do
|
||||
it "does not report shadowed vars in outer scope" do
|
||||
source = Source.new %(
|
||||
macro included
|
||||
def foo
|
||||
|
@ -192,6 +200,19 @@ module Ameba::Rule::Lint
|
|||
)
|
||||
subject.catch(source).should be_valid
|
||||
end
|
||||
|
||||
it "does not report shadowed vars in macro withing the same scope" do
|
||||
source = Source.new %(
|
||||
{% methods = klass.methods.select { |m| m.annotation(MyAnn) } %}
|
||||
|
||||
{% for m, m_idx in methods %}
|
||||
{% if d = m.annotation(MyAnn) %}
|
||||
{% d %}
|
||||
{% end %}
|
||||
{% end %}
|
||||
)
|
||||
subject.catch(source).should be_valid
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue