Add rake task rubocop:check:graceful
What does this MR do and why?
This MR adds a new rake task rake rubocop:check:graceful
which runs RuboCop checks in CI as usual but ignores offenses from "silenced" cop rules.
We silence a cop if it is enabled has Details: grace period
in the YAML configuration defined.
This new rake task is run on CI twice:
- In scheduled pipelines via
update-static-analysis-cache
- In case of silenced offenses Slack is notified
- On
master
or MRs with RuboCop-related changes viarubocop
job- In case of silenced offenses Slack is NOT notified to avoid spam
See #370433 (comment 1059067801).
haml-lint
. So each time we enable a cop with a grace period
we need to either fix the offenses or disable the cop rule in
.haml-lint.yml`.
Screenshots
update-static-analysis-cache - No offenses |
update-static-analysis-cache - Silenced offenses |
rubocop - No offenses |
rubocop - Silenced offenses |
rubocop - Active offense |
---|---|---|---|---|
https://gitlab.com/gitlab-org/gitlab/-/jobs/2991249901 ![]() |
https://gitlab.com/gitlab-org/gitlab/-/jobs/2991158530 ![]() |
https://gitlab.com/gitlab-org/gitlab/-/jobs/2991158530 ![]() |
https://gitlab.com/gitlab-org/gitlab/-/jobs/2991249938 ![]() |
https://gitlab.com/gitlab-org/gitlab/-/jobs/2991145665 ![]() |
Slack notification |
---|
![]() |
How to set up and validate locally
# Run uncached to trigger potential warnings from cops - see below
# --cache false won't work with --parallel
rm -fr tmp/rubocop_cache
bundle exec rake rubocop:check:graceful
# Enable some cop rules with TODOs and re-run
rm -fr tmp/rubocop_cache
bundle exec rake rubocop:check:graceful
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Peter Leitzen