mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Merge pull request #452 from crystal-ameba/reopen-issue-447
This commit is contained in:
commit
63be60ce96
2 changed files with 4 additions and 11 deletions
|
@ -402,11 +402,12 @@ module Ameba::Rule::Lint
|
||||||
CRYSTAL
|
CRYSTAL
|
||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't report type declaration as a call argument" do
|
pending "doesn't report type declaration as a call argument" do
|
||||||
expect_no_issues subject, <<-CRYSTAL
|
expect_no_issues subject, <<-CRYSTAL
|
||||||
foo Foo(T), foo : T
|
foo Foo(T), foo : T
|
||||||
foo Foo, foo : Nil
|
foo Foo, foo : Nil
|
||||||
foo foo : String, bar : Int32?
|
foo foo : String
|
||||||
|
foo foo : String, bar : Int32?, baz : Bool
|
||||||
CRYSTAL
|
CRYSTAL
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -43,10 +43,7 @@ module Ameba::Rule::Lint
|
||||||
|
|
||||||
scope.variables.each do |var|
|
scope.variables.each do |var|
|
||||||
next if var.ignored? || var.used_in_macro? || var.captured_by_block?
|
next if var.ignored? || var.used_in_macro? || var.captured_by_block?
|
||||||
|
next if exclude_type_declarations? && scope.assigns_type_dec?(var.name)
|
||||||
if scope.assigns_type_dec?(var.name)
|
|
||||||
next if exclude_type_declarations? || expressions_with_call?(node)
|
|
||||||
end
|
|
||||||
|
|
||||||
var.assignments.each do |assign|
|
var.assignments.each do |assign|
|
||||||
check_assignment(source, assign, var)
|
check_assignment(source, assign, var)
|
||||||
|
@ -54,11 +51,6 @@ module Ameba::Rule::Lint
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private def expressions_with_call?(node)
|
|
||||||
node.is_a?(Crystal::Expressions) &&
|
|
||||||
node.expressions.first?.is_a?(Crystal::Call)
|
|
||||||
end
|
|
||||||
|
|
||||||
private def check_assignment(source, assign, var)
|
private def check_assignment(source, assign, var)
|
||||||
return if assign.referenced?
|
return if assign.referenced?
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue