Use prefer_name_location: true in PredicateName rule

This commit is contained in:
Sijawusz Pur Rahnama 2023-11-14 03:30:15 +01:00
parent 15d241e138
commit 633ed7538e
2 changed files with 8 additions and 2 deletions

View file

@ -21,8 +21,14 @@ module Ameba::Rule::Naming
it "fails if predicate name is wrong" do
expect_issue subject, <<-CRYSTAL
class Image
def self.is_valid?(x)
# ^^^^^^^^^ error: Favour method name 'valid?' over 'is_valid?'
end
end
def is_valid?(x)
# ^^^^^^^^^^^^^^ error: Favour method name 'valid?' over 'is_valid?'
# ^^^^^^^^^ error: Favour method name 'valid?' over 'is_valid?'
end
CRYSTAL
end

View file

@ -34,7 +34,7 @@ module Ameba::Rule::Naming
return unless node.name =~ /^is_([a-z]\w*)\?$/
alternative = $1
issue_for node, MSG % {alternative, node.name}
issue_for node, MSG % {alternative, node.name}, prefer_name_location: true
end
end
end