From 824b95cd29e6938fbc308ea85fa2007fcd593a09 Mon Sep 17 00:00:00 2001 From: Chou Yu Ta <lawrencechou1024@gmail.com> Date: Tue, 11 Feb 2025 13:38:41 +0000 Subject: [PATCH] Correct script for listing of cop rules with offenses The intent of `:\d+\d+:` is probably to match `:35:7` from a log line like below: ``` lib/backup/tasks/task.rb:35:7: C: [Correctable] Style/EndlessMethod: Avoid endless method definitions. ``` Take the [raw_job_output.log] from https://gitlab.com/gitlab-org/gitlab/-/merge_requests/179410 for example: Before fix (incorrect): ``` $ grep --perl-regexp -o ":\d+\d+: \w: \[\S+\] ([\w/]+)" raw_job_output.log | awk '{print $4}' | sort | uniq -c 10 Layout/TrailingWhitespace 2 Style/SuperArguments ``` After fix (correct): ``` $ grep --perl-regexp -o ":\d+:\d+: \w: \[\S+\] ([\w/]+)" raw_job_output.log | awk '{print $4}' | sort | uniq -c 30 Layout/EmptyLinesAroundMethodBody 10 Layout/TrailingWhitespace 70 Style/EndlessMethod 14 Style/SuperArguments ``` [raw_job_output.log]: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/179410#raw_job_outputlog --- .gitlab/merge_request_templates/New Version of gitlab-styles.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab/merge_request_templates/New Version of gitlab-styles.md b/.gitlab/merge_request_templates/New Version of gitlab-styles.md index 725fa216b38e1..aa94e9688b679 100644 --- a/.gitlab/merge_request_templates/New Version of gitlab-styles.md +++ b/.gitlab/merge_request_templates/New Version of gitlab-styles.md @@ -18,7 +18,7 @@ This MR can be reused to upgrade `gitlab-styles` in this project after a new ver - [ ] (Optional) [Generate TODOs](https://docs.gitlab.com/ee/development/rubocop_development_guide.html#resolving-rubocop-exceptions) for pending offenses - [ ] Put :new: cop rules (or if configuration is changed) in "grace period". See [docs](https://docs.gitlab.com/ee/development/rubocop_development_guide.html#enabling-a-new-cop). - [ ] (Optional) Remove any offenses for disabled cops - - Use `grep --perl-regexp -o ":\d+\d+: \w: \[\S+\] ([\w/]+)" raw_job_output.log | awk '{print $4}' | sort | uniq -c` to get a list of cop rules with offenses. Where `raw_job_output.log` is the raw output of the `rubocop` job + - Use `grep --extended-regexp -o ":[0-9]+:[0-9]+: [[:alnum:]]: \[[^[:space:]]+\] ([[:alnum:]/]+)" raw_job_output.log | awk '{print $4}' | sort | uniq -c` to get a list of cop rules with offenses. Where `raw_job_output.log` is the raw output of the `rubocop` job - [ ] (Optional) Autocorrect offenses (only if the changeset is small) - [ ] Compare the total runtime of `rubocop --parallel` scan with previous runs - [ ] Make sure CI passes and does not have "silenced offenses" :green_heart: -- GitLab