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 should allow unnamed single formats #7944

Closed
marcandre opened this issue May 8, 2020 · 2 comments
Closed

Style/FormatStringToken should allow unnamed single formats #7944

marcandre opened this issue May 8, 2020 · 2 comments

Comments

@marcandre
Copy link
Contributor

I like the idea of that cop, but IIC, it wants me to change

format('%.2f', percentage)
# => into
format('%{percentage}.2f', percentage: percentage)

May I suggest that formatting a single parameter shouldn't require such verbosity? Or that there is at least an option to that effect? Current situation sounds to me like a cop that would enforce that all methods use only named parameters, even those with a single argument!

(Yes, I know, I can disable the cop for now...)

@noraj
Copy link

noraj commented Jul 13, 2020

https://docs.rubocop.org/rubocop/0.88/cops_style.html#styleformatstringtoken

There is EnforcedStyle: unannotated but there is no EnabledForSingleParameter: false yet.

cc. @backus

@bbatsov
Copy link
Collaborator

bbatsov commented Jul 13, 2020

Probably it'd be better if there was a config for the parameter count (e.g. 1,2,3) after which params should be named, but it's also a bit weird when to have special cases only for certain styles - they make the configuration harder to understand.

Tietew added a commit to Tietew/rubocop that referenced this issue Oct 16, 2020
…`Style/FormatStringToken` cop.

`MaxUnannotatedPlaceholdersAllowed` defines the number of `unannotated`
style token in a format string to be allowed when enforced style is not
`unannotated`.
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