mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
parent
bd68e8c3b3
commit
ddbcf5cb3f
3 changed files with 37 additions and 3 deletions
|
@ -475,6 +475,32 @@ module Ameba::Rule::Lint
|
|||
issue.location.to_s.should eq "source.cr:1:1"
|
||||
issue.message.should eq "Useless assignment to variable `foo`"
|
||||
end
|
||||
|
||||
it "doesn't report if top level variable defined inside class is referenced" do
|
||||
s = Source.new %(
|
||||
class A
|
||||
foo : String? = "foo"
|
||||
end
|
||||
|
||||
puts foo
|
||||
)
|
||||
subject.catch(s).should be_valid
|
||||
end
|
||||
|
||||
it "doesn't report if top level variable assigned inside class and referenced" do
|
||||
s = Source.new %(
|
||||
class A
|
||||
foo : String? = "foo"
|
||||
|
||||
bar do
|
||||
foo = "bar"
|
||||
end
|
||||
end
|
||||
|
||||
puts foo
|
||||
)
|
||||
subject.catch(s).should be_valid
|
||||
end
|
||||
end
|
||||
|
||||
context "branching" do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue