Skip to content

Pay down the RuboCop baseline recorded in .rubocop_todo.yml #155

Description

@marcosdemelo

Context

#151 introduces RuboCop with a .rubocop_todo.yml baseline that records the offenses existing in the codebase at that point. CI blocks new offenses, but the baseline itself carries technical debt that should be paid down incrementally.

Numbers below were extracted from the .rubocop_todo.yml generated in #151 (RuboCop 1.75.8).

Total: 721 offenses across 59 cops.

Department Cops Offenses
Style 22 416
RSpec 16 258
Layout 6 15
Gemspec 3 11
Metrics 3 9
Lint 3 6
Performance 3 3
Naming 2 2
Security 1 1

Suggested approach

Work in small PRs, one category (or one cop) at a time. Each PR removes the corresponding entries from .rubocop_todo.yml so CI enforces the cop from then on. Regenerating the whole file with --auto-gen-config should be avoided, since it hides which cops were actually fixed.

Phase 1 — Safe autocorrections (411 offenses, 41 cops)

Mechanical, low risk. bundle exec rubocop --autocorrect --only <Cop> plus a spec run is enough. Largest ones:

Cop Offenses
Style/StringLiterals 306
Style/AccessorGrouping 40
Style/NumericLiterals 8
RSpec/ClassCheck 7
Style/HashSyntax 5
Layout/SpaceAfterComma 4
Layout/EmptyLineAfterGuardClause 3
Lint/AmbiguousOperator 3
remaining 33 cops 1–2 each

Phase 2 — Unsafe autocorrections (68 offenses, 9 cops)

Autocorrectable with --autocorrect-all, but each change needs a human look because semantics can shift.

Cop Offenses Note
RSpec/BeEql 34 eq → be for booleans/nil/numbers. Behavior-neutral in practice.
Style/FrozenStringLiteralComment 25 Adds the magic comment to every file. Needs a full spec run because it can surface string mutation.
Style/MutableConstant 2 Freeze constants in parser/ofx211.rb and version.rb.
Style/NumericPredicate 2
RSpec/DescribedClass 1
Performance/InefficientHashSearch 1
Style/SpecialGlobalVars 1
Style/StringConcatenation 1
Style/ZeroLengthPredicate 1

Phase 3 — Spec structure (manual, 213 offenses, 9 cops)

Requires rewriting spec setup, mostly @ivar in before blocks → let/subject. Best done file by file.

Cop Offenses
RSpec/InstanceVariable 155
RSpec/MultipleExpectations 21
RSpec/ContextWording 20
RSpec/MessageSpies 4
RSpec/StubbedMock 4
RSpec/SpecFilePathFormat 3
RSpec/NestedGroups 2
RSpec/ExampleLength 1

Phase 4 — Code design (manual, 19 offenses, 8 cops)

Each one is a small design decision in lib/.

Cop Offenses Where
Style/Documentation 9 Every class in lib/ofx/ lacks a top-level comment.
Metrics/MethodLength 6 Parsers.
Metrics/AbcSize 2 Parsers.
Lint/IneffectiveAccessModifier 2 parser/ofx211.rb, private before def self. methods.
Metrics/ClassLength 1 parser/ofx102.rb.
Naming/MethodName 1 lib/ofx.rb, the OFX() helper. Likely keep as is and allow it explicitly.
Naming/MethodParameterName 1 parser/ofx211.rb.
Security/Open 1 lib/ofx/parser.rb uses open. Worth a look on its own since it accepts user-provided paths.

Phase 5 — Gemspec (10 offenses, 2 cops)

Cop Offenses Note
Gemspec/DevelopmentDependencies 9 Move add_development_dependency entries to the Gemfile.
Gemspec/RequireMFA 1 Add rubygems_mfa_required metadata. Depends on the release process.

Definition of done

.rubocop_todo.yml is empty (or removed) and bundle exec rubocop passes on main with no exclusions.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions