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

"too many arguments for format string" warning #12910

Closed
andyw8 opened this issue May 16, 2024 · 4 comments · Fixed by #12938
Closed

"too many arguments for format string" warning #12910

andyw8 opened this issue May 16, 2024 · 4 comments · Fixed by #12938

Comments

@andyw8
Copy link
Contributor

andyw8 commented May 16, 2024

It doesn't cause a problem, but when running with warnings enabled, the following is emitted:

/home/runner/work/.../vendor/bundle/ruby/3.3.0/gems/rubocop-1.63.5/lib/rubocop/cop/mixin/surrounding_space.rb:87: warning: too many arguments for format string

(I think it may be a clash between the format defined by RuboCop and format defined in Kernel?)

The same can be seen when running RuboCop's own tests with config.warnings = true.

@Earlopain
Copy link
Contributor

There are quite a few of these. Some cops define multiple offense format strings with different "arity" and they just all get the same amount of arguments passed.

I looked at this in the past and some are trivial to fix, some require a bit more finesse.

@andyw8
Copy link
Contributor Author

andyw8 commented May 16, 2024

Ah, I see, thanks. Feel free to close if it's already been discussed previously.

@Earlopain
Copy link
Contributor

Earlopain commented May 17, 2024

I haven't talked about this with anyone. It's not a very common usecase since it's mostly a cli tool but I think it would be nice to have RuboCop warning-free anyways for those that use it in other ways.

You probably won't be able to raise on warnings since RuboCop inspects some rather strange-looking code (mostly regex stuff) but most looked fixable from what I remember.

Earlopain added a commit to Earlopain/rubocop that referenced this issue May 17, 2024
See rubocop#12910

This aren't all cops where this happens, just the ones with trivial solutions
@Earlopain
Copy link
Contributor

Earlopain commented May 17, 2024

I'm trying to some of these off:

Remaining:

Wasn't quite as much as I thought it would be. The regex warnings made up the bulk of all the warnings in the test suite

bbatsov pushed a commit that referenced this issue May 20, 2024
See #12910

This aren't all cops where this happens, just the ones with trivial solutions
Earlopain added a commit to Earlopain/rubocop that referenced this issue May 27, 2024
Closes rubocop#12910

This is inspired by how Rails approaches this
Earlopain added a commit to Earlopain/rubocop that referenced this issue May 27, 2024
This is inspired by how Rails approaches this
Earlopain added a commit to Earlopain/rubocop that referenced this issue May 27, 2024
This is inspired by how Rails approaches this
Earlopain added a commit to Earlopain/rubocop that referenced this issue May 27, 2024
This is inspired by how Rails approaches this
Earlopain added a commit to Earlopain/rubocop that referenced this issue May 28, 2024
This is inspired by how Rails approaches this
Earlopain added a commit to Earlopain/rubocop that referenced this issue May 28, 2024
This is inspired by how Rails approaches this
Earlopain added a commit to Earlopain/rubocop that referenced this issue May 28, 2024
This is inspired by how Rails approaches this
Earlopain added a commit to Earlopain/rubocop that referenced this issue May 28, 2024
This is inspired by how Rails approaches this
Earlopain added a commit to Earlopain/rubocop that referenced this issue May 29, 2024
This is inspired by how Rails approaches this
bbatsov pushed a commit that referenced this issue May 29, 2024
This is inspired by how Rails approaches this
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