codeclimate / codeclimate-rubocop

Code Climate Engine for Rubocop
MIT License
60 stars 45 forks source link

Adding `rubocop-capybara` as a required extension in configuration breaks build #346

Open vietqhoang opened 1 year ago

vietqhoang commented 1 year ago

Adding rubocop-capybara to the "required extensions" list in .rubocop.yml configuration file breaks the build on CodeClimate.

A snippet of the require list in the .rubocop.yml:

require:
  - rubocop-capybara
  - rubocop-rails
  - rubocop-rspec

A screenshot of the build error:

CleanShot 2023-03-01 at 18 59 29@2x

Our CodeClimate setup is using the beta channel. Running rubocop locally executes without issue.

The expectation is for the CodeClimate to run successfully.

The output log of the CodeClimate error:

/usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/feature_loader.rb:46:in `rescue in rescue in load': cannot load such file -- rubocop-capybara (LoadError)
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/feature_loader.rb:39:in `rescue in load'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/feature_loader.rb:32:in `load'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/feature_loader.rb:21:in `load'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/config_loader_resolver.rb:14:in `block (2 levels) in resolve_requires'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/config_loader_resolver.rb:13:in `each'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/config_loader_resolver.rb:13:in `block in resolve_requires'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/config_loader_resolver.rb:12:in `tap'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/config_loader_resolver.rb:12:in `resolve_requires'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/config_loader.rb:46:in `load_file'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/config_loader.rb:104:in `configuration_from_file'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/config_store.rb:68:in `for_dir'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/config_store.rb:58:in `for'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/target_finder.rb:117:in `combined_exclude_glob_patterns'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/target_finder.rb:85:in `find_files'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/target_finder.rb:59:in `target_files_in_dir'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/target_finder.rb:38:in `block in find'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/target_finder.rb:36:in `each'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/target_finder.rb:36:in `find'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/runner.rb:85:in `find_target_files'
    from /usr/src/app/lib/cc/engine/file_list_resolver.rb:15:in `block in expanded_list'
    from /usr/src/app/lib/cc/engine/file_list_resolver.rb:13:in `each'
    from /usr/src/app/lib/cc/engine/file_list_resolver.rb:13:in `flat_map'
    from /usr/src/app/lib/cc/engine/file_list_resolver.rb:13:in `expanded_list'
    from /usr/src/app/lib/cc/engine/rubocop.rb:47:in `files_to_inspect'
    from /usr/src/app/lib/cc/engine/rubocop.rb:27:in `block in run'
    from /usr/src/app/lib/cc/engine/rubocop.rb:26:in `chdir'
    from /usr/src/app/lib/cc/engine/rubocop.rb:26:in `run'
    from /usr/src/app/bin/codeclimate-rubocop:17:in `<main>'
/usr/local/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:155:in `require': cannot load such file -- rubocop/capybara (LoadError)
    from /usr/local/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:155:in `require'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/feature_loader.rb:42:in `rescue in load'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/feature_loader.rb:32:in `load'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/feature_loader.rb:21:in `load'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/config_loader_resolver.rb:14:in `block (2 levels) in resolve_requires'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/config_loader_resolver.rb:13:in `each'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/config_loader_resolver.rb:13:in `block in resolve_requires'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/config_loader_resolver.rb:12:in `tap'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/config_loader_resolver.rb:12:in `resolve_requires'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/config_loader.rb:46:in `load_file'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/config_loader.rb:104:in `configuration_from_file'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/config_store.rb:68:in `for_dir'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/config_store.rb:58:in `for'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/target_finder.rb:117:in `combined_exclude_glob_patterns'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/target_finder.rb:85:in `find_files'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/target_finder.rb:59:in `target_files_in_dir'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/target_finder.rb:38:in `block in find'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/target_finder.rb:36:in `each'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/target_finder.rb:36:in `find'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/runner.rb:85:in `find_target_files'
    from /usr/src/app/lib/cc/engine/file_list_resolver.rb:15:in `block in expanded_list'
    from /usr/src/app/lib/cc/engine/file_list_resolver.rb:13:in `each'
    from /usr/src/app/lib/cc/engine/file_list_resolver.rb:13:in `flat_map'
    from /usr/src/app/lib/cc/engine/file_list_resolver.rb:13:in `expanded_list'
    from /usr/src/app/lib/cc/engine/rubocop.rb:47:in `files_to_inspect'
    from /usr/src/app/lib/cc/engine/rubocop.rb:27:in `block in run'
    from /usr/src/app/lib/cc/engine/rubocop.rb:26:in `chdir'
    from /usr/src/app/lib/cc/engine/rubocop.rb:26:in `run'
    from /usr/src/app/bin/codeclimate-rubocop:17:in `<main>'
/usr/local/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:155:in `require': cannot load such file -- rubocop-capybara (LoadError)
    from /usr/local/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:155:in `require'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/feature_loader.rb:35:in `load'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/feature_loader.rb:21:in `load'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/config_loader_resolver.rb:14:in `block (2 levels) in resolve_requires'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/config_loader_resolver.rb:13:in `each'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/config_loader_resolver.rb:13:in `block in resolve_requires'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/config_loader_resolver.rb:12:in `tap'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/config_loader_resolver.rb:12:in `resolve_requires'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/config_loader.rb:46:in `load_file'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/config_loader.rb:104:in `configuration_from_file'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/config_store.rb:68:in `for_dir'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/config_store.rb:58:in `for'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/target_finder.rb:117:in `combined_exclude_glob_patterns'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/target_finder.rb:85:in `find_files'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/target_finder.rb:59:in `target_files_in_dir'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/target_finder.rb:38:in `block in find'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/target_finder.rb:36:in `each'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/target_finder.rb:36:in `find'
    from /usr/local/bundle/gems/rubocop-1.39.0/lib/rubocop/runner.rb:85:in `find_target_files'
    from /usr/src/app/lib/cc/engine/file_list_resolver.rb:15:in `block in expanded_list'
    from /usr/src/app/lib/cc/engine/file_list_resolver.rb:13:in `each'
    from /usr/src/app/lib/cc/engine/file_list_resolver.rb:13:in `flat_map'
    from /usr/src/app/lib/cc/engine/file_list_resolver.rb:13:in `expanded_list'
    from /usr/src/app/lib/cc/engine/rubocop.rb:47:in `files_to_inspect'
    from /usr/src/app/lib/cc/engine/rubocop.rb:27:in `block in run'
    from /usr/src/app/lib/cc/engine/rubocop.rb:26:in `chdir'
    from /usr/src/app/lib/cc/engine/rubocop.rb:26:in `run'
    from /usr/src/app/bin/codeclimate-rubocop:17:in `<main>
