Skip to content

add rubocop pre-commit hooks #408

@kbroch-rivosinc

Description

@kbroch-rivosinc

As with the other code in the repo (python, yaml, json, etc), pre-commit hooks have been put in place to allow dev's to find and fix coding lint issue and consistently format the code before committing it. Time for ruby?

Currently there is already a .rubocop.yml file so I assume that's the starting point for what we want to lint/fmt.

If so, just need to add the pre-commit cfg

Command line options of how rubocop runs in the pre-commit hook can be found here: https://github.com/rubocop/rubocop/blob/master/.pre-commit-hooks.yaml

@dhower-qc It is probably a bad idea to merge into main the autocorrected changes given how many other ruby related PRs are active but rather let the changes occur gradually as the files are edited for other reasons. I am going to put 2 commits (one for pre-commit config, other with autocorrected changes) in the PR to show the autocorrected changes and let the CI run on them but I imagine removing the autocorrected changes before it is merged. Thoughts?

Currently running pre-commit rubocop cfg:

❯ pre-commit run --all-files rubocop

...

2 files inspected, 308 offenses detected, 230 offenses corrected, 2 more offenses can be corrected with `rubocop -A`

Tip: Based on detected gems, the following RuboCop extension libraries might be helpful:
  * rubocop-rake (https://rubygems.org/gems/rubocop-rake)

You can opt out of this message by adding the following to your config (see https://docs.rubocop.org/rubocop/extensions.html#extension-suggestions for more options):
  AllCops:
    SuggestExtensions: false

~/rvi/repos/riscv-software-src/riscv-unified-db on dev/kbroch/rubocop-pre-commit:main ⇡1 !38          took 9s at 10:09:06 AM

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions