Skip to content

Add TooManyMigrationRuns cop to test performance#4850

Open
johha wants to merge 2 commits intomainfrom
migration-cop
Open

Add TooManyMigrationRuns cop to test performance#4850
johha wants to merge 2 commits intomainfrom
migration-cop

Conversation

@johha
Copy link
Contributor

@johha johha commented Feb 16, 2026

Enforces max 4 migration runs per test file to prevent expensive repeated migrations. Detects subjects, let helpers, helper methods, and before/after blocks. Intentionally simple to avoid false positives on edge cases.

Also reduce number of migration calls in _add_state_to_stacks_spec to please Rubocop.

  • I have reviewed the contributing guide

  • I have viewed, signed, and submitted the Contributor License Agreement

  • I have made this pull request to the main branch

  • I have run all the unit tests using bundle exec rake

  • I have run CF Acceptance Tests

@johha johha force-pushed the migration-cop branch 4 times, most recently from 535949c to 90cc5e2 Compare February 17, 2026 12:45
@johha johha marked this pull request as ready for review March 5, 2026 13:10
Enforces max 4 migration runs per test file to prevent expensive repeated migrations.
Detects subjects, let helpers, helper methods, and before/after blocks.
Intentionally simple to avoid false positives on edge cases.

Also reduce number of migration calls in `_add_state_to_stacks_spec` to
please Rubbcop.
Disable cop for `bigint_migration_*_shared_context` & `drop_unique_constraint_quota_definitions_name_key_spec.rb`.
- Fix empty file handling (nil AST guard)
- Replace fragile string matching with AST-based detection
- Consolidate AST traversals into fewer passes
- Remove unused parameter and fix method naming
- Add comprehensive spec covering all detection patterns
@johha johha requested a review from philippthun March 12, 2026 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants