Reports also methods not ending with `?` suffix in `PredicateName` rule

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

View File

@ -30,6 +30,10 @@ module Ameba::Rule::Naming
def is_valid?(x)
# ^^^^^^^^^ error: Favour method name 'valid?' over 'is_valid?'
end
def is_valid(x)
# ^^^^^^^^ error: Favour method name 'valid?' over 'is_valid'
end
CRYSTAL
end

View File

@ -31,7 +31,7 @@ module Ameba::Rule::Naming
MSG = "Favour method name '%s?' over '%s'"
def test(source, node : Crystal::Def)
return unless node.name =~ /^is_([a-z]\w*)\?$/
return unless node.name =~ /^is_([a-z]\w*)\??$/
alternative = $1
issue_for node, MSG % {alternative, node.name}, prefer_name_location: true