Skip lib definitions altogether

This commit is contained in:
Sijawusz Pur Rahnama 2024-01-10 01:14:03 +01:00
parent d23ad7f0ab
commit 98d5bc720a
2 changed files with 12 additions and 0 deletions

View File

@ -998,6 +998,16 @@ module Ameba::Rule::Lint
CRYSTAL
end
it "doesn't report if it's referenced in a lib" do
expect_no_issues subject, <<-CRYSTAL
lib LibFoo
struct Foo
a : Int32
end
end
CRYSTAL
end
it "doesn't report if it's referenced" do
expect_no_issues subject, <<-CRYSTAL
def foo

View File

@ -39,6 +39,8 @@ module Ameba::Rule::Lint
end
def test(source, node, scope : AST::Scope)
return if scope.lib_def?(check_outer_scopes: true)
scope.variables.each do |var|
next if var.ignored? || var.used_in_macro? || var.captured_by_block?
next if exclude_type_declarations? && scope.assigns_type_dec?(var.name)