Skip to content
代码片段 群组 项目
未验证 提交 824b95cd 编辑于 作者: Chou Yu Ta's avatar Chou Yu Ta 提交者: GitLab
浏览文件

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
上级 05235d6f
No related branches found
No related tags found
无相关合并请求
......@@ -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:
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册