Upgrade gitlab-styles to 15.0.0 (RuboCop 1.92.1)
What does this MR do and why?
Upgrades gitlab-styles to 15.0.0, which brings RuboCop 1.92.1 and the latest RuboCop plugins. See the 15.0.0 release for its changes. It also sets RuboCop's TargetRubyVersion to 3.3, the minimum for GitLab 19.0 and for gitlab-styles 15.0.0.
The main reason for the upgrade: RuboCop 1.82.1+ computes its result-cache checksum before forking --parallel workers (https://github.com/rubocop/rubocop/commit/5245f3186). Without that, the weekly housekeeper:generate-rubocop-todos job misses every cached result and times out.
References
Changes in this MR
Gemfile,Gemfile.lock,Gemfile.next.lock:gitlab-styles~> 15.0, locked withbundle lock --conservative --updatefor gitlab-styles and the 9 RuboCop gems it brings in, so only those 10 gems change. Thesha256checksums match RubyGems..rubocop.yml:TargetRubyVersion3.2 → 3.3. RuboCop now parses with Prism.gems/config/rubocop.ymlstays at 3.2 until the gems move to gitlab-styles 15..rubocop.yml: excludeconfig/puma.rb, a local copy ofconfig/puma.rb.examplethat.gitignoreignores. Without it, local TODO regeneration adds entries that CI never sees.rubocop/cop/api/entity_field_type.rb:upcase_firstcapitalized the parsed string in place. Prism's strings are frozen, so the cop raisedFrozenErrorwhile correcting. It now returns a new string, and a spec example runs with Prism.ee/app/views/groups/saml_providers/_test_button.html.haml:= return unless …→- return unless …. Prism rejects outputtingreturn's value (Lint/Syntax: unexpected void value expression) in haml-lint's generated Ruby. The early return behaves the same; the view no longer writes a stray newline.config/initializers/wikicloth_ruby_3_patch.rb,.haml-lint.yml: gitlab-styles 15.0.0 removesCop/LineBreakAfterGuardClausesin favour of RuboCop'sLayout/EmptyLineAfterGuardClause(gitlab-org/ruby/gems/gitlab-styles!296 (merged)), so remove its disable comments and its haml-lintignored_copsentry, which RuboCop rejects as an unknown cop. The gems undergems/lint with their own lockfiles and the released gitlab-styles, so theirs stay..rubocop.yml: loadrubocop-rspecwithplugins:instead ofrequire:. rubocop-rspec 3.10 only loads its default config as a plugin.gems/config/rubocop.ymlkeepsrequire:, because each gem undergems/runs RuboCop with its own lockfile, and those pin rubocop-rspec versions without plugin support.spec/rubocop/formatter/graceful_formatter_spec.rb: the fake offense double getsdisabled?: false. RuboCop 1.92'sSimpleTextFormatter, whichGracefulFormatterextends, now calls it.spec/tasks/rubocop_rake_spec.rb: resetRuboCop::PathUtilaround eachtodo:generateexample. RuboCop 1.86 cachesDir.pwdfor the whole process (https://github.com/rubocop/rubocop/commit/9ce111d38), so every example after the first searched the previous, deleted temporary directory and wrote no TODOs.lib/tasks/rubocop.rake: thedocstask finds each cop's gem inGem.loaded_specsby install path, instead of matching the path with a regex. The regex only matched released gems such asgitlab-styles-14.1.0/, so with gitlab-styles from a git ref, as in this MR's dry run, its cops fell under anilkey and the task raisedTypeError.ee/app/views/projects/settings/merge_requests/_target_branch_rules_settings.html.haml:@target_branch_rules&.empty?→@target_branch_rules && @target_branch_rules.empty?, theLint/SafeNavigationWithEmptycorrection. It gives the same result when@target_branch_rulesisnil, as in view specs that render without the controller. The rake task only scans Ruby files, so a TODO entry here would have to be added by hand.ee/spec/lib/security/secret_detection/partner_tokens/generator/client_generator_spec.rb: the strings that assert a literal#{}in generated source are now%(…\#{…}…), with the same values.Lint/InterpolationCheckflags 3 more of them, and a TODO entry for the file would make its existing inline disable redundant, which the rake task can't see. The inline disable is removed..rubocop_todo/(separate commit): regenerated withbundle exec rake rubocop:todo:generateon top of master, with the Ruby 3.3 target, and not edited by hand. 37 new TODO files, 11 grown and 10 shrunk. All new and grown lists are in the grace period.Cop/AvoidReturnFromBlocks,RSpec/ExampleStartingCharacterandRSpec/EmptyLineAfterSharedExample, which now also check_1anditblocks, found no new offenses.
TODO generation time
The same full rake rubocop:todo:generate run locally (14 cores): 53 minutes with RuboCop 1.81.7 and about 9 minutes with RuboCop 1.92.1. With 1.81.7, the parent process's cache key differs from the parallel workers', so the serial pass re-inspects every file on one core. The scheduled housekeeper:generate-rubocop-todos job showed 0 hits / 54,478 misses. RuboCop 1.82.1+ computes the checksum before forking (https://github.com/rubocop/rubocop/commit/5245f3186).
Cops with new TODO files
All are in the grace period. Links go to the cop's page on docs.rubocop.org, or to its source at the version used when it has no docs page.
Cops that start running with this upgrade (12)
Existing cops with new offenses (25)
Checklist
- Verify upcoming release of
gitlab-styles- Point to "Release" MR of
gitlab-stylesinGemfile -
rubocopjob- Inspect any warnings/errors
- (Optional) Generate TODOs for pending offenses
- Put
🆕 cop rules (or if configuration is changed) in "grace period" - (Optional) Remove any offenses for disabled cops
- Put
- (Optional) Autocorrect offenses (only if the changeset is small)
- Compare the total runtime of
rubocop --parallelscan with previous runs
- Make sure CI passes and does not have "silenced offenses"
💚 - Don't merge this MR yet!
- Wait for
gitlab-stylesto be released
- Point to "Release" MR of
- Upgrade released version of
gitlab-styles- Make sure release is complete
- Rephrase the title and MR description to match final upgrade
- Point to released version in
Gemfile - (Optional) Regenerate TODOs for new/changed cop rules
- Make sure CI passes and does not have "silenced offenses"
💚 - Let the MR being reviewed again and merged
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist.
After merge
- Notify team members of the upgrade by creating an announcement in relevant Slack channels (
#backendand#development) and Engineering Week In Review (EWIR).