Ruleset hardening: promote five low-risk rules to Error - #10878
Ruleset hardening: promote five low-risk rules to Error#10878Jesper Schulz-Wedde (JesperSchulz) merged 9 commits into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Promote AL0523, AA0242, AA0224, and AW0007 to Error with tightly scoped suppressions for accepted existing behavior. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a50e6515-9906-448a-a23b-2be37c212338
Apply the AA0242 and AA0224 suppressions to the localized layer copies required by MicroSnapApp propagation. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a50e6515-9906-448a-a23b-2be37c212338
Replace all 11 AA0242 suppressions with the actual partial-record fix by adding the accessed fields to the preceding SetLoadFields call: - ItemJnlPostLine (W1, APAC, CH, ES, IT, RU): add "Item No." to the ReservEntry2 load set used by ItemRec.Get(ReservEntry2."Item No."). - ReleaseTransferDocument (W1, IT): add "Unit of Measure Code" to the TransLine load set read inside the FindSet loop. - ProductionOrder.Table: add Description and "Description 2" to the ItemVariant load set. - NetCustVendBalancesMgt: add "Applies-to Doc. Type" and "Applies-to Doc. No." to the GenJournalLine load set. Adding fields to SetLoadFields is behavior-neutral and removes the just-in-time field loads the analyzer flagged, so no suppression is needed. Also reword the AL0254 comment on the NL Docket report: the generic 'shared-table key' justification is inaccurate there, since Cust./Vendor Ledger Entry already carry an equivalent key and Employee Ledger Entry does not. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Predrag Maricic (PredragMaricic)
left a comment
There was a problem hiding this comment.
S1 - Blocking: In PostedDepositSubform.Page.al, the Account Card and Account Ledger Entries actions call page procedures that call themselves unconditionally. The source table already exposes the intended methods, and the neighboring wrapper demonstrates the correct delegation with Rec.ShowDimensions(). Retaining the page API for compatibility does not require retaining recursion. Change the bodies to Rec.ShowAccountCard() and Rec.ShowAccountLedgerEntries(), then keep the narrowly justified AL0523 suppression if the duplicate public wrappers must remain.
S2 - Blocking: The AA0224 comments say the mismatches intentionally preserve request-page choices, but concrete omitted values are reachable. Customer Labels implements the fifth barcode format throughout the dataset yet omits its caption, and IC Inbox handles Cancel in OnValidate while omitting the Cancel caption. Promoting AA0224 and suppressing these sites removes the existing warning while leaving blank or misaligned UI options. Add captions for reachable values, or expose a separate option type containing only intended request-page values; suppress only cases that are genuinely intentional and explain why.
Fix recursive page wrappers, correct option models and captions, and add the Employee Ledger Entry sorting key so the associated suppressions can be removed. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a50e6515-9906-448a-a23b-2be37c212338
Bind prepayment request pages to a two-value option while preserving the existing internal processing option and InitializeRequest behavior. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a50e6515-9906-448a-a23b-2be37c212338
|
Predrag Maricic (@PredragMaricic) Addressed the final request-page concern in |
Keep Statistic initialization internal, synchronize persisted visible request values before execution, and remove stale employee-ledger sorting suppressions. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a50e6515-9906-448a-a23b-2be37c212338
|
Predrag Maricic (@PredragMaricic) Follow-up |
Predrag Maricic (PredragMaricic)
left a comment
There was a problem hiding this comment.
The prior blocking findings are addressed in the current head: the posted-deposit wrappers now delegate through Rec with real page-action coverage, reachable option captions are complete, employee-ledger sorts have supporting keys, and the prepayment request pages keep Statistic internal while synchronizing persisted visible choices. I found no remaining actionable issues.
…soft#11154) ## What & why Platform 30.x uptake fails to compile `StockRegisterforJobWork.Report.al` (GST Subcontracting, IN localization) with two AL0254 errors on line 324: ``` StockRegisterforJobWork.Report.al(324,37): error AL0254: Sorting field 'Prod. Order No.' should be part of the keys for table 'Purch. Rcpt. Line'. Add the field to a key definition to improve performance. StockRegisterforJobWork.Report.al(324,37): error AL0254: Sorting field 'Prod. Order Line No.' should be part of the keys for table 'Purch. Rcpt. Line'. Add the field to a key definition to improve performance. ``` The `Purch. Rcpt. Line` data item sorts on `"Prod. Order No."` (5401) and `"Prod. Order Line No."` (99000754). Those fields exist only on the Manufacturing table extension `Mfg. Purch. Receipt Line` (which extends `Purch. Rcpt. Line`) and are not covered by any key on the base table. Recent AL compilers tightened **AL0254** to also validate sort fields introduced by a **table extension** (earlier compilers only checked base-table fields). Combined with AL0254 defaulting to Error (after the global `AL0254 → Warning` ruleset override was removed in microsoft#10878), the report no longer compiles. No app logic changed — this only surfaces under the newer compiler. The fix wraps the `DataItemTableView` sort in a scoped `#pragma warning disable/restore AL0254`, matching the accepted suppression already used for the Item Ledger Entry sort a few lines above in the same report (added in microsoft#10878): ```al #pragma warning disable AL0254 // Accepted: Object-specific sorting; adding a shared-table key risks schema and performance changes. DataItemTableView = sorting("Prod. Order No.", "Prod. Order Line No.") Order(Ascending); #pragma warning restore AL0254 ``` A covering key is intentionally **not** added, since altering a shared base/extension table's keys risks schema and performance changes. ## Linked work [AB#649216](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/649216) ## How I validated this - [ ] I read the full diff and it contains only changes I intended. - [ ] I built the affected app(s) locally with no new analyzer warnings. - [ ] I ran the change in Business Central and confirmed it behaves as expected. - [ ] I added or updated tests for the new behavior, or explained below why none are needed. **What I tested and the outcome** Local build was **not** performed in this environment (the NAV enlistment initialization requires elevation that isn't available in the current session). The change is a 2-line, comment-annotated `#pragma` identical in pattern to the existing accepted AL0254 suppression at line 224 of the same report; it only suppresses the diagnostic and does not alter the report's runtime behavior or its sort order. No tests added — this is a compile-only suppression with no behavior change. **Please build the app locally and confirm before requesting review**; CI on this PR is the safety net. ## Risk & compatibility Minimal. Pragma/comment-only change with no functional, schema, or data impact. It suppresses AL0254 for one object-specific sort whose sort fields come from a table extension without a covering key. Follow-up: once the newly-flagged AL0254 sort sites across BCApps are addressed, the AL0254 Error hardening from microsoft#10878 can stay in place. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Summary
AL0254,AL0523,AA0242,AA0224, andAW0007, allowing the base ruleset's Error default to apply.src/rulesets/base.ruleset.jsonfrom 81 to 76 overrides;AL0424remains Warning and is untouched.The authoritative census contains 776 raw diagnostic records because projects and generated country views repeat diagnostics. Those collapse to 71 distinct generated file/line sites. The final diff changes 52 files (51 AL files) and retains 46 exact suppressions: 22
AL0254, 3AL0523, and 21AW0007. There are noAA0242orAA0224suppressions and no bare restores.Review fixes
ShowAccountCard()andShowAccountLedgerEntries()to delegate throughRec, and changed the existing unit tests to invoke the actual subform actions through TestPage.SetLoadFieldscall, eliminating the JIT loads.OnPreReportsynchronizes persisted request values for normal runs; explicit Statistic initialization hides the selector and preserves internal ordinal 2.The remaining suppressions preserve accepted report/page sorting choices, duplicate wrapper APIs, and FlowFilter API exposure without broad behavior changes.
Validation
Invoke-MiSnapAppwithRepoBranchName = 'main': success across all 52 changed files atc6ecfe4758..alpackages, and global-only symbol restore returned no packages.Related to AB#640773.