.vbw-planning/milestones/03-coverage-analysis-quick-wins-critical-path-test-co/phases/01-coverage-analysis-quick-wins/PLAN-02.md
Audit the entire codebase with RuboCop using the rubocop-rails-omakase configuration and fix all violations, achieving zero offenses. This satisfies REQ-14 and ensures the CI lint job passes cleanly.
Decomposition rationale: This plan depends on Plan 01 because Style/FrozenStringLiteralComment is typically the most voluminous cop violation. By completing Plan 01 first, this plan deals with a much smaller and more varied set of violations that require more careful, contextual fixes.
Current state:
rubocop-rails-omakase as its base ruleset (inherits the gem's rubocop.yml)test/dummy/db/schema.rbStyle/FrozenStringLiteralComment violations will be resolvedStyle/StringLiterals (single vs double quotes)Layout/* (indentation, spacing, line length)Metrics/* (method/class length -- may need exclusions for large files targeted in Phase 3)Naming/* (variable/method naming conventions)Rails/* cops from the omakase setMetrics/ClassLength or Metrics/MethodLength -- these should be addressed with targeted .rubocop.yml exclusions since Phase 3 handles the actual refactoringConstraints:
rubocop -a for safe corrections, -A for aggressive only when reviewed).rubocop.yml with a comment referencing Phase 3test/dummy/db/schema.rb exclusion must remain (Rails-generated)test/tmp/ are not git-tracked and not subject to RuboCop
</context>
bin/rubocop -f json -o tmp/rubocop_report.json and bin/rubocop -f simple to get a complete picture of all violations. Categorize them by: (a) auto-correctable with -a (safe), (b) auto-correctable with -A (unsafe, needs review), (c) manual fix required, (d) should be excluded (Metrics cops on large files destined for Phase 3 refactoring). Document the count and category of each cop violation type.bin/rubocop -a to apply all safe auto-corrections across the codebase. This handles cops like Style/StringLiterals, Layout/TrailingWhitespace, Layout/EmptyLineAfterMagicComment, Layout/SpaceInsideBlockBraces, etc. Review the diff to confirm no behavioral changes -- only formatting/style changes. If any auto-correction looks wrong, revert that specific change and handle it manually in Task 3.git diff --stat to see scope of changes. Run bin/rails test to confirm no test regressions. Run bin/rubocop -f simple to see remaining violations after safe auto-correct.Rails/HttpPositionalArguments)# rubocop:disable comment with an explanationbin/rubocop -f simple after each batch of fixes. The violation count should decrease monotonically. Run bin/rails test after all manual fixes..rubocop.ymlMetrics/ClassLength, Metrics/MethodLength, or Metrics/BlockLength violations remain for the three large files targeted for refactoring in Phase 3, add targeted exclusions to .rubocop.yml:
# Phase 3 refactoring targets -- remove exclusions after extraction
Metrics/ClassLength:
Exclude:
- "lib/source_monitor/fetching/feed_fetcher.rb"
- "lib/source_monitor/configuration.rb"
- "app/controllers/source_monitor/import_sessions_controller.rb"
bin/rubocop and confirm it exits 0 with zero offenses. The exclusions should only cover the Phase 3 target files..rubocop.yml has targeted, documented exclusions. Zero RuboCop offenses across the entire codebase.bin/rubocop -f simple -- must show no offenses detected. (2) bin/rubocop -f github -- must exit 0 (this is what CI runs). (3) bin/rails test -- full test suite must pass. (4) Verify the coverage baseline has not grown (run wc -l config/coverage_baseline.json and confirm it is still approximately 2328 lines -- style changes should not affect coverage).bin/rubocop exits 0bin/rubocop -f github exits 0bin/rails test exits 0bin/rubocop -f simple outputs no offenses detectedbin/rubocop -f github exits 0 (CI lint format)bin/rails test exits 0 with no regressionsconfig/coverage_baseline.json) has not grown in line count.rubocop.yml exclusions are limited to Phase 3 target files with documenting commentsbin/rubocop -f github) passesPhase 1 success criterion #3 ("Coverage baseline shrinks by at least 10%") is not directly addressed by Plans 01 or 02, which focus on code quality (REQ-13, REQ-14). The coverage baseline may shrink slightly if RuboCop fixes remove dead branches or simplify code paths. After Plan 02 completes, regenerate the baseline with bin/update-coverage-baseline and measure the delta. The 10% reduction target (from 2328 uncovered lines to ~2095 or fewer) will primarily be achieved in Phase 2 when dedicated test coverage plans execute.