Skip to content
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

Style/FormatStringToken false positive for double % #7439

Closed
svyatov opened this issue Oct 16, 2019 · 1 comment · Fixed by #7440
Closed

Style/FormatStringToken false positive for double % #7439

svyatov opened this issue Oct 16, 2019 · 1 comment · Fixed by #7440

Comments

@svyatov
Copy link

svyatov commented Oct 16, 2019

Rubocop sees Style/FormatStringToken in escaped % sign.

format '%<hit_rate>6.2f%%', hit_rate: 12.34
# => " 12.34%"

Expected behavior

Rubocop must not recognize Style/FormatStringToken offense here.

Actual behavior

Style/FormatStringToken: Prefer annotated tokens (like %<foo>s) over unannotated tokens (like %s).
        format '%<hit_rate>6.2f%%', hit_rate: hit_rate
                               ^^

Steps to reproduce the problem

Use provided code sample.

RuboCop version

$ [bundle exec] rubocop -V
0.75.1 (using Parser 2.6.5.0, running on ruby 2.6.1 x86_64-darwin18)
@buehmann
Copy link
Contributor

Thanks for the report! I am taking of this.

buehmann added a commit to buehmann/rubocop that referenced this issue Oct 17, 2019
`%%` is technically a format sequence in the `unannotated` style. But it
cannot be written in another style in a sensible way.
koic added a commit that referenced this issue Oct 17, 2019
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 a pull request may close this issue.

2 participants