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

Metrics/ClassLength calls class_definition? on nil. #8872

Closed
reitermarkus opened this issue Oct 9, 2020 · 3 comments · Fixed by #8873
Closed

Metrics/ClassLength calls class_definition? on nil. #8872

reitermarkus opened this issue Oct 9, 2020 · 3 comments · Fixed by #8873
Labels

Comments

@reitermarkus
Copy link
Contributor

reitermarkus commented Oct 9, 2020

The Metrics/ClassLength cop somewhere hits a point where it calls nil.class_definition?.


Expected behavior

No error.

Actual behavior

Error occurs:

Inspecting 1 file
Scanning /Users/Markus/Downloads/test.rb
An error occurred while Metrics/ClassLength cop was inspecting /Users/Markus/Downloads/test.rb:1:0.
undefined method `class_definition?' for nil:NilClass
/Users/Markus/.config/rbenv/versions/system/lib/ruby/gems/system/gems/rubocop-0.93.0/lib/rubocop/cop/metrics/class_length.rb:48:in `on_casgn'
.
.
.

Steps to reproduce the problem

  1. Create a file test.rb with these contents:
A, B, = C
  1. Call rubocop test.rb --display-cop-names --debug.

RuboCop version

$ rubocop -V
0.93.0 (using Parser 2.7.2.0, rubocop-ast 0.7.1, running on ruby 2.6.3 universal.x86_64-darwin19)
@reitermarkus reitermarkus changed the title Style/StringLiterals calls class_definition? on nil. Style/ClassLength calls class_definition? on nil. Oct 9, 2020
@reitermarkus reitermarkus changed the title Style/ClassLength calls class_definition? on nil. Metrics/ClassLength calls class_definition? on nil. Oct 9, 2020
@koic koic added the bug label Oct 9, 2020
koic added a commit to koic/rubocop that referenced this issue Oct 9, 2020
Fixes rubocop#8872.

This PR fixes an error for `Metrics/ClassLength`
when multiple assignments to constants.
bbatsov pushed a commit that referenced this issue Oct 9, 2020
Fixes #8872.

This PR fixes an error for `Metrics/ClassLength`
when multiple assignments to constants.
@jherdman
Copy link

Is it possible to release as a patch release? It's blocking me on an upgrade to 0.93.

@koic
Copy link
Member

koic commented Oct 12, 2020

@jherdman RuboCop 0.93.1 has been released. Thank you.
https://github.com/rubocop-hq/rubocop/releases/tag/v0.93.1

@jherdman
Copy link

jherdman commented Oct 12, 2020 via email

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.

3 participants