Skip to content

[Fix #510] Clarify Performance/RegexpMatch message for !~ - #528

Merged
koic merged 1 commit into
rubocop:masterfrom
koic:fix_regexp_match_offense_message_for_bang_tilde
Aug 11, 2026
Merged

[Fix #510] Clarify Performance/RegexpMatch message for !~#528
koic merged 1 commit into
rubocop:masterfrom
koic:fix_regexp_match_offense_message_for_bang_tilde

Conversation

@koic

@koic koic commented Jul 14, 2026

Copy link
Copy Markdown
Member

The offense message said to use match? instead of !~, but following that wording literally when correcting by hand negates the logic of the expression. Prefix the suggested method with ! for !~, in the same way as Performance/StringInclude does, so that the message guides manual corrections that preserve behavior. The autocorrection was already correct and is unchanged.

Fixes #510.


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.

The offense message said to use `match?` instead of `!~`, but following that wording literally
when correcting by hand negates the logic of the expression. Prefix the suggested method with `!` for `!~`,
in the same way as `Performance/StringInclude` does, so that the message guides manual corrections
that preserve behavior. The autocorrection was already correct and is unchanged.

Fixes rubocop#510.
@koic
koic force-pushed the fix_regexp_match_offense_message_for_bang_tilde branch from 744fa30 to f1763dd Compare July 14, 2026 12:57
@koic
koic merged commit 9c60244 into rubocop:master Aug 11, 2026
15 checks passed
@koic
koic deleted the fix_regexp_match_offense_message_for_bang_tilde branch August 11, 2026 10:57
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.

Performance/RegexpMatch: Wording pitfall will negate code expression

1 participant