Skip to content

Fix Style/RedundantFormat false positive when a interpolated value is given to a specifier with a width or precision#14608

Merged
koic merged 1 commit intorubocop:masterfrom
dvandersluis:issue/14604
Oct 17, 2025
Merged

Fix Style/RedundantFormat false positive when a interpolated value is given to a specifier with a width or precision#14608
koic merged 1 commit intorubocop:masterfrom
dvandersluis:issue/14604

Conversation

@dvandersluis
Copy link
Member

When format or sprintf has a specifier with a width or precision, and the related argument is an interpolated string, we cannot register that as a redundant format, as we cannot know ahead of time how wide the resulting string should be since it depends on the value of the interpolation.

Fixes #14604.


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 force-pushed the issue/14604 branch 2 times, most recently from 0e7d7e6 to 9c5059b Compare October 16, 2025 20:33
… interpolated value is given to a specifier with a width or precision
@koic koic merged commit f7f653f into rubocop:master Oct 17, 2025
22 checks passed
@koic
Copy link
Member

koic commented Oct 17, 2025

Thanks!

@dvandersluis dvandersluis deleted the issue/14604 branch October 17, 2025 17:41
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.

Style/RedundantFormat gives doubly inconsistent advice

2 participants