mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
parent
fafc5f4bdc
commit
04c7300964
3 changed files with 32 additions and 0 deletions
|
@ -124,6 +124,20 @@ module Ameba::Rule::Lint
|
||||||
subject.catch(source).should be_valid
|
subject.catch(source).should be_valid
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "doesn't report if it shadows record type declaration" do
|
||||||
|
source = Source.new %(
|
||||||
|
class FooBar
|
||||||
|
record Foo, index : String
|
||||||
|
|
||||||
|
def bar
|
||||||
|
3.times do |index|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
)
|
||||||
|
subject.catch(source).should be_valid
|
||||||
|
end
|
||||||
|
|
||||||
it "reports rule, location and message" do
|
it "reports rule, location and message" do
|
||||||
source = Source.new %(
|
source = Source.new %(
|
||||||
foo = 1
|
foo = 1
|
||||||
|
|
|
@ -408,6 +408,17 @@ module Ameba::Rule::Lint
|
||||||
)
|
)
|
||||||
subject.catch(s).should be_valid
|
subject.catch(s).should be_valid
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "doesn't report if assignment initialized and captured by block" do
|
||||||
|
s = Source.new %(
|
||||||
|
a : String? = nil
|
||||||
|
|
||||||
|
1.times do
|
||||||
|
a = "Fotis"
|
||||||
|
end
|
||||||
|
)
|
||||||
|
subject.catch(s).should be_valid
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "branching" do
|
context "branching" do
|
||||||
|
|
|
@ -110,6 +110,13 @@ module Ameba::AST
|
||||||
on_scope_end(node) if @current_scope.eql?(node)
|
on_scope_end(node) if @current_scope.eql?(node)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# :nodoc:
|
||||||
|
def visit(node : Crystal::TypeDeclaration)
|
||||||
|
if !@current_scope.type_definition? && (var = node.var).is_a?(Crystal::Var)
|
||||||
|
@current_scope.add_variable var
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# :nodoc:
|
# :nodoc:
|
||||||
def visit(node : Crystal::Arg)
|
def visit(node : Crystal::Arg)
|
||||||
@current_scope.add_argument node
|
@current_scope.add_argument node
|
||||||
|
|
Loading…
Reference in a new issue