co-maintainer 0.7.8 → 0.7.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/package.json
CHANGED
|
@@ -13,7 +13,10 @@ export declare function escapeProperty(value: string): string;
|
|
|
13
13
|
/** One workflow command per finding still standing, errors first. A finding
|
|
14
14
|
* that was closed since the last review needs no annotation. The dropped
|
|
15
15
|
* files warning takes one of the warning slots. */
|
|
16
|
-
export declare function githubAnnotations(findings: HumanFinding[], coverage?: Coverage
|
|
16
|
+
export declare function githubAnnotations(findings: HumanFinding[], coverage?: Coverage,
|
|
17
|
+
/** Name each finding's rules, only when the repository turned references
|
|
18
|
+
* on, as the terminal output does. */
|
|
19
|
+
showReferences?: boolean): string[];
|
|
17
20
|
export type GithubSummaryInput = {
|
|
18
21
|
/** What was reviewed, for the line under the heading. */
|
|
19
22
|
title: string;
|
|
@@ -30,6 +33,9 @@ export type GithubSummaryInput = {
|
|
|
30
33
|
/** The extensions' results. Their findings join the table, and their
|
|
31
34
|
* `markdown` follows the AI part. */
|
|
32
35
|
extensions?: ExtensionReport;
|
|
36
|
+
/** Name each finding's rules in its annotation. On only when the
|
|
37
|
+
* repository turned references on. */
|
|
38
|
+
showReferences?: boolean;
|
|
33
39
|
/** An intent file was given. The summary says so and never shows the text. */
|
|
34
40
|
intent?: boolean;
|
|
35
41
|
};
|
|
@@ -27,7 +27,17 @@ export function escapeData(value) {
|
|
|
27
27
|
export function escapeProperty(value) {
|
|
28
28
|
return escapeData(value).replace(/:/g, "%3A").replace(/,/g, "%2C");
|
|
29
29
|
}
|
|
30
|
-
|
|
30
|
+
/** ` (rule R3)` or ` (rules R3, I1)`: the guide and instruction rules a
|
|
31
|
+
* finding rests on, so a CI annotation names them as the terminal does. */
|
|
32
|
+
function rulesNote(row) {
|
|
33
|
+
const ids = (row.references ?? []).flatMap((reference) => reference.kind === "rule" || reference.kind === "instruction"
|
|
34
|
+
? [reference.id]
|
|
35
|
+
: []);
|
|
36
|
+
if (ids.length === 0)
|
|
37
|
+
return "";
|
|
38
|
+
return ` (${ids.length === 1 ? "rule" : "rules"} ${ids.join(", ")})`;
|
|
39
|
+
}
|
|
40
|
+
function annotation(row, showReferences = false) {
|
|
31
41
|
const properties = [];
|
|
32
42
|
if (row.path) {
|
|
33
43
|
properties.push(`file=${escapeProperty(row.path)}`);
|
|
@@ -46,7 +56,8 @@ function annotation(row) {
|
|
|
46
56
|
? `${row.severity}: ${short}`
|
|
47
57
|
: `${row.severity} finding`)}`);
|
|
48
58
|
const level = row.blocking ? "error" : "warning";
|
|
49
|
-
|
|
59
|
+
const note = showReferences ? rulesNote(row) : "";
|
|
60
|
+
return `::${level} ${properties.join(",")}::${escapeData(`${row.body || row.title}${note}`)}`;
|
|
50
61
|
}
|
|
51
62
|
function active(findings) {
|
|
52
63
|
return sortHumanFindings(findings).filter((row) => row.state !== "closed");
|
|
@@ -63,7 +74,10 @@ function droppedAnnotation(coverage) {
|
|
|
63
74
|
/** One workflow command per finding still standing, errors first. A finding
|
|
64
75
|
* that was closed since the last review needs no annotation. The dropped
|
|
65
76
|
* files warning takes one of the warning slots. */
|
|
66
|
-
export function githubAnnotations(findings, coverage
|
|
77
|
+
export function githubAnnotations(findings, coverage,
|
|
78
|
+
/** Name each finding's rules, only when the repository turned references
|
|
79
|
+
* on, as the terminal output does. */
|
|
80
|
+
showReferences = false) {
|
|
67
81
|
const rows = active(findings);
|
|
68
82
|
const errors = rows.filter((row) => row.blocking);
|
|
69
83
|
const warnings = rows.filter((row) => !row.blocking);
|
|
@@ -72,7 +86,7 @@ export function githubAnnotations(findings, coverage) {
|
|
|
72
86
|
...errors.slice(0, MAX_ANNOTATIONS_PER_LEVEL),
|
|
73
87
|
...warnings.slice(0, MAX_ANNOTATIONS_PER_LEVEL - (dropped ? 1 : 0)),
|
|
74
88
|
];
|
|
75
|
-
const lines = shown.map(annotation);
|
|
89
|
+
const lines = shown.map((row) => annotation(row, showReferences));
|
|
76
90
|
if (dropped)
|
|
77
91
|
lines.push(dropped);
|
|
78
92
|
const left = rows.length - shown.length;
|
|
@@ -150,7 +164,7 @@ export function emitGithubOutput(input) {
|
|
|
150
164
|
// Only an extension finding with a location is annotated. The job summary
|
|
151
165
|
// lists the rest.
|
|
152
166
|
const located = extensionHumanFindings(input.extensions).filter((row) => row.path);
|
|
153
|
-
for (const line of githubAnnotations([...input.findings, ...located], input.coverage)) {
|
|
167
|
+
for (const line of githubAnnotations([...input.findings, ...located], input.coverage, input.showReferences)) {
|
|
154
168
|
console.log(line);
|
|
155
169
|
}
|
|
156
170
|
appendStepSummary(githubSummary(input));
|