The new Naming/PredicateMethod
is returning a false positive for a method which is, maybe, not the best method ever but it is definitely not a predicate method
def set_admin! raise 'Nope' unless some_checks? admin_arel.first_or_create true end
Actually, the true
is just used to return a simpler object here. I'm not incline to remove it and return the internal admin object, but if you think it should work that way I would do the change
No offenses, because the method returns a boolean, but is not a predicate. The boolean is the "result of the operation"
Actual behaviortest.rb:1:5: C: Naming/PredicateMethod: Predicate method names should end with ?.
def set_admin!
Steps to reproduce the problem
test.rb
def set_admin! raise 'Nope' unless some_checks? admin_arel.first_or_create true end
bundle exec rubocop --only Naming/PredicateMethod test.rb
$ be rubocop -V
1.76.0 (using Parser 3.3.8.0, rubocop-ast 1.45.0, analyzing as Ruby 2.7, running on ruby 3.4.3) [arm64-darwin24]
From main branch
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