The Lint/DisjunctiveAssignmentInConstructor cop errors when if finds an empty constructor.
I am working on a branch to fix this. I should have a PR submitted shortly.
Lint/DisjunctiveAssignmentInConstructor cop to pass given an empty constructor:
def initialize
end
Rubocop errors out with a NoMethodError
An error occurred while Lint/DisjunctiveAssignmentInConstructor cop was inspected exmample.rb:2
NoMethodError:
undefined method `type' for nil:NilClass
$ bundle exec rubocop -V
0.63.0 (using Parser 2.6.0.0, running on ruby 2.5.3 x86_64-darwin17)
(but I think this was actually introduced in 0.62.x)
Thanks for your help!
I'm afraid this is only partially fixed. I discovered you can produce the error with the following code snippet (i.e. test.rb):
# frozen_string_literal: true
class NullLogger
def warn _message
end
end
This yields the following output:
cop test.rb
An error occurred while Lint/DisjunctiveAssignmentInConstructor cop was inspecting /Users/bkuhlmann/Dropbox/Development/OSS/test.rb:4:2.
To see the complete backtrace run rubocop -d.
Inspecting 1 file
An error occurred while Lint/DisjunctiveAssignmentInConstructor cop was inspecting /Users/bkuhlmann/Dropbox/Development/OSS/test.rb:4:2.
To see the complete backtrace run rubocop -d.
.
1 file inspected, no offenses detected
1 error occurred:
An error occurred while Lint/DisjunctiveAssignmentInConstructor cop was inspecting test.rb:4:2.
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.63.0 (using Parser 2.6.0.0, running on ruby 2.6.0 x86_64-darwin18)
This make using the null object pattern show up with errors. :cry:
I was able to isolate the above error further. It happens with the #initialize constructor only. Example:
class NullLogger
def initialize _parameters
end
end
@bkuhlmann This fix hasn't been released yet. i.e. It's only in the master branch. My guess is that the fix will be released in a future v0.63.1.
Mention the following information in the issue report:
0.63.0
Did you test this against the v0.63.0 release or against a build from the master branch?
For more about the release schedule, see the Changelog:
https://github.com/rubocop-hq/rubocop/blob/master/CHANGELOG.md
:bow: @rmm5t. Ah, sorry about that -- I see where I got confused now. I thought this was part of the 0.63.0 release which is what I'm currently using. I'll await the next release. :)
FYI, RuboCop 0.63.1 has been released.
Thanks! Picked up the latest update and all is green again. :)
Most helpful comment
Thanks! Picked up the latest update and all is green again. :)