Merge pull request #216 from crystal-ameba/is_a_filter_in_multi_args_block

Do not report IsAFilter if there is a block with multiple args
This commit is contained in:
Sijawusz Pur Rahnama 2021-03-23 21:30:09 +01:00 committed by GitHub
commit f4ffb8a287
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View file

@ -26,6 +26,15 @@ module Ameba::Rule::Style
subject.catch(source).should_not be_valid
end
it "does not report if there .is_a? call within block with multiple arguments" do
source = Source.new %(
t.all? { |_, v| v.is_a?(String) }
t.all? { |foo, bar| foo.is_a?(String) }
t.all? { |foo, bar| bar.is_a?(String) }
)
subject.catch(source).should be_valid
end
context "properties" do
it "allows to configure filter_names" do
source = Source.new %(

View file

@ -52,6 +52,7 @@ module Ameba::Rule::Style
return unless (body = block.body).is_a?(Crystal::IsA)
return unless (path = body.const).is_a?(Crystal::Path)
return unless body.obj.is_a?(Crystal::Var)
return if block.args.size > 1
name = path.names.join("::")
name = "::#{name}" if path.global? && !body.nil_check?