Do not report IsAFilter if there is a block with multiple args

This commit is contained in:
Vitalii Elenhaupt 2021-03-23 20:56:02 +02:00
parent 320ec2ba75
commit 13605afe4a
No known key found for this signature in database
GPG key ID: CD0BF17825928BC0
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 subject.catch(source).should_not be_valid
end 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 context "properties" do
it "allows to configure filter_names" do it "allows to configure filter_names" do
source = Source.new %( source = Source.new %(

View file

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