Reputation: 2250
I am attempting to enable code quality reports for merge requests for a Ruby on Rails application managed in GitLab.
In my .gitlab-ci.yml
file I have added the code quality template.
.gitlab-ci.yml:
include:
- template: Jobs/SAST.gitlab-ci.yml
- template: Jobs/Secret-Detection.gitlab-ci.yml
- template: Code-Quality.gitlab-ci.yml
My .rubocop.yml
file, stored in the root of the project has lots of configuration.
require:
- rubocop-rspec
- rubocop-rails
- rubocop-performance
Style/HashEachMethods:
Enabled: true
Style/HashTransformKeys:
Enabled: true
Metrics/AbcSize:
Enabled: false
…
And I have configured a .codeclimate.yml
file as such.
version: "2"
plugins:
rubocop:
enabled: true
channel: rubocop-1-48-1
config:
file: .rubocop.yml
If I run rubocop locally I get a clean bill of health. When GitLab runs it as part of a merge request pipeline, it has over 100 failures.
Major - Method
get_state
has 32 lines of code (exceeds 25 allowed). Consider refactoring.in app/services/order/order_service.rb:62
I am basing my config on GitLab's Documentation and Code Climate's documentation.
Edit: Here is what I get when I run codeclimate locally, with the specific details of the failing code obfuscated.
✗ docker run \
--interactive --tty --rm \
--env CODECLIMATE_CODE="$PWD" \
--volume "$PWD":/code \
--volume /var/run/docker.sock:/var/run/docker.sock \
--volume /tmp/cc:/tmp/cc \
codeclimate/codeclimate analyze
Starting analysis
Running structure: Done!
Running duplication: Done!
Running rubocop: Done!
== app/controllers/foobar_controller.rb (1 issue) ==
18-29: Method `barbaz` has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. [structure]
…
Upvotes: 1
Views: 250