Skip to content

Ruleset hardening: promote five low-risk rules to Error - #10878

Merged
Jesper Schulz-Wedde (JesperSchulz) merged 9 commits into
mainfrom
jesperschulz-ruleset-al0254-hardening
Sep 3, 2026
Merged

Ruleset hardening: promote five low-risk rules to Error#10878
Jesper Schulz-Wedde (JesperSchulz) merged 9 commits into
mainfrom
jesperschulz-ruleset-al0254-hardening

Conversation

@JesperSchulz

@JesperSchulz Jesper Schulz-Wedde (JesperSchulz) commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Remove the global Warning overrides for AL0254, AL0523, AA0242, AA0224, and AW0007, allowing the base ruleset's Error default to apply.
  • Convert the actionable recursion, option-model/caption, partial-record, and missing-key findings into real fixes.
  • Keep tightly scoped, ID-qualified suppressions only for accepted pre-existing behavior.
  • Reduce src/rulesets/base.ruleset.json from 81 to 76 overrides; AL0424 remains 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, 3 AL0523, and 21 AW0007. There are no AA0242 or AA0224 suppressions and no bare restores.

Review fixes

  • AL0523: retained the three public page wrappers for compatibility, fixed ShowAccountCard() and ShowAccountLedgerEntries() to delegate through Rec, and changed the existing unit tests to invoke the actual subform actions through TestPage.
  • AA0242: fixed all 11 propagated source sites by adding each accessed field to the preceding SetLoadFields call, eliminating the JIT loads.
  • AA0224: fixed all 13 propagated source sites. Added reachable captions, retained move-negative compatibility, and separated the visible Invoice/Credit Memo request option from the internal three-value processing option. OnPreReport synchronizes persisted request values for normal runs; explicit Statistic initialization hides the selector and preserves internal ordinal 2.
  • AL0254: added descriptive Employee Ledger Entry keys for Closed by Entry No. and NL proposal sorting, then removed four now-stale suppressions.

The remaining suppressions preserve accepted report/page sorting choices, duplicate wrapper APIs, and FlowFilter API exposure without broad behavior changes.

Validation

  • Invoke-MiSnapApp with RepoBranchName = 'main': success across all 52 changed files at c6ecfe4758.
  • W1 BaseApp analyzer diagnostics are clear for the synchronized purchase/sales prepayment request-page changes and previously reviewed files; the Bank Deposits test source has no diagnostics.
  • A full test compile/run was unavailable because this checkout has no local .alpackages, and global-only symbol restore returned no packages.
  • BOM, CRLF, and trailing-newline behavior is unchanged in every modified AL file.

Related to AB#640773.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added AL: Apps (W1) Add-on apps for W1 Ownership: Needs Review Ownership is Other, low confidence, or needs manual correction Team: Other GitHub request for other area than SCM, Finance or Integration labels Sep 1, 2026
@github-actions github-actions Bot added this to the Version 30.0 milestone Sep 1, 2026
Jesper Schulz-Wedde added 2 commits September 1, 2026 10:44
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
Comment thread src/Layers/NL/BaseApp/Local/Bank/Payment/Docket.Report.al Outdated
@JesperSchulz Jesper Schulz-Wedde (JesperSchulz) changed the title Ruleset hardening: promote AL0254 to Error Ruleset hardening: promote five low-risk rules to Error Sep 1, 2026
Comment thread src/Layers/IT/BaseApp/Inventory/Transfer/ReleaseTransferDocument.Codeunit.al Outdated
Comment thread src/Layers/W1/BaseApp/Inventory/Transfer/ReleaseTransferDocument.Codeunit.al Outdated
Comment thread src/Layers/APAC/BaseApp/Inventory/Posting/ItemJnlPostLine.Codeunit.al Outdated
Comment thread src/Layers/IT/BaseApp/Inventory/Posting/ItemJnlPostLine.Codeunit.al Outdated
Comment thread src/Layers/RU/BaseApp/Inventory/Posting/ItemJnlPostLine.Codeunit.al Outdated
Comment thread src/Layers/W1/BaseApp/Inventory/Posting/ItemJnlPostLine.Codeunit.al Outdated
Comment thread src/Layers/W1/BaseApp/Manufacturing/Document/ProductionOrder.Table.al Outdated
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>
Comment thread src/Layers/NA/BaseApp/Local/Bank/Deposit/PostedDepositSubform.Page.al Outdated
Comment thread src/Layers/W1/BaseApp/Purchases/Reports/PurchasePrepmtDocTest.Report.al Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@JesperSchulz

Copy link
Copy Markdown
Contributor Author

Predrag Maricic (@PredragMaricic) Addressed the final request-page concern in 7a7f82c125: all nine propagated prepayment reports now use a separate two-value Invoice/Credit Memo request option, while the existing DocumentType retains Statistic for internal processing and purchase InitializeRequest compatibility. W1 diagnostics and Invoke-MiSnapApp are clean. Please re-review.

Comment thread src/rulesets/base.ruleset.json
Comment thread src/Layers/W1/BaseApp/Purchases/Reports/PurchasePrepmtDocTest.Report.al Outdated
Comment thread src/Layers/NL/BaseApp/Local/Bank/Payment/PaymentHistoryOverview.Report.al Outdated
Comment thread src/Layers/NL/BaseApp/Local/Bank/Payment/ProposalOverview.Report.al Outdated
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
@JesperSchulz

Copy link
Copy Markdown
Contributor Author

Predrag Maricic (@PredragMaricic) Follow-up c6ecfe4758 resolves the four substantive threads: Payment/Proposal Overview stale AL0254 suppressions are removed, and all nine prepayment reports now synchronize persisted request values in OnPreReport while preserving explicit internal Statistic initialization behind a hidden two-value selector. W1 diagnostics and Invoke-MiSnapApp are clean. Please re-review.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/Layers/APAC/BaseApp/Sales/Reports/CustomerLabels.Report.al
Merged via the queue into main with commit 1e38721 Sep 3, 2026
174 checks passed
@JesperSchulz
Jesper Schulz-Wedde (JesperSchulz) deleted the jesperschulz-ruleset-al0254-hardening branch September 3, 2026 15:31
pull Bot pushed a commit to CarstenMertes/BCApps that referenced this pull request Sep 8, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AL: Apps (W1) Add-on apps for W1 Ownership: Needs Review Ownership is Other, low confidence, or needs manual correction Team: Other GitHub request for other area than SCM, Finance or Integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants