-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
bugenhancementgood first issueEasy task, suitable for newcomers to the projectEasy task, suitable for newcomers to the project
Description
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
Expected behavior
No offenses, because the method returns a boolean, but is not a predicate. The boolean is the "result of the operation"
Actual behavior
test.rb:1:5: C: Naming/PredicateMethod: Predicate method names should end with ?.
def set_admin!
Steps to reproduce the problem
- Create a file
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
RuboCop version
$ 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
sled and morgoth
Metadata
Metadata
Assignees
Labels
bugenhancementgood first issueEasy task, suitable for newcomers to the projectEasy task, suitable for newcomers to the project