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

FormatParameterMismatch should ignore dynamic widths #2123

Closed
deivid-rodriguez opened this issue Aug 8, 2015 · 3 comments
Closed

FormatParameterMismatch should ignore dynamic widths #2123

deivid-rodriguez opened this issue Aug 8, 2015 · 3 comments
Labels

Comments

@deivid-rodriguez
Copy link
Contributor

$ cat bug.rb 
max_width = 7
id = 58
format('%*d', max_width, id)
$ rubocop bug.rb
Inspecting 1 file
W

Offenses:

bug.rb:3:1: W: Lint/FormatParameterMismatch: Number arguments (2) to format mismatches expected fields (1).
format('%*d', max_width, id)
^^^^^^

1 file inspected, 1 offense detected

This is a hard cop to get right...

@bbatsov bbatsov assigned bbatsov and unassigned bbatsov Aug 9, 2015
@bbatsov bbatsov added the bug label Aug 9, 2015
@bbatsov
Copy link
Collaborator

bbatsov commented Aug 10, 2015

//cc @edmz

@edmz
Copy link
Contributor

edmz commented Aug 10, 2015

I have been working on these, but they are a bit harder than what I originally thought.

@dreyks
Copy link
Contributor

dreyks commented Sep 8, 2015

what about the opposite situation?

v = [1, 2]
format('%d%d', *v)

W: Number arguments (1) to format mismatches expected fields (2).

this should probably be ignored too

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

4 participants