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/RedundantFormat error undefined method 'type?' for nil #13880

Closed
tagliala opened this issue Feb 20, 2025 · 1 comment · Fixed by #13881
Closed

Style/RedundantFormat error undefined method 'type?' for nil #13880

tagliala opened this issue Feb 20, 2025 · 1 comment · Fixed by #13881
Assignees
Labels

Comments

@tagliala
Copy link
Contributor

Tested also against master. At the best of my knowledge, this is not a duplicate

$ bundle exec rubocop test.rb --only Style/RedundantFormat
Inspecting 1 file
An error occurred while Style/RedundantFormat cop was inspecting ./test.rb:2:5.
To see the complete backtrace run rubocop -d.
.

1 file inspected, no offenses detected

1 error occurred:
An error occurred while Style/RedundantFormat cop was inspecting ./test.rb:2:5.
Errors are usually caused by RuboCop bugs.
Please, update to the latest RuboCop version if not already in use, and report a bug if the issue still occurs on this version.
https://github.com/rubocop/rubocop/issues

Mention the following information in the issue report:
1.72.2 (using Parser 3.3.7.1, rubocop-ast 1.38.0, analyzing as Ruby 3.0, running on ruby 3.4.1) [arm64-darwin24]

Expected behavior

Cop not returning an error

Actual behavior

Describe here what actually happened.
Please use rubocop --debug when pasting rubocop output as it contains additional information.

Steps to reproduce the problem

  1. Create test.rb
config = { username: 'test', password: 'test' }
puts format('%<username>s:%<password>s', **config.slice(:username, :password))
  1. bundle exec rubocop test.rb --only Style/RedundantFormat --debug
$ bundle exec rubocop test.rb --only Style/RedundantFormat --debug
For ~/dev/ifad/chronomodel: configuration from ./.rubocop.yml
Default configuration from ~/.rvm/gems/ruby-3.4.1/bundler/gems/rubocop-e585e474e280/config/default.yml
Use parallel by default.
Skipping parallel inspection: only a single file needs inspection
Inspecting 1 file
Scanning ~/dev/ifad/chronomodel/test.rb
An error occurred while Style/RedundantFormat cop was inspecting ,/test.rb:2:5.
undefined method 'type?' for nil
~/.rvm/gems/ruby-3.4.1/bundler/gems/rubocop-e585e474e280/lib/rubocop/cop/style/redundant_format.rb:156:in 'RuboCop::Cop::Style::RedundantFormat#matching_argument?'
~/.rvm/gems/ruby-3.4.1/bundler/gems/rubocop-e585e474e280/lib/rubocop/cop/style/redundant_format.rb:127:in 'block in RuboCop::Cop::Style::RedundantFormat#all_fields_literal?'
~/.rvm/gems/ruby-3.4.1/bundler/gems/rubocop-e585e474e28
...OMISSIS...

rubocop.yml

$ cat .rubocop.yml 
AllCops:
  NewCops: disable

RuboCop version

Tested against master

$ [bundle exec] rubocop -V
$ bundle exec rubocop -V
1.72.2 (using Parser 3.3.7.1, rubocop-ast 1.38.0, analyzing as Ruby 3.0, running on ruby 3.4.1) [arm64-darwin24]
@dvandersluis dvandersluis self-assigned this Feb 20, 2025
@dvandersluis
Copy link
Member

Thanks for the report, I can reproduce. I'll take a look now.

dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Feb 20, 2025
dvandersluis added a commit that referenced this issue Feb 20, 2025
[Fix #13880] Fix `Style/RedundantFormat` when given double-splatted arguments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants