Resolve auto-correctable RuboCop offenses (Exclude-only) in .rubocop_todo/**/*.yml

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

  • Collaborate/take over this issue

❗ COMMUNITY CONTRIBUTORS, PLEASE ONLY PICKUP ONE COP VIOLATION TO ALLOW OTHER NEW CONTRIBUTORS TO LEARN FROM THESE TOO ❗

Problem

.rubocop_todo/**/*.yml contains auto-correctable (RuboCop) offenses (grep -hr auto-correct .rubocop_todo -A 1 | grep "^[A-Z]") which can be fixed automatically.

Implementation guide

Resolve auto-correctable rules which are enabled by letting RuboCop auto-correct them automatically 🎉

  1. Verify that the you are working on is already enabled. See also #369268 (closed)
  2. Pick a offense from The List below e.g. Layout/ClosingHeredocIndentation
  3. Create a branch (e.g. 239356-abc/fix-Layout/ClosingHeredocIndentation)
    • Info: Using this issue ID (239356) in a branch name will add required labels and reference to this issue in the new merge request.
    • Info: Using your username or initials (e.g. abc/ above) in the branch name will help to prevent branch naming clashes with other contributors also working on this issue.
  4. Delete the rule from the corresponding .rubocop_todo/ YAML file (for example https://gitlab.com/gitlab-org/gitlab/-/blob/fdeea9247566ca45fece68605a838ebc659b62db/.rubocop_todo/gitlab/rails/safe_format.yml)
  5. Auto-correct RuboCop offenses via e.g. bundle exec rubocop --autocorrect --only Layout/ClosingHeredocIndentation
  6. Check changed files and adjust if needed
    • Suggestion: In order to keep MRs short one can fix 10-15 files in one go. Depending on the amount of changes in the file.
  7. Commit and create a merge request
    • Hint: You can use Fix <Cop/Name> offenses as git commit message
    • Info: Community contributions can use git trailer Changelog: other so they are attributed in CHANGELOG.md
  8. Mention this merge request in this issue
  9. 🎉

The List

📣 A list containing all auto-correctable offenses

  • FactoryBot/CreateList (0 entries) Chart
  • Gemspec/DeprecatedAttributeAssignment (0 entries) Chart
  • Gitlab/DocumentationLinks/Link (0 entries) Chart
  • Gitlab/FeatureFlagKeyDynamic (31 entries) Chart
  • Gitlab/Rails/AttrEncrypted (54 entries) Chart
  • Gitlab/Rails/SafeFormat (6 entries) Chart
  • Gitlab/StrongMemoizeAttr (554 entries) Chart
  • GraphQL/FieldDefinitions (0 entries) Chart
  • GraphQL/FieldHashKey (0 entries) Chart
  • GraphQL/FieldMethod (0 entries) Chart
  • GraphQL/OrderedFields (0 entries) Chart
  • GraphQL/UnnecessaryFieldAlias (0 entries) Chart
  • GraphQL/UnusedArgument (0 entries) Chart
  • Graphql/Descriptions (0 entries) Chart
  • Graphql/ResourceNotAvailableError (9 entries) Chart
  • InternalAffairs/CopDescriptionWithExample (155 entries) Chart
  • InternalAffairs/ExampleHeredocDelimiter (57 entries) Chart
  • InternalAffairs/LocationExpression (21 entries) Chart
  • InternalAffairs/NodeMatcherDirective (89 entries) Chart
  • InternalAffairs/NodeTypeMultiplePredicates (5 entries) Chart
  • InternalAffairs/NodeTypePredicate (16 entries) Chart
  • InternalAffairs/RedundantExpectOffenseArguments (2 entries) Chart
  • InternalAffairs/RedundantMessageArgument (14 entries) Chart
  • InternalAffairs/RedundantSourceRange (10 entries) Chart
  • Layout/ArgumentAlignment (0 entries) Chart
  • Layout/ArrayAlignment (195 entries) Chart
  • Layout/ClassStructure (429 entries) Chart
  • Layout/ClosingParenthesisIndentation (0 entries) Chart
  • Layout/EmptyLineAfterMagicComment (593 entries) Chart
  • Layout/EmptyLinesAroundMethodBody (23 entries) Chart
  • Layout/ExtraSpacing (0 entries) Chart
  • Layout/FirstArgumentIndentation (0 entries) Chart
  • Layout/FirstArrayElementIndentation (0 entries) Chart
  • Layout/FirstHashElementIndentation (0 entries) Chart
  • Layout/HashAlignment (0 entries) Chart
  • Layout/LeadingCommentSpace (0 entries) Chart
  • Layout/LeadingEmptyLines (0 entries) Chart
  • Layout/LineBreakAfterFinalMixin (32 entries) Chart
  • Layout/LineContinuationLeadingSpace (0 entries) Chart
  • Layout/LineContinuationSpacing (149 entries) Chart
  • Layout/LineEndStringConcatenationIndentation (603 entries) Chart
  • Layout/LineLength (4176 entries) Chart
  • Layout/MultilineOperationIndentation (0 entries) Chart
  • Layout/ParameterAlignment (0 entries) Chart
  • Layout/SpaceBeforeBlockBraces (0 entries) Chart
  • Layout/SpaceInLambdaLiteral (0 entries) Chart
  • Layout/SpaceInsideBlockBraces (0 entries) Chart
  • Layout/SpaceInsideParens (0 entries) Chart
  • Layout/SpaceInsidePercentLiteralDelimiters (0 entries) Chart
  • Layout/TrailingEmptyLines (0 entries) Chart
  • Layout/TrailingWhitespace (1 entries) Chart
  • Lint/AmbiguousOperatorPrecedence (0 entries) Chart
  • Lint/AmbiguousRange (0 entries) Chart
  • Lint/AmbiguousRegexpLiteral (0 entries) Chart
  • Lint/AssignmentInCondition (209 entries) Chart
  • Lint/DeprecatedConstants (0 entries) Chart
  • Lint/DuplicateRegexpCharacterClassElement (0 entries) Chart
  • Lint/ImplicitStringConcatenation (0 entries) Chart
  • Lint/IncompatibleIoSelectWithFiberScheduler (0 entries) Chart
  • Lint/NonAtomicFileOperation (0 entries) Chart
  • Lint/OrAssignmentToConstant (0 entries) Chart
  • Lint/RedundantCopDisableDirective (0 entries) Chart
  • Lint/RedundantDirGlobSort (0 entries) Chart
  • Lint/RedundantSafeNavigation (0 entries) Chart
  • Lint/RedundantStringCoercion (0 entries) Chart
  • Lint/SafeNavigationConsistency (0 entries) Chart
  • Lint/SymbolConversion (84 entries) Chart
  • Lint/UnusedBlockArgument (354 entries) Chart
  • Lint/UnusedMethodArgument (515 entries) Chart
  • Lint/UselessAssignment (0 entries) Chart
  • Lint/UselessNumericOperation (0 entries) Chart
  • Lint/Void (1 entries) Chart
  • Naming/HeredocDelimiterCase (0 entries) Chart
  • Naming/InclusiveLanguage (51 entries) Chart
  • Performance/FlatMap (0 entries) Chart
  • Performance/MapCompact (100 entries) Chart
  • Performance/RegexpMatch (0 entries) Chart
  • Performance/StringIdentifierArgument (212 entries) Chart
  • Performance/StringInclude (0 entries) Chart
  • Performance/StringReplacement (0 entries) Chart
  • RSpec/AnyInstanceOf (317 entries) Chart
  • RSpec/BeEmpty (0 entries) Chart
  • RSpec/BeEq (1474 entries) Chart
  • RSpec/BeNil (0 entries) Chart
  • RSpec/BeforeAll (0 entries) Chart
  • RSpec/ChangeByZero (39 entries) Chart
  • RSpec/ContainExactly (195 entries) Chart
  • RSpec/DescribedClass (0 entries) Chart
  • RSpec/Dialect (33 entries) Chart
  • RSpec/EmptyLineAfterHook (0 entries) Chart
  • RSpec/EnvMocking (0 entries) Chart
  • RSpec/Eq (0 entries) Chart
  • RSpec/ExampleWording (67 entries) Chart
  • RSpec/ExcessiveDocstringSpacing (78 entries) Chart
  • RSpec/ExpectChange (322 entries) Chart
  • RSpec/HooksBeforeExamples (0 entries) Chart
  • RSpec/IsExpectedSpecify (0 entries) Chart
  • RSpec/MetadataStyle (0 entries) Chart
  • RSpec/ReceiveMessages (556 entries) Chart
  • RSpec/RedundantAround (0 entries) Chart
  • RSpec/RedundantPredicateMatcher (13 entries) Chart
  • RSpec/ReturnFromStub (184 entries) Chart
  • RSpec/ScatteredLet (213 entries) Chart
  • RSpec/SpecifyExpected (10 entries) Chart
  • RSpec/VerifiedDoubleReference (242 entries) Chart
  • Rails/Date (212 entries) Chart
  • Rails/EnumHash (0 entries) Chart
  • Rails/EnumSyntax (0 entries) Chart
  • Rails/FilePath (106 entries) Chart
  • Rails/FindEach (17 entries) Chart
  • Rails/NegateInclude (0 entries) Chart
  • Rails/Pluck (236 entries) Chart
  • Rails/PluralizationGrammar (0 entries) Chart
  • Rails/RedundantForeignKey (49 entries) Chart
  • Rails/StrongParams (290 entries) Chart
  • Rails/TimeZone (72 entries) Chart
  • Rails/WhereRange (78 entries) Chart
  • Style/AccessorGrouping (59 entries) Chart
  • Style/ArgumentsForwarding (4 entries) Chart
  • Style/BlockDelimiters (42 entries) Chart
  • Style/ClassAndModuleChildren (490 entries) Chart
  • Style/CombinableLoops (0 entries) Chart
  • Style/EmptyElse (18 entries) Chart
  • Style/EmptyLiteral (0 entries) Chart
  • Style/EmptyMethod (0 entries) Chart
  • Style/EndlessMethod (26 entries) Chart
  • Style/ExplicitBlockArgument (0 entries) Chart
  • Style/FloatDivision (0 entries) Chart
  • Style/FormatString (201 entries) Chart
  • Style/FrozenStringLiteralComment (0 entries) Chart
  • Style/GuardClause (492 entries) Chart
  • Style/HashAsLastArrayItem (0 entries) Chart
  • Style/HashEachMethods (120 entries) Chart
  • Style/IfUnlessModifier (728 entries) Chart
  • Style/Iso8601Date (0 entries) Chart
  • Style/KeywordParametersOrder (0 entries) - !148567 (merged) Chart
  • Style/Lambda (0 entries) Chart
  • Style/MapIntoArray (16 entries) Chart
  • Style/MutableConstant (29 entries) Chart
  • Style/NumericLiteralPrefix (48 entries) Chart
  • Style/RedundantInterpolation (0 entries) Chart
  • Style/RedundantInterpolationUnfreeze (0 entries) Chart
  • Style/RedundantParentheses (31 entries) Chart
  • Style/RedundantRegexpEscape (39 entries) Chart
  • Style/RedundantReturn (43 entries) Chart
  • Style/RedundantSelf (321 entries) Chart
  • Style/SelfAssignment (0 entries) Chart
  • Style/SendWithLiteralMethodName (0 entries) Chart
  • Style/SingleArgumentDig (0 entries) Chart
  • Style/SoleNestedConditional (37 entries) Chart
  • Style/StringConcatenation (232 entries) Chart
  • Style/StringLiteralsInInterpolation (0 entries) Chart
  • Style/SuperArguments (170 entries) Chart
  • Style/SymbolProc (170 entries) Chart

How to regenerate the list?

  1. Copy+paste the Script from below 👇 as save as regenerate.rb
  2. Copy the The List from above ☝️ in Markdown format
  3. Run regenerate.rb
  4. Paste the copied list from above ☝️ and terminate input with Ctrl-D
  5. Copy+paste the newly generated list in the The List section

Script

script
#!/usr/bin/env ruby
# frozen_string_literal: true

# From https://gitlab.com/gitlab-org/gitlab/-/issues/239356#the-list

require "yaml"

BURNDOWN_CHART_URL = "https://ck3g.gitlab.io/rubocop-burndown/"

sha = `git rev-parse HEAD`.chomp

template = <<~MD
- [ ] [`%{rule_name}`](https://gitlab.com/gitlab-org/gitlab/-/blob/#{sha}/%{path}) (%{entries} entries) [Chart](#{BURNDOWN_CHART_URL}#%{rule_name})
MD

warn "Paste the markdown bullet point list from https://gitlab.com/gitlab-org/gitlab/-/issues/239356: (Terminate with Ctrl-D)"
current = $stdin.readlines.to_h { |line| [line[/`(\S+)`/, 1], line] } # rubocop:disable Rails/IndexBy
puts "Received #{current.keys.count} lines\n\n"

todos = Dir.glob(".rubocop_todo/**/*.yml").to_h do |path|
  next [nil, []] unless /^# Cop supports --auto-?correct/.match?(File.read(path))

  yaml = YAML.safe_load_file(path)
  name, config = yaml.first
  entries = config.fetch('Exclude', []) || []
  [name, [path, entries.size]]
end

todos.delete(nil)

(current.keys | todos.keys).uniq.sort.each do |name|
  path, entries = todos[name]
  current_line = current[name]

  if current_line && !path
    current_line.sub!('- [ ]', '- [x]')
    current_line.sub!(/\d+ entries/, '0 entries')
    current_line.chomp!
    current_line += " [Chart](#{BURNDOWN_CHART_URL}##{name})"
    puts current_line
  elsif path
    puts format(template, rule_name: name, path: path, entries: entries)
  end
end
Edited Feb 13, 2026 by 🤖 GitLab Bot 🤖
Assignee Loading
Time tracking Loading