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

False positive Number arguments (1) to String#% mismatches expected fields (6). #2307

Closed
obfuscoder opened this issue Oct 7, 2015 · 1 comment
Labels

Comments

@obfuscoder
Copy link

I got this code:

data = [1, 2, 3, 4, 5, 6]
order = '%02d%03d%01d%02d%02d%03d' % data

Running rubocop yields this:

t.rb:2:36: W: Number arguments (1) to String#% mismatches expected fields (6).
order = '%02d%03d%01d%02d%02d%03d' % data

I expect to not see any warnings here.

I am running rubocop 0.34.2 on JRuby 1.7.20

@bbatsov bbatsov added the bug label Oct 7, 2015
@bbatsov
Copy link
Collaborator

bbatsov commented Oct 7, 2015

//cc @edmz

alexdowad added a commit to alexdowad/rubocop that referenced this issue Oct 27, 2015
If the LHS is not a literal, it could evaluate to a format string with any
number of arguments, so we can't count an offense for that. On the other hand,
if the RHS is not a literal, it could evaluate to an array with any number
of arguments, so we can't count an offense for that either.

Fixes rubocop#2307.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants