Commit 26035c62 authored by Harsh Chouraria's avatar Harsh Chouraria Committed by Evan Read

Section on overriding rubocop version

A failure occurs if recent versions of Ruby are used with Code Quality
jobs.

They fail because the default rubocop version in use does not support
very recent Ruby releases (in the past 2-3 years).

An override of configuration is required to make it work in this
situation.

This change adds a troubleshooting section that specifically explains
how to override the rubocop version to address the job errors.

Related to issue:
https://gitlab.com/gitlab-org/ci-cd/codequality/-/issues/28
parent 60ff8c11
...@@ -456,3 +456,32 @@ This can be due to multiple reasons: ...@@ -456,3 +456,32 @@ This can be due to multiple reasons:
GitLab only uses the Code Quality artifact from the latest created job (with the largest job ID). GitLab only uses the Code Quality artifact from the latest created job (with the largest job ID).
If multiple jobs in a pipeline generate a code quality artifact, those of earlier jobs are ignored. If multiple jobs in a pipeline generate a code quality artifact, those of earlier jobs are ignored.
To avoid confusion, configure only one job to generate a `gl-code-quality-report.json`. To avoid confusion, configure only one job to generate a `gl-code-quality-report.json`.
### Rubocop errors
When using Code Quality jobs on a **Ruby** project, you can encounter problems running Rubocop.
For example, the following error can appear when using either a very recent or very old version
of Ruby:
```plaintext
/usr/local/bundle/gems/rubocop-0.52.1/lib/rubocop/config.rb:510:in `check_target_ruby':
Unknown Ruby version 2.7 found in `.ruby-version`. (RuboCop::ValidationError)
Supported versions: 2.1, 2.2, 2.3, 2.4, 2.5
```
This is caused by the default version of **rubocop** used by the check engine not covering
support for the Ruby version in use.
To use a custom version of **rubocop** that
[supports the version of Ruby used by the project](https://docs.rubocop.org/rubocop/compatibility.html#support-matrix),
you can [override the configuration through a `.codeclimate.yml` file](https://docs.codeclimate.com/docs/rubocop#using-rubocops-newer-versions)
created in the project repository.
For example, to specify using **rubocop** release **0.67**:
```yaml
version: "2"
plugins:
rubocop:
enabled: true
channel: rubocop-0-67
```
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment