fix(PC0030): stop suggesting SetLoadFields on setup and reference tables - #543
Merged
Merged
Conversation
Partial records bypass the NST record cache: a full-record read that repeats identically is served from memory, while the same read with SetLoadFields goes back to SQL every time. On tables whose few rows are always cached - setup singletons, posting groups and other lookup data - the suggestion therefore makes code slower, not faster. TableHelper.IsSetupOrReferenceTable recognizes that class structurally: the existing setup-table heuristic, a namespace ending in ".Setup", or a single Code-type primary key named "Code" or "Name", vetoed when the primary key is AutoIncrement. PC0030 no longer reports any read on such a table; until now only a parameterless Get() on a setup table was excluded. IsSetupTable keeps its narrow meaning for AC0013. Fixtures that used a "Primary Key" PK by habit are re-keyed to "No." so they keep testing the suppression they are named after. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…efs and any AutoIncrement key field A RecordRef linked to a setup or reference record via SetTable now inherits that record's suppression, so the same read is judged the same way through either receiver. The AutoIncrement veto inspects every primary-key field, not only the first, so a compound "Code, Entry No." key on a growing table in a Setup namespace no longer slips through. TableHelper shares one single-Code-PK predicate between IsSetupTable and IsSetupOrReferenceTable, evaluates the cheap primary-key check before the namespace and member lookups, and describes the shapes it matches without rule-specific rationale. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…0 recognizer Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
Fixes #531.
Why
Partial records bypass the NST record cache. A full-record read that repeats identically is served from memory with one SQL statement; the same read with
SetLoadFieldsre-queries SQL every time (Duilio Tacconi measured ~10,000 identical statements where the cached read produced one - Partial record vs NST caching; the same effect surfaced in #297). On tables whose few rows are always cached - setup singletons, posting groups and other lookup data - PC0030 was recommending something that makes code slower.Whether a read repeats is a data property the analyzer cannot see, so the fix does not try to predict performance. It recognizes the table class where the cache is essentially always hot and stays silent there; master data, documents and ledgers are unchanged.
What
TableHelper.IsSetupOrReferenceTable(Common): the existing setup-table heuristic, or a namespace ending in.Setup, or a singleCode-type primary key namedCodeorName; vetoed when the primary key isAutoIncrement(growing tables that live in a Setup namespace). Structural signals only - no table-name matching, no field counts - so it behaves the same for Microsoft, partner and localized apps.IsSetupTablekeeps its narrow meaning for AC0013.Get()on a setup table was excluded;Get('CODE'),FindFirstandFindSetstill fired."Primary Key"PK by habit and would have flipped silently; they are re-keyed to"No."so each keeps testing the suppression it is named after.SetupTableGetWithArgsandSetupTableFindFirstmove toNoDiagnostic; nine new fixtures cover each signal and each veto (.Setupnamespace with compound PK,.Setupas a non-final segment,AutoIncrementPK, Integer PK namedCode, PKCode/Name).Evidence (Base App w1-28.4, 1,527 tables)
CodePK namedCodeCodePK namedNamePrimary Key/GetRecordOnce.SetupAutoIncrementveto removes two of its false positives (Payment Reporting Argument,Adv. Bonus Depreciation Setup);Close Income Statement Buffer,Inventory Period EntryandWarehouse Employeeremain accepted missesCodePK namedNo.Field count was rejected as a signal (General Ledger Setup has 114 fields and one row). Known misses: compound-PK reference tables outside
.Setup(Inventory Posting Setup,Dimension Value) still report.Companion docs PR: ALCops/alcops.dev#183
Verification
dotnet test ALCops.sln: 1,191 passed, 0 failed (PC0030 87/87, PC0031 31/31, AC0013 8/8); the newNoDiagnosticfixtures failed before the analyzer change.dotnet format --verify-no-changesclean; Common and PlatformCop built fornetstandard2.1;net8.0;net10.0withContinuousIntegrationBuild=true;Validate-Rules.ps1OK.🤖 Generated with Claude Code