New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lint/FormatParameterMismatch false positive for fields with absolute argument numbers #6482
Labels
Comments
koic
added a commit
to koic/rubocop
that referenced
this issue
Nov 14, 2018
…atch` Fixes rubocop#6482. This PR fixes a false positive for `Lint/FormatParameterMismatch` when using (digit)$ flag. ```ruby format('%1$s %1$s', 'foo') ``` The following an explanation about (digit)$ flag written in the document. > Specifies the absolute argument number for this field. > Absolute and relative argument numbers cannot be mixed in a > sprintf string. https://ruby-doc.org/core-2.5.3/Kernel.html#method-i-sprintf This PR adds a check on the maximum value specified by (digit)$ and the number of arguments.
8 tasks
Thanks for the feedback. I confirmed this reproduction and I opened a PR #6483. |
Whoa, that's fast! Thank you. |
koic
added a commit
to koic/rubocop
that referenced
this issue
Nov 15, 2018
…atch` Fixes rubocop#6482. This PR fixes a false positive for `Lint/FormatParameterMismatch` when using (digit)$ flag. ```ruby format('%1$s %1$s', 'foo') ``` The following an explanation about (digit)$ flag written in the document. > Specifies the absolute argument number for this field. > Absolute and relative argument numbers cannot be mixed in a > sprintf string. https://ruby-doc.org/core-2.5.3/Kernel.html#method-i-sprintf This PR adds a check on the maximum value specified by (digit)$ and the number of arguments.
koic
added a commit
that referenced
this issue
Nov 15, 2018
…rameter_mismatch [Fix #6482] Fix a false positive for `Lint/FormatParameterMismatch`
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In the format string for
Kernel#format
you can specify the absolute argument number before a field using(digit)$
flag. Here are examples from the docs:RuboCop currently fails to deal with such situations.
Expected behavior
No offenses.
Actual behavior
Lint/FormatParameterMismatch offense.
Steps to reproduce the problem
Given this minimal example:
Run:
RuboCop version
The text was updated successfully, but these errors were encountered: