Skip to content

fix(PC0030): suppress on setup table parameterless Get()#286

Merged
Arthurvdv merged 3 commits into
release/v0.8.3from
fix/pc0030-suppress-setup-tables
May 18, 2026
Merged

fix(PC0030): suppress on setup table parameterless Get()#286
Arthurvdv merged 3 commits into
release/v0.8.3from
fix/pc0030-suppress-setup-tables

Conversation

@Arthurvdv
Copy link
Copy Markdown
Member

Summary

Suppresses PC0030 when a parameterless Get() is called on a setup table. Setup tables (single-record configuration tables) gain near-zero benefit from SetLoadFields.

Changes

  • New shared helper: ALCops.Common/Helpers/TableHelper.IsSetupTable() with relaxed heuristic (single Code PK field named "Primary Key" or "PrimaryKey", case-insensitive)
  • PC0030 suppression: Only when Get() has zero arguments AND the table matches the setup table heuristic
  • AC0013 refactor: Now uses shared TableHelper.IsSetupTable() instead of private method
  • Tests: 4 new test cases (2 NoDiagnostic: SetupTableGet, SetupTableGetNoSpace; 2 HasDiagnostic: SetupTableGetWithArgs, SetupTableFindFirst)

Rationale

  • Microsoft's BaseApp uses SetLoadFields on setup tables in only 1.8% of cases (~54 out of ~2,977)
  • keytogoodcode.com SQL analysis proves near-zero benefit for single-record cached tables
  • alguidelines.dev refactoring guide shows SalesSetup.Get() without SetLoadFields as the correct pattern

Closes #283

Setup tables (single-record configuration tables like General Ledger Setup,
Sales & Receivables Setup, etc.) gain near-zero benefit from SetLoadFields.
Microsoft's BaseApp uses SetLoadFields on setup tables in only 1.8% of cases.

Changes:
- Add shared TableHelper.IsSetupTable() in ALCops.Common with relaxed heuristic
  (single Code PK field named "Primary Key" or "PrimaryKey", case-insensitive)
- Suppress PC0030 when Get() has no arguments AND table is a setup table
- Refactor AC0013 (FieldGroupsRequired) to use shared helper
- Add 4 new test cases (2 NoDiagnostic, 2 HasDiagnostic)
- Update existing test fixtures to use non-setup-table PK names

Closes #283

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Arthurvdv and others added 2 commits May 18, 2026 18:56
The unqualified field reference format from PR #284 was not properly
applied during the merge conflict resolution.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Arthurvdv Arthurvdv merged commit 9dc9ead into release/v0.8.3 May 18, 2026
43 checks passed
@Arthurvdv Arthurvdv deleted the fix/pc0030-suppress-setup-tables branch May 18, 2026 17:54
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.

1 participant