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

TypeError while Metrics/AbcSize on self::Constant ||= something #8742

Closed
Tietew opened this issue Sep 17, 2020 · 2 comments
Closed

TypeError while Metrics/AbcSize on self::Constant ||= something #8742

Tietew opened this issue Sep 17, 2020 · 2 comments
Assignees
Labels

Comments

@Tietew
Copy link
Contributor

Tietew commented Sep 17, 2020

Steps to reproduce the problem

test.rb

def foo
  self::FooModule ||= Module.new
end

Note: same error when Object::FooModule ||=

Run rubocop

$ bundle exec rubocop -d --only Metrics/AbcSize test.rb
(snip)
Inspecting 1 file
Scanning .../test.rb
An error occurred while Metrics/AbcSize cop was inspecting .../test.rb:1:0.
no implicit conversion of RuboCop::AST::Node into String
.../rubocop-0.91.0/lib/rubocop/cop/metrics/utils/abc_size_calculator.rb:102:in `match?'
.../rubocop-0.91.0/lib/rubocop/cop/metrics/utils/abc_size_calculator.rb:102:in `capturing_variable?'
.../rubocop-0.91.0/lib/rubocop/cop/metrics/utils/abc_size_calculator.rb:87:in `assignment?'
.../rubocop-0.91.0/lib/rubocop/cop/metrics/utils/abc_size_calculator.rb:46:in `block in calculate'
.../rubocop-ast-0.4.1/lib/rubocop/ast/node.rb:626:in `block in visit_descendants'
(snip)
.

1 file inspected, no offenses detected

1 error occurred:
An error occurred while Metrics/AbcSize cop was inspecting .../test.rb:1:0.
Errors are usually caused by RuboCop bugs.
Please, report your problems to RuboCop's issue tracker.
https://github.com/rubocop-hq/rubocop/issues

Mention the following information in the issue report:
0.91.0 (using Parser 2.7.1.4, rubocop-ast 0.4.1, running on ruby 2.6.6 x86_64-linux)
Finished in 0.09263256285339594 seconds

RuboCop version

$ [bundle exec] rubocop -V
0.91.0 (using Parser 2.7.1.4, rubocop-ast 0.4.1, running on ruby 2.6.6 x86_64-linux)
@koic koic added the bug label Sep 17, 2020
@marcandre marcandre self-assigned this Sep 17, 2020
@marcandre
Copy link
Contributor

I'll handle this, just need a bit more time as I realize there are a few other issues...

marcandre added a commit to marcandre/rubocop that referenced this issue Sep 18, 2020
`var += ...` was counted twice
`obj.method += ...` was not counted
`Const ||= ...` was crashing [rubocop#8742]
marcandre added a commit that referenced this issue Sep 20, 2020
`var += ...` was counted twice
`obj.method += ...` was not counted
`Const ||= ...` was crashing [#8742]
@marcandre
Copy link
Contributor

Fixed, along with a few tweaks to the metric. Thanks for opening this issue.

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

3 participants