Skip to content

fix(AC0002): skip setup tables whose primary key is always blank - #579

Merged
Arthurvdv merged 5 commits into
mainfrom
fix/ac0002-setup-table-primary-key
Oct 8, 2026
Merged

Arthurvdv merged 5 commits into
mainfrom
fix/ac0002-setup-table-primary-key

Conversation

@Arthurvdv

Copy link
Copy Markdown
Member

Fixes #575

Summary

AC0002 (NotBlankRequiredOnPrimaryKeyField) no longer reports setup tables. A setup table holds one record, and its primary key is always blank by design. Setup tables are assumed to be singletons that no other table relates to, so the cascading rename/delete the rule guards against does not apply.

  • NotBlankOnPrimaryKeyField: one early return in the AC0002 branch, which reuses the shared TableHelper.IsSetupTable (also used by AC0013). It matches a sole Code primary key field named Primary Key/PrimaryKey, or a parameterless, return-less GetRecordOnce method on the table. The helper already compiles on netstandard2.1, so no TFM guards are needed.
  • AC0003 (the No. Series branch of the same analyzer) is unchanged.
  • Tests: three new NoDiagnostic fixtures (SetupTablePrimaryKey, SetupTablePrimaryKeyNoSpace, SetupTableGetRecordOnce), observed failing before the fix. A HasDiagnostic/PrimaryKeyTextField regression guard pins the Code-only scope.
  • New rule doc .claude/rules/diagnostics/ac0002-not-blank-required-on-primary-key-field.md. The AC0013 doc notes that it shares the heuristic.

Deliberate scope limits

The heuristic matches by convention, not by checking inbound relations. These cases still report AC0002:

  • a Text "Primary Key" field (the helper is Code-only);
  • a singleton keyed by PK or Code without a GetRecordOnce method.

Widening the heuristic would also change AC0013. An explicit NotBlank = false remains the opt-out.

CodeFix rename

No behaviour change. In NotBlankRequiredOnPrimaryKeyFieldCodeFixProvider, GetBooleanFalsePropertyValue and GetNotBlankFalseProperty actually produced NotBlank = true. They are renamed to GetBooleanTruePropertyValue and GetNotBlankTrueProperty, and updatedNotBlankProperty now has correct casing.

Verification

  • dotnet build ALCops.sln and dotnet test ALCops.sln: all green.
  • dotnet format ALCops.sln --verify-no-changes: clean.
  • ApplicationCop CI-TFM build (netstandard2.1, net8.0, net10.0): 0 warnings, 0 errors.
  • Validate-Rules.ps1: OK.
  • Code review (/code-review, Sonnet, effort high): no correctness issues; review nits addressed in chore(AC0002): tighten setup-table wording from review.

Docs: ALCops/alcops.dev#199

🤖 Generated with Claude Code

Arthurvdv and others added 5 commits October 7, 2026 21:30
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Arthurvdv
Arthurvdv merged commit 998bc5f into main Oct 8, 2026
44 checks passed
@Arthurvdv
Arthurvdv deleted the fix/ac0002-setup-table-primary-key branch October 8, 2026 05:32
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.

[Bug]: AC0002 in setup tables

1 participant