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 for Lint/FormatParameterMismatch when options param is a local variable #2506

Closed
backus opened this issue Dec 15, 2015 · 5 comments

Comments

@backus
Copy link
Contributor

backus commented Dec 15, 2015

Example

params = { y: '2015', m: '01', d: '01' }

puts format('%{y}-%{m}-%{d}', params)

Rubocop output

$ cat ex.rb
params = { y: '2015', m: '01', d: '01' }

puts format('%{y}-%{m}-%{d}', params)

$ ruby ex.rb
2015-01-01

$ rubocop -v
0.35.1

$ rubocop -D ex.rb
Inspecting 1 file
W

Offenses:

ex.rb:3:6: W: Lint/FormatParameterMismatch: Number arguments (1) to format mismatches expected fields (0).
puts format('%{y}-%{m}-%{d}', params)
     ^^^^^^

1 file inspected, 1 offense detected
@OfTheDelmer
Copy link

👍 just had this issue

@alexdowad
Copy link
Contributor

The thing to check here is whether the format string contains %{name} or %<name> format specifiers.

@alexdowad
Copy link
Contributor

Just pushed a fix to a branch which has an open PR...

@backus
Copy link
Contributor Author

backus commented Dec 15, 2015

Wow thanks for the quick fix @alexdowad

@backus
Copy link
Contributor Author

backus commented Dec 15, 2015

@alexdowad I cloned your fork and verified that the issue in question is fixed on your perf branch. Thanks again.

I think it might make sense though to cherry-pick this fix out of your perf branch and open a separate PR for it since this is independent of performance linting and also likely to be merged and released much more quickly than a new set of features.

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

No branches or pull requests

3 participants