mirror of
https://github.com/microsoft/BCQuality.git
synced 2026-08-06 09:26:52 +01:00
style-review: calibrate analyzer-redundant rules to info; keep correctness bugs out of style scope (#95)
Online-eval data shows the style leaf is the largest source of dismissed findings. Two causes: - Mechanical, analyzer-enforced conventions (this-keyword AA0248, label suffixes AA0074, missing ToolTip, label scope) fire at gating severity and duplicate what CodeCop/AppSourceCop already report. Calibrate them to info so a severity-gating consumer drops the redundant noise. - Correctness/logic/data-integrity defects get reframed as style conventions and emitted here. Sharpen the scope boundary: such defects belong to the relevant domain leaf, or to al-code-review's cross-cutting agent channel when no knowledge file covers them, never to this leaf. Co-authored-by: wenjiefan <wenjiefan@microsoft.com>
This commit is contained in:
parent
0e06485027
commit
9214f73819
1 changed files with 6 additions and 4 deletions
|
|
@ -53,13 +53,15 @@ When the post-conflict worklist is empty because no applicable style knowledge e
|
||||||
|
|
||||||
For each worklist entry, evaluate the diff against the file's `## Best Practice` and `## Anti Pattern` sections. Style findings rarely reach `blocker` — reserve it for cases where the knowledge file documents a platform-level requirement (for example, API page property constraints the OData runtime rejects). Most style findings are `minor` or `info`; egregious misuse (`Error` with pre-built Text losing translation and telemetry classification) may reach `major`.
|
For each worklist entry, evaluate the diff against the file's `## Best Practice` and `## Anti Pattern` sections. Style findings rarely reach `blocker` — reserve it for cases where the knowledge file documents a platform-level requirement (for example, API page property constraints the OData runtime rejects). Most style findings are `minor` or `info`; egregious misuse (`Error` with pre-built Text losing translation and telemetry classification) may reach `major`.
|
||||||
|
|
||||||
|
Severity calibration — a formal analyzer already flags the mechanical presence/naming conventions (the `this` keyword AA0248, approved label suffixes AA0074, a missing `ToolTip`, a `Label` declared at local instead of object scope, required parentheses). On those, BCQuality's value is the *explanation* of why the rule exists, not a second gate; emit them at `info` so a consumer that gates on severity does not re-flag what CodeCop/AppSourceCop already reports. Reserve `minor` for style issues with concrete downstream impact the analyzer does not catch — lost translation or telemetry classification from a string-built `Error`, an `OptionCaption` that does not match its `OptionMembers`, a misleading named invocation. This keeps the domain's default output advisory and prevents analyzer-redundant noise from competing with substantive review.
|
||||||
|
|
||||||
Set `confidence` to:
|
Set `confidence` to:
|
||||||
|
|
||||||
- `high` when the detection is based on an unambiguous pattern match.
|
- `high` when the detection is based on an unambiguous pattern match.
|
||||||
- `medium` when detection relies on heuristics or when any frontmatter dimension was `unknown`.
|
- `medium` when detection relies on heuristics or when any frontmatter dimension was `unknown`.
|
||||||
- `low` when the finding is an advisory derived only from applicability.
|
- `low` when the finding is an advisory derived only from applicability.
|
||||||
|
|
||||||
After evaluating each worklist entry, also consider whether the diff exhibits a style defect the agent recognises from its general AL knowledge that no knowledge file in the worklist covers. Such candidates are agent findings within this skill's domain — emit them with `references: []`, an `id` slug prefixed with `agent:`, `confidence` capped at `medium`, `severity` capped at `minor` (agent findings are advisory and non-gating), and a `message` that is self-contained (describing both the issue and a concrete recommendation, since there is no knowledge-file footer for the consumer to fall back on). Hold every candidate to the precision bar in `skills/do.md` (*Agent findings*): emit only a clear, widely-accepted AL style violation with a concrete basis a knowledgeable BC reviewer would agree on — steelman it first and drop personal preference, speculation, and any single defensible formatting choice among several; when in doubt, omit. The scope is strictly style; defects outside this domain belong to other leaves and MUST NOT be emitted here. Before emitting, check the worklist for a knowledge file that matches the candidate — if one exists, upgrade the candidate to a knowledge-backed finding instead. See `skills/do.md` for the full contract.
|
After evaluating each worklist entry, also consider whether the diff exhibits a style defect the agent recognises from its general AL knowledge that no knowledge file in the worklist covers. Such candidates are agent findings within this skill's domain — emit them with `references: []`, an `id` slug prefixed with `agent:`, `confidence` capped at `medium`, `severity` capped at `minor` (agent findings are advisory and non-gating), and a `message` that is self-contained (describing both the issue and a concrete recommendation, since there is no knowledge-file footer for the consumer to fall back on). Hold every candidate to the precision bar in `skills/do.md` (*Agent findings*): emit only a clear, widely-accepted AL style violation with a concrete basis a knowledgeable BC reviewer would agree on — steelman it first and drop personal preference, speculation, and any single defensible formatting choice among several; when in doubt, omit. The scope is strictly style — naming, labelling, formatting, and analyzer-adjacent conventions. A correctness, logic, data-integrity, or contract defect is NOT a style finding even when it can be reworded as a convention: a method that mutates a shared `Record`'s filters, an unfiltered `DeleteAll`, a violated interface contract, or a wrong boolean guard are behavioural defects, not conventions — do not emit them here under a style framing. If a specific domain leaf covers the concern (performance, security, error-handling, …) it belongs there; if no knowledge file in any domain covers it, it belongs to the `al-code-review` super-skill's cross-cutting self-review agent channel (`from-sub-skill: "agent"`, `severity` capped at `minor`), not to this leaf. A reliable test: if you cannot cite a style `## Best Practice`/`## Anti Pattern` for the concern, it is very likely not a style finding. Before emitting, check the worklist for a knowledge file that matches the candidate — if one exists, upgrade the candidate to a knowledge-backed finding instead. See `skills/do.md` for the full contract.
|
||||||
|
|
||||||
For every emitted finding, decide whether the fix is mechanical. A fix is mechanical when it is small, local, and unambiguous from the diff context (for example: delete unreachable lines; replace `Count() > 0` with `not IsEmpty()`; move a local `Label` to object scope; add a missing `ToolTip`, `OptionCaption`, or `DataClassification`; replace a string-concatenated `Error` with a Label-backed call; change an over-broad permission token; or add an obvious `else`/guard branch). For mechanical findings, emit `findings[].suggested-code` with the literal replacement for the source lines indicated by `location`. The payload must be a verbatim replacement — no diff markers, no fences, no commentary — that the consumer can render as a one-click suggestion. When a `.good.al` companion exists and the diff context matches the `.bad.al` shape, adapt the `.good.al` replacement into `suggested-code`.
|
For every emitted finding, decide whether the fix is mechanical. A fix is mechanical when it is small, local, and unambiguous from the diff context (for example: delete unreachable lines; replace `Count() > 0` with `not IsEmpty()`; move a local `Label` to object scope; add a missing `ToolTip`, `OptionCaption`, or `DataClassification`; replace a string-concatenated `Error` with a Label-backed call; change an over-broad permission token; or add an obvious `else`/guard branch). For mechanical findings, emit `findings[].suggested-code` with the literal replacement for the source lines indicated by `location`. The payload must be a verbatim replacement — no diff markers, no fences, no commentary — that the consumer can render as a one-click suggestion. When a `.good.al` companion exists and the diff context matches the `.bad.al` shape, adapt the `.good.al` replacement into `suggested-code`.
|
||||||
|
|
||||||
|
|
@ -82,13 +84,13 @@ Output conforms to the DO output contract. A populated example:
|
||||||
"skill": { "id": "al-style-review", "version": 1 },
|
"skill": { "id": "al-style-review", "version": 1 },
|
||||||
"outcome": "completed",
|
"outcome": "completed",
|
||||||
"summary": {
|
"summary": {
|
||||||
"counts": { "blocker": 0, "major": 0, "minor": 1, "info": 0 },
|
"counts": { "blocker": 0, "major": 0, "minor": 0, "info": 1 },
|
||||||
"coverage": { "worklist-size": 1, "items-evaluated": 1 }
|
"coverage": { "worklist-size": 1, "items-evaluated": 1 }
|
||||||
},
|
},
|
||||||
"findings": [
|
"findings": [
|
||||||
{
|
{
|
||||||
"id": "microsoft/knowledge/style/label-suffix-approved-list.md",
|
"id": "microsoft/knowledge/style/apply-approved-label-suffixes.md",
|
||||||
"severity": "minor",
|
"severity": "info",
|
||||||
"message": "A Label named Text000 has no approved suffix (Msg/Err/Qst/Tok/Lbl/Txt). Per the referenced CodeCop AA0074 guidance, every Label and TextConst carries a suffix indicating its consuming call.",
|
"message": "A Label named Text000 has no approved suffix (Msg/Err/Qst/Tok/Lbl/Txt). Per the referenced CodeCop AA0074 guidance, every Label and TextConst carries a suffix indicating its consuming call.",
|
||||||
"location": {
|
"location": {
|
||||||
"file": "src/Sales/PostingRoutines.Codeunit.al",
|
"file": "src/Sales/PostingRoutines.Codeunit.al",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue