Lint/Void autocorrection is unsafe when a constant is referenced
When I run rubocop -a on this file:
Foo::Bar
class Foo::Bar
end
It rewrites the file like so:
class Foo::Bar
end
However, this is unsafe, due to Ruby's constant autoloading mechanism.
For example, in a Rails app, the constant may be referenced to force it to be loaded from another file, before apply a monkey-patch.
Expected behavior
Either the file is unchanged, or the change is only applied when unsafe autocorrections are used.
Actual behavior
See above.
Steps to reproduce the problem
- Put the above into
test.rb - Run
rubocop -a test.rb
RuboCop version
1.54.0 (using Parser 3.2.2.3, rubocop-ast 1.29.0, running on ruby 3.2.2) [aarch64-linux-musl]
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed soon if no further activity occurs. Thank you for your understanding!
This issue has been automatically closed due to lack of activity. Feel free to ask for it to be re-opened if you ever come back to it.