KEMBAR78
[Fix #14318] Add `WaywardPredicates` config to `Naming/PredicateMethod` to handle methods that look like predicates but aren't by dvandersluis · Pull Request #14327 · rubocop/rubocop · GitHub
Skip to content

Conversation

@dvandersluis
Copy link
Member

Allows Naming/PredicateMethod to be aware of methods that look like predicates but do not return a boolean value, when determining if a method's return value is boolean.

Fixes #14318.


Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.

@dvandersluis dvandersluis requested a review from bbatsov June 23, 2025 13:53
AllowedPatterns: []
AllowBangMethods: false
# Methods that are known to not return a boolean value, despite ending in `?`.
NonBooleanPredicates:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with the PR in general, I'm only wondering if we can come up with a better name for this, as predicates are supposed to return booleans, so it sounds odd when I read it. I'm thinking of something more fun like:

  • OutlawPredicates
  • DeviantPredicates
  • WaywardPredicates

:D

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha alright, I've changed it to WaywardPredicates now.

…teMethod` to handle methods that look like predicates but aren't
@dvandersluis dvandersluis changed the title [Fix #14318] Add NonBooleanPredicates config to Naming/PredicateMethod to handle methods that look like predicates but aren't [Fix #14318] Add WaywardPredicates config to Naming/PredicateMethod to handle methods that look like predicates but aren't Jun 25, 2025
@bbatsov bbatsov merged commit c17fb36 into rubocop:master Jun 26, 2025
24 checks passed
@bbatsov
Copy link
Collaborator

bbatsov commented Jun 26, 2025

Now that's proper RuboCop naming! 😁 Thanks for tackling this!

dvandersluis added a commit that referenced this pull request Jun 26, 2025
In #14327 the new configuration name was changed but I forgot to update the changelog.
viralpraxis pushed a commit to viralpraxis/rubocop that referenced this pull request Jul 3, 2025
In rubocop#14327 the new configuration name was changed but I forgot to update the changelog.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Naming/PredicateMethod should not be triggered by nonzero?

2 participants