Skip to content

Commit

Permalink
Add test spec covering accessor macros
Browse files Browse the repository at this point in the history
  • Loading branch information
Sija committed Dec 28, 2023
1 parent 4567293 commit aeffa6a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions spec/ameba/rule/lint/useless_assign_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,23 @@ module Ameba::Rule::Lint
CRYSTAL
end

it "doesn't report if this is an accessor declaration" do
accessor_macros = %w[setter class_setter]
%w[getter class_getter property class_property].each do |name|
accessor_macros << name
accessor_macros << "#{name}?"
accessor_macros << "#{name}!"
end
accessor_macros.each do |accessor|
expect_no_issues subject, <<-CRYSTAL
class Foo
#{accessor} foo : String?
#{accessor} bar = "bar"
end
CRYSTAL
end
end

it "does not report if assignment is referenced after the record declaration" do
expect_no_issues subject, <<-CRYSTAL
foo = 2
Expand Down

0 comments on commit aeffa6a

Please sign in to comment.