-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
An error occurred while Style/RescueEnsureAlignment cop was inspecting #2119
Comments
Any news on this, @rrosenblum? I haven't been able to reproduce the issue. |
I am working on reproducing the issue. I have been unable to boil the code down to a small reproducible state. The error consistently happens on one of my machines, but I can not reproduce it on another. The issue is that |
I found the issue, and a way to reproduce it. The issue isn't specifically with # .rubocop.yml
Style/RescueEnsureAlignment:
Exclude:
- 'test.rb' # test.rb
begin
foo
rescue
bar
end When RuboCop is run, it will wind up inspecting the code in This issue does not happen when the file is excluded from AllCops. I am going to have to do some digging into how to fix this issue. |
It appears that the way Excluded files are handled is that the cop runs all From the commissioner code def investigate(processed_source)
reset_errors
prepare(processed_source)
invoke_custom_processing(@cops, processed_source)
invoke_custom_processing(@forces, processed_source)
process(processed_source.ast) if processed_source.ast
@cops.each_with_object([]) do |cop, offenses|
filename = processed_source.buffer.name
# ignore files that are of no interest to the cop in question
offenses.concat(cop.offenses) if cop.relevant_file?(filename)
end
end This doesn't seem like the best way to handle this. It would be preferable if we could avoid running the I will add a bug fix for |
The error message is
undefined method 'include?' for nil:NilClass
. This is happening in version0.33.0
.I am trying to limit down the code that causes this issue to provide example source. Placing breakpoints in the code, it appears that
investigate
isn't being run so@modifier_locations
is not set.A quick fix would be
or initializing
@modifier_locations
to[]
.One of the safeguards is worthwhile, but I am more curious why
investigate
does not appear to be running at all.The text was updated successfully, but these errors were encountered: