Give Codacy's RuboCop a config it can load without the omakase gem

Merged
JA
2mo ago
+204-0

Problem

.rubocop.yml starts with inherit_gem: rubocop-rails-omakase: rubocop.yml. Codacy's RuboCop runner doesn't install that gem, so its RuboCop stage errors on the missing gem before it lints anything. This was seen in Codacy's analysis log on #268.

Change

Adds .rubocop-codacy.yml: rubocop-rails-omakase 1.1.0's configuration (the version pinned in Gemfile.lock) flattened together with the overrides in .rubocop.yml. It needs only rubocop-performance and rubocop-rails. The app never reads it, and bin/rubocop and the ci/lint job still use .rubocop.yml. The only reader is the drift test below.

The file first went in on #268 (9752435f3). It's fork tooling unrelated to that fix, and #268 is the trial run for an upstream PR, so it moves here and is removed there.

Out of scope

  • How Codacy is pointed at this file. Nothing in the repository names it: there's no .codacy.yml. The link, if any, is set in Codacy's own settings, which I can't see.
  • Codacy's other failures on #268. PMD7's parser NullPointerException on unchanged JavaScript controllers, and its Diff/Deltas stage errors, are separate.

Validation

  • bundle exec rubocop -c .rubocop-codacy.yml over all of fork main gives 0 offences, the same as bundle exec rubocop with .rubocop.yml.
  • The config catches real offences. A throwaway file with a single-quoted string and trailing whitespace got Style/StringLiterals and Layout/TrailingWhitespace offences under this config. The file was deleted before committing.
  • Maintenance: the file is a hand-kept copy. It has to be regenerated when rubocop-rails-omakase is bumped in Gemfile.lock or .rubocop.yml changes, and its header says so.
  • Drift guard (8f674e3): test/architecture/codacy_rubocop_config_test.rb resolves both files with RuboCop's loader and compares each cop's on/off state and options, 781 entries in all. It fails when they disagree, and names the cop. Three deliberate breaks each failed it: a changed value in the flat file, a new override in .rubocop.yml, and a cop dropped from the flat file.