-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
Description
A method that returns true
, false
and implicit nil
is flagged as a predicate method.
def foo
case @foo
when "bar" then true
when "baz" then false
end
end
Changing the method body to an explicit nil
return fixes the offence.
def foo
case @foo
when "bar" then true
when "baz" then false
else nil
end
end
But raises the Style/EmptyElse
offence.
Expected behavior
My expectation is there for the foo
not to cause the Naming/PredicateMethod
offence. This is a conversion method that, for certain values, returns a boolean value.
Actual behavior
The foo
method causes the Naming/PredicateMethod
offence despite not being a predicate method.
Steps to reproduce the problem
Please see the description.
RuboCop version
$ [bundle exec] rubocop -V
1.77.0 (using Parser 3.3.8.0, rubocop-ast 1.45.1, analyzing as Ruby 3.4, running on ruby 3.4.2)