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
rubocop-i18n plugin specs fail on rubocop 1.38.0 #11169
Comments
We ran into the same problem w/ StandardRb, and traced it back to this PR and the additions made to the processed source module. I was able to fix it on the standardrb end by adding the same methods to our test helper that were added to the cop_helper in rubocop and that fixes it, but it seems like there should be some change to the module class either in rubocop-ast or in rubocop that would elide the need for the test fix? Not sure, what do you think @tdeo? |
Hey @camilopayan, I'm wondering if you couldn't be using the I believe that's what the subproject like rubocop-rails, rubocop-rspec are doing and should let you keep compatibility with other changes within rubocop's codebase in the future |
Using There's caveat using it in (large) projects which contain RuboCop related and non-related specs. Because This happened at GitLab twice already: https://gitlab.com/gitlab-org/gitlab/-/issues/382452#note_1182874406 Possible solution we found so far:
|
Ouch - I believe rubocop could provide some better documentation about it. I believe that shouldn't be a big deal for rubocop-i18n but for the record, here's how I'm doing it in our project: In require 'rubocop'
require 'rubocop/rspec/cop_helper'
require 'rubocop/rspec/shared_contexts'
require 'rubocop/rspec/expect_offense'
require 'rubocop-rspec'
require 'rubocop/rspec/shared_contexts/default_rspec_language_config_context'
require 'cops' # This is actually `lib/cops/` which contains our custom cops, make sure they're required during cop specs since they're not autoloaded
RSpec.configure do |config|
# spec/lib/cops/ is the folder containing specs for cops in our repo
config.define_derived_metadata(file_path: %r{/spec/lib/cops/}) do |meta|
meta[:cop_spec] = true
end
config.include CopHelper, :cop_spec
config.include RuboCop::RSpec::ExpectOffense, :cop_spec
config.include_context 'config', :cop_spec
config.include_context 'with default RSpec/Language config', :cop_spec
end This way, you don't have the default injections of |
Nearly all of the specs in the rubocop-18n plugin fail with the same error,
undefined method 'disabled' for nil:NilClass
. This started as of rubocop 1.38.0 and works fine in 1.37.1.The line in question is https://github.com/rubocop/rubocop/blob/v1.38.0/lib/rubocop/comment_config.rb#L94, which implies the registry is
nil
at this point.Expected behavior
This plugin's specs all pass with rubocop 1.37.1, and I would expect them to continue to pass.
Actual behavior
Thousands of spec errors all like the following:
Steps to reproduce the problem
HEAD
is puppetlabs/rubocop-i18n@92ef8f4)bundle update
bundle exec rake spec
bundle exec rspec spec/rubocop/cop/i18n/gettext/decorate_string_formatting_using_percent_spec.rb:44
RuboCop version
The text was updated successfully, but these errors were encountered: