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.
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.
The foo
method causes the Naming/PredicateMethod
offence despite not being a predicate method.
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)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4