Merge pull request #452 from crystal-ameba/reopen-issue-447

This commit is contained in:
Sijawusz Pur Rahnama 2024-01-22 19:30:21 +01:00 committed by GitHub
commit 63be60ce96
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 11 deletions

View file

@ -402,11 +402,12 @@ module Ameba::Rule::Lint
CRYSTAL
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
foo Foo(T), foo : T
foo Foo, foo : Nil
foo foo : String, bar : Int32?
foo foo : String
foo foo : String, bar : Int32?, baz : Bool
CRYSTAL
end

View file

@ -43,10 +43,7 @@ module Ameba::Rule::Lint
scope.variables.each do |var|
next if var.ignored? || var.used_in_macro? || var.captured_by_block?
if scope.assigns_type_dec?(var.name)
next if exclude_type_declarations? || expressions_with_call?(node)
end
next if exclude_type_declarations? && scope.assigns_type_dec?(var.name)
var.assignments.each do |assign|
check_assignment(source, assign, var)
@ -54,11 +51,6 @@ module Ameba::Rule::Lint
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)
return if assign.referenced?