You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I expect that these 2 Cops would be able to work together and have the ability to distinguish between external gems and project code. My suggestion is that:
Lint/ConstantResolution focusses on project code, and ignores gems loaded through the Gemfile
Style/RedundantConstantBase focusses on external gems and doesn't check project references.
Actual behavior
When both are enabled, you end up in an infinite chicken/egg problem because both cops do not agree on the correct constant resolution in the source code.
Steps to reproduce the problem
Use the following code snippet:
::RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
config.example_status_persistence_file_path = '.rspec_status'
# Disable RSpec exposing methods globally on `Module` and `main`
config.disable_monkey_patching!
config.expect_with(:rspec) do |c|
c.syntax = :expect
end
end
…Base`
Fixesrubocop#11266.
This PR fixes a false positive for `Style/RedundantConstantBase`
when enabling `Lint/ConstantResolution`.
It respects `Lint/ConstantResolution` when enabling `Lint/ConstantResolution`.
OTOH, it respects `Style/RedundantConstantBase` when disabling `Lint/ConstantResolution`.
This is to honor the desire to enable the Lint cop which is disabled by default.
Fixes#11266.
This PR fixes a false positive for `Style/RedundantConstantBase`
when enabling `Lint/ConstantResolution`.
It respects `Lint/ConstantResolution` when enabling `Lint/ConstantResolution`.
OTOH, it respects `Style/RedundantConstantBase` when disabling `Lint/ConstantResolution`.
This is to honor the desire to enable the Lint cop which is disabled by default.
Expected behavior
I expect that these 2 Cops would be able to work together and have the ability to distinguish between external gems and project code. My suggestion is that:
Lint/ConstantResolution
focusses on project code, and ignores gems loaded through theGemfile
Style/RedundantConstantBase
focusses on external gems and doesn't check project references.Actual behavior
When both are enabled, you end up in an infinite chicken/egg problem because both cops do not agree on the correct constant resolution in the source code.
Steps to reproduce the problem
Use the following code snippet:
This triggers the following output from RuboCop
But if you apply the change and remove the leading
::
, the following is outputted instead:This means it's impossible to find a correct code approach to resolve this unless one of the Cops is disabled.
RuboCop version
The text was updated successfully, but these errors were encountered: