test(review): Expand boundary fixtures across all eight rules#117
Merged
Conversation
Cover false-positive boundaries on the drop / narrow side of the rule catalog so the golden suite exercises the "should NOT fire" path for each destructive rule: - `drop-column-referenced-fk-also-removed` — the FK column on the source side is dropped together with the referencing constraint, so `fk_is_removed` short-circuits the outgoing-FK check. - `drop-table-referenced-cascade` — the dropped table's incoming FK is removed in the same migration, exercising the `removed_fks` path built from `fk_diffs` removals. - `drop-pk-replaced-by-equivalent-pk` — the PRIMARY KEY is rebuilt under a different constraint name on the same column set, so `same_column_set` returns true and no PK-loss finding is emitted. - `type-narrow-equivalent-int4` — `INT` → `INTEGER` is a dialect alias with identical `int_rank`, so `detect_type_narrowing` returns None. All four fixtures expect an empty findings array, locking in the no-finding contract against future regressions.
Cover the "add"-side rules with new tables, default values, composite indexes, and the implicit-NO-ACTION → CASCADE transition so the golden suite locks down both the should-not-fire and should-fire paths: - `add-not-null-new-table-with-default` — NOT NULL columns with DEFAULT values on a brand-new table do not trigger `risk/add-not-null-on-existing` because `run_rules` only iterates `modified_tables`. - `add-unique-on-new-table` — a UNIQUE INDEX created together with a new table is similarly skipped by the modified-tables iteration. - `add-cascade-delete-from-noaction` — an existing FK gains `ON DELETE CASCADE` while the before side has no explicit `ON DELETE` clause, complementing the existing fixture which uses an explicit `NO ACTION`. Expects one warning finding. - `fk-with-composite-prefix-index` — a newly added FK on `(tenant_id)` is covered by a pre-existing composite index on `(tenant_id, created_at)`, so `column_list_has_prefix` returns true and `risk/fk-without-index` stays silent.
…iant
The parser maps both explicit `ON DELETE NO ACTION` and the absent
clause to `ReferentialAction::NoAction`, and the diff layer normalizes
that to `None` on `old_value.on_delete`. Under that contract the
`add-cascade-delete-from-noaction` fixture provided no additional
coverage over the existing `add-cascade-delete` fixture; only the
table and column names differed.
Use `ON DELETE SET NULL` → `ON DELETE CASCADE` instead so the modified
branch of `check_add_cascade_delete` sees an actual non-CASCADE
referential action on `old_value` (`Some("SET NULL")`) before the
upgrade. The rename keeps the fixture name aligned with the SQL it
ships.
Code Metrics Report
Details | | main (1aee9bd) | #117 (2382f5b) | +/- |
|---------------------|----------------|----------------|-------|
+ | Coverage | 94.6% | 94.6% | +0.0% |
| Files | 81 | 81 | 0 |
| Lines | 37324 | 37324 | 0 |
+ | Covered | 35334 | 35344 | +10 |
+ | Test Execution Time | 1m35s | 1m34s | -1s |Code coverage of files in pull request scope (92.2% → 92.8%)
Reported by octocov |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
fixtures/review/, one per review rule, to lock down the should-NOT-fire side of each rule plus a previously uncoveredSET NULL→CASCADEtransition.Some("SET NULL")rather than the parser-defaultNone.Changes
drop-column-referenced-fk-also-removed,drop-table-referenced-cascade,drop-pk-replaced-by-equivalent-pk, andtype-narrow-equivalent-int4to lock downfk_is_removed,removed_fks,same_column_set, andint_rankshort-circuits as zero-finding contracts.add-not-null-new-table-with-default,add-unique-on-new-table,add-cascade-delete-from-noaction, andfk-with-composite-prefix-indexto cover new-table iteration skip, default-bearing NOT NULL columns, the composite-index prefix match infk_columns_are_indexed, and the cascade-upgrade warning path.add-cascade-delete-from-set-nulland rewrite the before-sideON DELETEclause soold_value.on_delete = Some("SET NULL"), removing duplicate coverage with the existingadd-cascade-deletefixture (which the parser already normalizes from absent / explicit NO ACTION toNone).