Skip to content

Move all cops to Rubocop::Cop::*

Sean McGivern requested to merge use-conventional-cop-file-paths into master

We had our cops under Gitlab::Styles::Rubocop::Cop::*. On the version of RuboCop we're currently using, this is fine, but unconventional. (It's also quite wordy.)

However, on newer versions, this won't work as we want. https://github.com/rubocop/rubocop/pull/8490 changed the namespacing logic for cops. Previously, it was: the penultimate component of the class name is the namespace. After that PR, it is: all but the first two and last components of the class name combine to form the namespace.

Using an example from this project, Gitlab::Styles::Rubocop::Cop::Fips::MD5:

  • This was Fips / MD5.
  • With the new logic, it's Rubocop/Cop/Fips / MD5.

By renaming all cops to be under Rubocop::Cop directly, we can make the names consistent regardless of the RuboCop version. This change only moves the cops - all helpers, etc. are still under Gitlab::Styles.

Merge request reports