vietqhoang commented 1 year ago

Just an aside question: are there any environment variables present during the build process which can be used to determine the environment is CodeClimate? A cursory Google search didn't yield anything.

For the time being, in order to not roadblock my end, I was thinking to conditionally exclude rubocop-capybara using some preprocessing and adding a conditional to check for the environment variable.

vietqhoang commented 5 months ago

Having rubocop-rspec_rails department in the require on the rubocop config breaks the Codeclimate engine.

The reason for the inclusion of the department is that starting with Rubocop Rspec major version 3 many of the departments (Cabybara, FactoryBot, etc) have been extracted out of the dependency.

See the release: https://github.com/rubocop/rubocop-rspec/releases/tag/v3.0.0

And the specific changes which extracted out Rubocop Rspec Rails: https://github.com/rubocop/rubocop-rspec/pull/1830

/usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/feature_loader.rb:46:in `rescue in rescue in load': cannot load such file -- rubocop-rspec_rails (LoadError)
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/feature_loader.rb:39:in `rescue in load'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/feature_loader.rb:32:in `load'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/feature_loader.rb:21:in `load'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/config_loader_resolver.rb:14:in `block (2 levels) in resolve_requires'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/config_loader_resolver.rb:13:in `each'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/config_loader_resolver.rb:13:in `block in resolve_requires'
    from <internal:kernel>:90:in `tap'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/config_loader_resolver.rb:12:in `resolve_requires'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/config_loader.rb:53:in `load_file'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/config_loader.rb:112:in `configuration_from_file'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/config_store.rb:68:in `for_dir'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/config_store.rb:58:in `for'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/target_finder.rb:121:in `combined_exclude_glob_patterns'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/target_finder.rb:85:in `find_files'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/target_finder.rb:59:in `target_files_in_dir'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/target_finder.rb:38:in `block in find'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/target_finder.rb:36:in `each'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/target_finder.rb:36:in `find'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/runner.rb:111:in `find_target_files'
    from /usr/src/app/lib/cc/engine/file_list_resolver.rb:15:in `block in expanded_list'
    from /usr/src/app/lib/cc/engine/file_list_resolver.rb:13:in `each'
    from /usr/src/app/lib/cc/engine/file_list_resolver.rb:13:in `flat_map'
    from /usr/src/app/lib/cc/engine/file_list_resolver.rb:13:in `expanded_list'
    from /usr/src/app/lib/cc/engine/rubocop.rb:47:in `files_to_inspect'
    from /usr/src/app/lib/cc/engine/rubocop.rb:27:in `block in run'
    from /usr/src/app/lib/cc/engine/rubocop.rb:26:in `chdir'
    from /usr/src/app/lib/cc/engine/rubocop.rb:26:in `run'
    from /usr/src/app/bin/codeclimate-rubocop:17:in `<main>'
<internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:148:in `require': cannot load such file -- rubocop/rspec_rails (LoadError)
    from <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:148:in `require'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/feature_loader.rb:42:in `rescue in load'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/feature_loader.rb:32:in `load'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/feature_loader.rb:21:in `load'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/config_loader_resolver.rb:14:in `block (2 levels) in resolve_requires'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/config_loader_resolver.rb:13:in `each'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/config_loader_resolver.rb:13:in `block in resolve_requires'
    from <internal:kernel>:90:in `tap'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/config_loader_resolver.rb:12:in `resolve_requires'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/config_loader.rb:53:in `load_file'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/config_loader.rb:112:in `configuration_from_file'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/config_store.rb:68:in `for_dir'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/config_store.rb:58:in `for'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/target_finder.rb:121:in `combined_exclude_glob_patterns'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/target_finder.rb:85:in `find_files'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/target_finder.rb:59:in `target_files_in_dir'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/target_finder.rb:38:in `block in find'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/target_finder.rb:36:in `each'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/target_finder.rb:36:in `find'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/runner.rb:111:in `find_target_files'
    from /usr/src/app/lib/cc/engine/file_list_resolver.rb:15:in `block in expanded_list'
    from /usr/src/app/lib/cc/engine/file_list_resolver.rb:13:in `each'
    from /usr/src/app/lib/cc/engine/file_list_resolver.rb:13:in `flat_map'
    from /usr/src/app/lib/cc/engine/file_list_resolver.rb:13:in `expanded_list'
    from /usr/src/app/lib/cc/engine/rubocop.rb:47:in `files_to_inspect'
    from /usr/src/app/lib/cc/engine/rubocop.rb:27:in `block in run'
    from /usr/src/app/lib/cc/engine/rubocop.rb:26:in `chdir'
    from /usr/src/app/lib/cc/engine/rubocop.rb:26:in `run'
    from /usr/src/app/bin/codeclimate-rubocop:17:in `<main>'
<internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:148:in `require': cannot load such file -- rubocop-rspec_rails (LoadError)
    from <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:148:in `require'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/feature_loader.rb:35:in `load'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/feature_loader.rb:21:in `load'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/config_loader_resolver.rb:14:in `block (2 levels) in resolve_requires'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/config_loader_resolver.rb:13:in `each'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/config_loader_resolver.rb:13:in `block in resolve_requires'
    from <internal:kernel>:90:in `tap'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/config_loader_resolver.rb:12:in `resolve_requires'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/config_loader.rb:53:in `load_file'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/config_loader.rb:112:in `configuration_from_file'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/config_store.rb:68:in `for_dir'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/config_store.rb:58:in `for'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/target_finder.rb:121:in `combined_exclude_glob_patterns'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/target_finder.rb:85:in `find_files'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/target_finder.rb:59:in `target_files_in_dir'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/target_finder.rb:38:in `block in find'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/target_finder.rb:36:in `each'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/target_finder.rb:36:in `find'
    from /usr/local/bundle/gems/rubocop-1.56.3/lib/rubocop/runner.rb:111:in `find_target_files'
    from /usr/src/app/lib/cc/engine/file_list_resolver.rb:15:in `block in expanded_list'
    from /usr/src/app/lib/cc/engine/file_list_resolver.rb:13:in `each'
    from /usr/src/app/lib/cc/engine/file_list_resolver.rb:13:in `flat_map'
    from /usr/src/app/lib/cc/engine/file_list_resolver.rb:13:in `expanded_list'
    from /usr/src/app/lib/cc/engine/rubocop.rb:47:in `files_to_inspect'
    from /usr/src/app/lib/cc/engine/rubocop.rb:27:in `block in run'
    from /usr/src/app/lib/cc/engine/rubocop.rb:26:in `chdir'
    from /usr/src/app/lib/cc/engine/rubocop.rb:26:in `run'
    from /usr/src/app/bin/codeclimate-rubocop:17:in `<main>'