codeclimate / codeclimate-rubocop

Code Climate Engine for Rubocop
MIT License
59 stars 43 forks source link

Code quality in Gitlab ci fails with error: (CC::CLI::Analyze::EngineFailure) engine rubocop failed #331

Closed ep4sh closed 2 years ago

ep4sh commented 2 years ago

Dear community,

I'm facing an issue with codeclimate running on Gitlab CI,

$ docker pull --quiet "$CODE_QUALITY_IMAGE" 
$ docker run --rm \ # collapsed multi-line command
WARNING: A new version (v0.87.0) is available. Upgrade instructions are available at: https://github.com/codeclimate/codeclimate#packages
WARNING: A new version (v0.87.0) is available. Upgrade instructions are available at: https://github.com/codeclimate/codeclimate#packages
error: (CC::CLI::Analyze::EngineFailure) engine rubocop failed with status 1 and stderr 
/usr/local/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:155:in `require': cannot load such file -- pg_query (LoadError)
    from /usr/local/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:155:in `require'
    from /code/custom_cops/ambiguous_column.rb:26:in `<class:AmbiguousColumn>'
    from /code/custom_cops/ambiguous_column.rb:25:in `<module:Searcher>'
    from /code/custom_cops/ambiguous_column.rb:5:in `<module:Cop>'
    from /code/custom_cops/ambiguous_column.rb:4:in `<module:RuboCop>'
    from /code/custom_cops/ambiguous_column.rb:3:in `<top (required)>'
    from /usr/local/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:155:in `require'
    from /usr/local/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:155:in `require'
    from /usr/local/bundle/gems/rubocop-1.23.0/lib/rubocop/config_loader_resolver.rb:15:in `block (2 levels) in resolve_requires'
    from /usr/local/bundle/gems/rubocop-1.23.0/lib/rubocop/config_loader_resolver.rb:13:in `each'
    from /usr/local/bundle/gems/rubocop-1.23.0/lib/rubocop/config_loader_resolver.rb:13:in `block in resolve_requires'
    from /usr/local/bundle/gems/rubocop-1.23.0/lib/rubocop/config_loader_resolver.rb:12:in `tap'
    from /usr/local/bundle/gems/rubocop-1.23.0/lib/rubocop/config_loader_resolver.rb:12:in `resolve_requires'
    from /usr/local/bundle/gems/rubocop-1.23.0/lib/rubocop/config_loader.rb:44:in `load_file'
    from /usr/local/bundle/gems/rubocop-1.23.0/lib/rubocop/config_store.rb:29:in `options_config='
    from /usr/src/app/lib/cc/engine/rubocop.rb:54:in `block in config_store'
    from /usr/src/app/lib/cc/engine/rubocop.rb:52:in `tap'
    from /usr/src/app/lib/cc/engine/rubocop.rb:52:in `config_store'
    from /usr/src/app/lib/cc/engine/rubocop.rb:45:in `files_to_inspect'
    from /usr/src/app/lib/cc/engine/rubocop.rb:28:in `block in run'
    from /usr/src/app/lib/cc/engine/rubocop.rb:27:in `chdir'
    from /usr/src/app/lib/cc/engine/rubocop.rb:27:in `run'
    from /usr/src/app/bin/codeclimate-rubocop:17:in `<main>'
Could not analyze code quality for the repository at /code

my rubocop version is:

version: "2"
plugins:
  rubocop:
    enabled: true
    channel: "rubocop-1-23-0"
    config:
      file: ".rubocop.yml"

I assume it could be version incompatibility issue.... Could you please help me to find out what's wrong with my pipeline?

Best regards, Pasha

ep4sh commented 2 years ago

Initially pasted incorrect rubocop version, fixed now :) the correct version is 1.23.0 (accroding to the .codeclimate.yml)

ep4sh commented 2 years ago

Latest rubocop (https://github.com/codeclimate/codeclimate-rubocop/tree/channel/rubocop-1-31-0) and latest codeclimate (https://gitlab.com/gitlab-org/gitlab-foss/-/blob/master/lib/gitlab/ci/templates/Jobs/Code-Quality.gitlab-ci.yml#L11) fixed the issue.

I hope this will help someone :) Cheerz!