mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Typeof scope
This commit is contained in:
parent
2704a0d8b1
commit
677c75716f
2 changed files with 23 additions and 0 deletions
|
@ -831,6 +831,24 @@ module Ameba::Rule::Lint
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "typeof" do
|
||||||
|
it "reports useless assigments in typeof" do
|
||||||
|
s = Source.new %(
|
||||||
|
typeof(begin
|
||||||
|
foo = 1
|
||||||
|
bar = 2
|
||||||
|
end)
|
||||||
|
)
|
||||||
|
subject.catch(s).should_not be_valid
|
||||||
|
s.issues.size.should eq 2
|
||||||
|
s.issues.first.location.to_s.should eq ":2:3"
|
||||||
|
s.issues.first.message.should eq "Useless assignment to variable `foo`"
|
||||||
|
|
||||||
|
s.issues.last.location.to_s.should eq ":3:3"
|
||||||
|
s.issues.last.message.should eq "Useless assignment to variable `bar`"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "macro" do
|
context "macro" do
|
||||||
it "doesn't report if assignment is referenced in macro" do
|
it "doesn't report if assignment is referenced in macro" do
|
||||||
s = Source.new %(
|
s = Source.new %(
|
||||||
|
|
|
@ -65,6 +65,11 @@ module Ameba::AST
|
||||||
on_scope_enter(node)
|
on_scope_enter(node)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# :nodoc:
|
||||||
|
def visit(node : Crystal::TypeOf)
|
||||||
|
on_scope_enter(node)
|
||||||
|
end
|
||||||
|
|
||||||
# :nodoc:
|
# :nodoc:
|
||||||
def visit(node : Crystal::CStructOrUnionDef)
|
def visit(node : Crystal::CStructOrUnionDef)
|
||||||
on_scope_enter(node)
|
on_scope_enter(node)
|
||||||
|
|
Loading…
Reference in a new issue