Reinstore RuboCop, the Ruby linter
RuboCop is a very standard code style and static analysis tool for Ruby. GitLab makes extensive use of it, with almost a hundred of custom "cops" (rules).
I'm about to push a series with many long-pending refactors in HgGitRepository
and in particular corrections for all Rubocop offenses. It seems a good time to get a bit further down that path and
-
fix all current issues -
enforce RuboCop by CI
Side remark: my Emacs found its way to launch RuboCop in real-time, even with GitLab custom cops without any intervention on my part, probably other IDEs can do as well. This implies that I didn't have to learn how to actually launch it myself, and also that I personally suffer from a bad decrease in readability if too much code is offending.
Instructions are easy to found in standard GitLab development docs, but I'll still repost the most basic ones.
To launch RuboCop manually on a given path (file or directory) from the root of the Heptapod repository clone:
bundle exec rubocop PATH
A majority of offenses can be corrected with
bundle exec rubocop --auto-correct PATH
To launch on the whole tree, it is advised to use the parallel option. The first execution will take a long time (got 6mn on my workstation), and then it's reasonable:
bundle exec rubocop --parallel