@repometry/core 0.0.0 → 0.2.0

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.
Files changed (30) hide show
  1. package/package.json +4 -3
  2. package/target/main/resources/plugin-v1.schema.json +328 -0
  3. package/target/main/ts/engine/author-contracts.d.ts +25 -0
  4. package/target/main/ts/engine/author-contracts.js +51 -0
  5. package/target/main/ts/engine/author-operation.d.ts +3 -0
  6. package/target/main/ts/engine/author-operation.js +34 -0
  7. package/target/main/ts/engine/manifest.js +6 -6
  8. package/target/main/ts/engine/plan.js +2 -2
  9. package/target/main/ts/engine/plugin-manifest.d.ts +42 -0
  10. package/target/main/ts/engine/plugin-manifest.js +18 -0
  11. package/target/main/ts/engine/plugin.d.ts +2 -0
  12. package/target/main/ts/index.d.ts +9 -16
  13. package/target/main/ts/index.js +2 -5
  14. package/target/main/ts/model/file-types.d.ts +1 -0
  15. package/target/main/ts/model/file-types.js +4 -1
  16. package/target/main/ts/model/finding-ignore.d.ts +3 -3
  17. package/target/main/ts/model/finding-ignore.js +22 -10
  18. package/target/main/ts/model/ignore-rule.d.ts +12 -1
  19. package/target/main/ts/model/inspection-category.d.ts +8 -0
  20. package/target/main/ts/model/inspection-category.js +8 -0
  21. package/target/main/ts/model/source.d.ts +2 -0
  22. package/target/main/ts/model/source.js +3 -1
  23. package/target/main/ts/profile/exclusions.d.ts +1 -1
  24. package/target/main/ts/profile/exclusions.js +5 -5
  25. package/target/main/ts/profile/ignore.d.ts +4 -0
  26. package/target/main/ts/profile/ignore.js +82 -0
  27. package/target/main/ts/profile/profile.js +2 -2
  28. package/target/main/ts/usecases/inspect.d.ts +1 -0
  29. package/target/main/ts/usecases/inspect.js +12 -6
  30. package/target/main/ts/usecases/review.js +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@repometry/core",
3
- "version": "0.0.0",
3
+ "version": "0.2.0",
4
4
  "description": "The Repometry plugin API and inspection engine",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -28,7 +28,8 @@
28
28
  "./internal/*.js": {
29
29
  "types": "./target/main/ts/*.d.ts",
30
30
  "default": "./target/main/ts/*.js"
31
- }
31
+ },
32
+ "./plugin-v1.schema.json": "./target/main/resources/plugin-v1.schema.json"
32
33
  },
33
34
  "files": [
34
35
  "target/main",
@@ -38,7 +39,7 @@
38
39
  "access": "public"
39
40
  },
40
41
  "scripts": {
41
- "build": "node -e \"require('node:fs').rmSync('target/main', { recursive: true, force: true })\" && tsc -p tsconfig.json && node -e \"require('node:fs').cpSync('../../LICENSE', 'LICENSE')\"",
42
+ "build": "node -e \"require('node:fs').rmSync('target/main', { recursive: true, force: true })\" && tsc -p tsconfig.json && node -e \"const fs = require('node:fs'); fs.cpSync('../../LICENSE', 'LICENSE'); fs.cpSync('src/main/resources', 'target/main/resources', { recursive: true })\"",
42
43
  "build:test": "npm run build && node -e \"require('node:fs').rmSync('target/verification', { recursive: true, force: true })\" && tsc -p tsconfig.test.json",
43
44
  "test": "npm run build:test && node --test 'target/verification/test/ts/*.test.js'",
44
45
  "prepack": "npm run build"
@@ -0,0 +1,328 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "urn:repometry:schema:plugin:1",
4
+ "title": "Repometry plugin manifest",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": [
8
+ "schema",
9
+ "id",
10
+ "category"
11
+ ],
12
+ "properties": {
13
+ "id": {
14
+ "$ref": "#/$defs/id"
15
+ },
16
+ "version": {
17
+ "$ref": "#/$defs/text"
18
+ },
19
+ "image": {
20
+ "type": "string",
21
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9.:/@_-]*$"
22
+ },
23
+ "command": {
24
+ "type": "array",
25
+ "minItems": 1,
26
+ "items": {
27
+ "type": "string",
28
+ "pattern": "^[^\\u0000]*$"
29
+ }
30
+ },
31
+ "scope": {
32
+ "enum": [
33
+ "file",
34
+ "repository"
35
+ ]
36
+ },
37
+ "fileIndependent": {
38
+ "type": "boolean",
39
+ "description": "Each file's results and diagnostics are independent of the other files supplied to a repository parser."
40
+ },
41
+ "include": {
42
+ "$ref": "#/$defs/globs"
43
+ },
44
+ "exclude": {
45
+ "$ref": "#/$defs/globs"
46
+ },
47
+ "limits": {
48
+ "type": "object",
49
+ "additionalProperties": false,
50
+ "properties": {
51
+ "timeoutMs": {
52
+ "type": "integer",
53
+ "minimum": 1,
54
+ "maximum": 2147483647
55
+ },
56
+ "maxOutputBytes": {
57
+ "$ref": "#/$defs/positiveInteger"
58
+ },
59
+ "memoryBytes": {
60
+ "$ref": "#/$defs/positiveInteger"
61
+ },
62
+ "pidsLimit": {
63
+ "$ref": "#/$defs/positiveInteger"
64
+ }
65
+ }
66
+ },
67
+ "tools": {
68
+ "type": "object",
69
+ "minProperties": 1,
70
+ "additionalProperties": {
71
+ "$ref": "#/$defs/text"
72
+ }
73
+ },
74
+ "languages": {
75
+ "type": "array",
76
+ "minItems": 1,
77
+ "items": {
78
+ "type": "object",
79
+ "additionalProperties": false,
80
+ "required": [
81
+ "id",
82
+ "label",
83
+ "include"
84
+ ],
85
+ "properties": {
86
+ "id": {
87
+ "$ref": "#/$defs/id"
88
+ },
89
+ "label": {
90
+ "$ref": "#/$defs/text"
91
+ },
92
+ "color": {
93
+ "type": "string",
94
+ "pattern": "^#[0-9A-Fa-f]{6}$"
95
+ },
96
+ "syntax": {
97
+ "$ref": "#/$defs/syntax"
98
+ },
99
+ "measures": {
100
+ "type": "array",
101
+ "uniqueItems": true,
102
+ "items": {
103
+ "enum": [
104
+ "functions",
105
+ "cyclomaticComplexity",
106
+ "cognitiveComplexity",
107
+ "classes",
108
+ "commentLines",
109
+ "codeLines",
110
+ "duplication",
111
+ "checks"
112
+ ]
113
+ }
114
+ },
115
+ "include": {
116
+ "$ref": "#/$defs/globs"
117
+ }
118
+ }
119
+ }
120
+ },
121
+ "optionsSchema": {
122
+ "anyOf": [
123
+ {
124
+ "type": "object"
125
+ },
126
+ {
127
+ "type": "boolean"
128
+ }
129
+ ]
130
+ },
131
+ "requires": {
132
+ "type": "object",
133
+ "additionalProperties": false,
134
+ "properties": {
135
+ "node": {
136
+ "$ref": "#/$defs/text"
137
+ },
138
+ "repometry": {
139
+ "$ref": "#/$defs/text"
140
+ },
141
+ "tools": {
142
+ "type": "array",
143
+ "uniqueItems": true,
144
+ "items": {
145
+ "type": "string",
146
+ "pattern": "^[^\\s/\\\\\\u0000]+$"
147
+ }
148
+ }
149
+ }
150
+ },
151
+ "schema": {
152
+ "const": "urn:repometry:schema:plugin:1"
153
+ },
154
+ "category": {
155
+ "enum": [
156
+ "language",
157
+ "source",
158
+ "maintainability",
159
+ "coverage",
160
+ "security"
161
+ ]
162
+ },
163
+ "checks": {
164
+ "type": "array",
165
+ "items": {
166
+ "type": "object",
167
+ "required": [
168
+ "id"
169
+ ],
170
+ "additionalProperties": false,
171
+ "properties": {
172
+ "id": {
173
+ "$ref": "#/$defs/text"
174
+ },
175
+ "description": {
176
+ "$ref": "#/$defs/text"
177
+ },
178
+ "measure": {
179
+ "$ref": "#/$defs/text"
180
+ },
181
+ "defaults": {
182
+ "type": "object",
183
+ "additionalProperties": false,
184
+ "properties": {
185
+ "limit": {
186
+ "type": "number",
187
+ "minimum": 0
188
+ },
189
+ "cost": {
190
+ "type": "number",
191
+ "minimum": 0
192
+ }
193
+ }
194
+ },
195
+ "per": {
196
+ "type": "array",
197
+ "minItems": 2,
198
+ "maxItems": 2,
199
+ "items": {
200
+ "$ref": "#/$defs/text"
201
+ }
202
+ }
203
+ }
204
+ }
205
+ }
206
+ },
207
+ "$defs": {
208
+ "syntax": {
209
+ "type": "object",
210
+ "additionalProperties": false,
211
+ "properties": {
212
+ "lineComments": {
213
+ "type": "array",
214
+ "items": {
215
+ "$ref": "#/$defs/syntax/$defs/marker"
216
+ }
217
+ },
218
+ "blockComments": {
219
+ "type": "array",
220
+ "items": {
221
+ "type": "array",
222
+ "minItems": 2,
223
+ "maxItems": 2,
224
+ "items": {
225
+ "$ref": "#/$defs/syntax/$defs/marker"
226
+ }
227
+ }
228
+ },
229
+ "strings": {
230
+ "type": "array",
231
+ "items": {
232
+ "type": "object",
233
+ "required": [
234
+ "quote"
235
+ ],
236
+ "additionalProperties": false,
237
+ "properties": {
238
+ "quote": {
239
+ "$ref": "#/$defs/syntax/$defs/marker"
240
+ },
241
+ "multiline": {
242
+ "type": "boolean"
243
+ },
244
+ "raw": {
245
+ "type": "boolean"
246
+ }
247
+ }
248
+ }
249
+ },
250
+ "stringPrefixes": {
251
+ "type": "array",
252
+ "items": {
253
+ "$ref": "#/$defs/syntax/$defs/word"
254
+ }
255
+ },
256
+ "keywords": {
257
+ "type": "array",
258
+ "maxItems": 512,
259
+ "items": {
260
+ "$ref": "#/$defs/syntax/$defs/word"
261
+ }
262
+ },
263
+ "regexAfter": {
264
+ "type": "array",
265
+ "items": {
266
+ "$ref": "#/$defs/syntax/$defs/word"
267
+ }
268
+ }
269
+ },
270
+ "$defs": {
271
+ "marker": {
272
+ "type": "string",
273
+ "minLength": 1,
274
+ "maxLength": 8,
275
+ "pattern": "^\\S+$"
276
+ },
277
+ "word": {
278
+ "type": "string",
279
+ "pattern": "^[A-Za-z_$][\\w$]*$"
280
+ }
281
+ }
282
+ },
283
+ "id": {
284
+ "type": "string",
285
+ "pattern": "^[a-z][a-z0-9-]*$"
286
+ },
287
+ "text": {
288
+ "type": "string",
289
+ "pattern": "\\S"
290
+ },
291
+ "positiveInteger": {
292
+ "type": "integer",
293
+ "minimum": 1,
294
+ "maximum": 9007199254740991
295
+ },
296
+ "globs": {
297
+ "type": "array",
298
+ "uniqueItems": true,
299
+ "items": {
300
+ "$ref": "#/$defs/text"
301
+ }
302
+ }
303
+ },
304
+ "allOf": [
305
+ {
306
+ "if": {
307
+ "required": [
308
+ "category"
309
+ ],
310
+ "properties": {
311
+ "category": {
312
+ "const": "language"
313
+ }
314
+ }
315
+ },
316
+ "then": {
317
+ "required": [
318
+ "languages"
319
+ ]
320
+ },
321
+ "else": {
322
+ "properties": {
323
+ "languages": false
324
+ }
325
+ }
326
+ }
327
+ ]
328
+ }
@@ -0,0 +1,25 @@
1
+ import type { DataContract } from './plugin.js';
2
+ import type { CodeStructure as StoredStructure, StructuralObservation as StoredObservation } from '../model/code-structure.js';
3
+ import type { Finding as StoredFinding, FindingResult as StoredFindings } from '../model/finding.js';
4
+ import type { PluginCategory } from '../model/inspection-category.js';
5
+ export type StructuralObservation = Omit<StoredObservation, 'rule'> & {
6
+ readonly check: StoredObservation['rule'];
7
+ };
8
+ export type CodeStructure = Omit<StoredStructure, 'observations'> & {
9
+ readonly observations?: readonly StructuralObservation[];
10
+ };
11
+ export type Finding = Omit<StoredFinding, 'tool' | 'rule' | 'category'> & {
12
+ readonly plugin?: string;
13
+ readonly check: string;
14
+ };
15
+ export type FindingResult = Omit<StoredFindings, 'findings'> & {
16
+ readonly findings: readonly Finding[];
17
+ };
18
+ export declare const codeStructure: DataContract<CodeStructure>;
19
+ export declare const codeStructures: DataContract<readonly CodeStructure[]>;
20
+ export declare const findingResult: DataContract<FindingResult>;
21
+ export declare function writeStructure(value: unknown): unknown;
22
+ export declare function writeFindings(value: unknown, id?: string, dimension?: PluginCategory): unknown;
23
+ export declare function readStructure(value: StoredStructure): CodeStructure;
24
+ export declare function readFindings(value: StoredFindings): FindingResult;
25
+ export declare function findingCategory(dimension: PluginCategory | undefined, chargesEffort: boolean): StoredFinding['category'];
@@ -0,0 +1,51 @@
1
+ import { codeStructure as storedStructure, codeStructures as storedStructures } from '../model/code-structure.js';
2
+ import { findingResult as storedFindings } from '../model/finding.js';
3
+ import { category } from '../model/inspection-category.js';
4
+ import { isRecord } from '../model/plugin-data.js';
5
+ export const codeStructure = { id: storedStructure.id,
6
+ accepts: (value) => storedStructure.accepts(writeStructure(value)) };
7
+ export const codeStructures = { id: storedStructures.id,
8
+ accepts: (value) => Array.isArray(value) && value.every(codeStructure.accepts) };
9
+ export const findingResult = { id: storedFindings.id,
10
+ accepts: (value) => storedFindings.accepts(writeFindings(value)) };
11
+ export function writeStructure(value) {
12
+ if (!isRecord(value) || !Array.isArray(value.observations))
13
+ return value;
14
+ return { ...value, observations: value.observations.map(writeObservation) };
15
+ }
16
+ function writeObservation(value) {
17
+ if (!isRecord(value))
18
+ return value;
19
+ const { check, ...fields } = value;
20
+ return { ...fields, rule: check };
21
+ }
22
+ export function writeFindings(value, id, dimension) {
23
+ if (!isRecord(value) || !Array.isArray(value.findings))
24
+ return value;
25
+ return { ...value, findings: value.findings.map(finding => writeFinding(finding, id, dimension)) };
26
+ }
27
+ function writeFinding(value, id, dimension) {
28
+ if (!isRecord(value))
29
+ return value;
30
+ const { plugin, check, ...fields } = value;
31
+ if (id !== undefined && plugin !== undefined && plugin !== id)
32
+ throw new Error('A finding may only name its reporting plugin ' + id);
33
+ if (dimension !== undefined && dimension !== category.maintainability && dimension !== category.security) {
34
+ throw new Error('Plugins in ' + dimension + ' do not produce findings');
35
+ }
36
+ const group = findingCategory(dimension, fields.effortMinutes !== undefined);
37
+ return { ...fields, tool: plugin ?? id ?? 'plugin', rule: check, category: group };
38
+ }
39
+ export function readStructure(value) {
40
+ const { observations, ...fields } = value;
41
+ return observations === undefined ? fields : { ...value, observations: observations.map(({ rule, ...entry }) => ({ ...entry, check: rule })) };
42
+ }
43
+ export function readFindings(value) {
44
+ return { ...value, findings: value.findings.map(({ tool, rule, category, ...entry }) => ({ ...entry, plugin: tool, check: rule })) };
45
+ }
46
+ export function findingCategory(dimension, chargesEffort) {
47
+ if (dimension === category.security)
48
+ return 'security';
49
+ return chargesEffort ? 'structure' : 'lint';
50
+ }
51
+ //# sourceMappingURL=author-contracts.js.map
@@ -0,0 +1,3 @@
1
+ import type { PluginCategory } from '../model/inspection-category.js';
2
+ import type { Operation } from './plugin.js';
3
+ export declare function authorOperation(id: string, category: PluginCategory, operation: Operation): Operation;
@@ -0,0 +1,34 @@
1
+ import { readFindings, readStructure, writeFindings, writeStructure } from './author-contracts.js';
2
+ import { findingResult } from '../model/finding.js';
3
+ import { codeStructure, codeStructures } from '../model/code-structure.js';
4
+ export function authorOperation(id, category, operation) {
5
+ const { output } = operation;
6
+ const inputs = Object.fromEntries(Object.entries(operation.inputs).map(([port, contract]) => [port, storedContract(contract)]));
7
+ return { ...operation, inputs, output: storedContract(output), async execute(context) {
8
+ const result = await operation.execute({ ...context, read: (port, contract) => readValue(context, port, contract) });
9
+ return authorResult(id, category, output.id, result);
10
+ } };
11
+ }
12
+ function authorResult(id, category, output, result) {
13
+ if (output === findingResult.id)
14
+ return writeFindings(result, id, category);
15
+ if (output === codeStructure.id)
16
+ return writeStructure(result);
17
+ if (output === codeStructures.id && Array.isArray(result))
18
+ return result.map(writeStructure);
19
+ return result;
20
+ }
21
+ const stored = new Map([codeStructure, codeStructures, findingResult].map(contract => [contract.id, contract]));
22
+ function storedContract(contract) {
23
+ return stored.get(contract.id) ?? contract;
24
+ }
25
+ function readValue(inputs, port, contract) {
26
+ if (contract.id === codeStructure.id)
27
+ return readStructure(inputs.read(port, codeStructure));
28
+ if (contract.id === codeStructures.id)
29
+ return inputs.read(port, codeStructures).map(readStructure);
30
+ if (contract.id === findingResult.id)
31
+ return readFindings(inputs.read(port, findingResult));
32
+ return inputs.read(port, contract);
33
+ }
34
+ //# sourceMappingURL=author-operation.js.map
@@ -37,7 +37,7 @@ export function manifestProducts(plugin) {
37
37
  }
38
38
  const undeclared = rules?.find(rule => rule.measure !== undefined && !catalog.has(rule.measure));
39
39
  if (undeclared)
40
- throw new Error(`Rule ${undeclared.id} in plugin ${id} references undeclared metric ${undeclared.measure}`);
40
+ throw new Error(`Check ${undeclared.id} in plugin ${id} references undeclared metric ${undeclared.measure}`);
41
41
  for (const metric of catalog.values()) {
42
42
  if (!metric.ratio)
43
43
  continue;
@@ -50,17 +50,17 @@ export function manifestProducts(plugin) {
50
50
  function manifestDeclarations(plugin) {
51
51
  const { id, kinds: declaredKinds, claims, providesLanguages, produces, rules, config } = plugin;
52
52
  if (declaredKinds === undefined && claims === undefined && providesLanguages === undefined && produces === undefined) {
53
- throw new Error(`Missing plugin manifest for ${id}. Declare kinds and produces.`);
53
+ throw new Error(`Missing plugin manifest for ${id}. Declare its category and products.`);
54
54
  }
55
55
  if (Object.hasOwn(plugin, 'languages'))
56
- throw new Error(`Plugin ${id} must declare languages in claims.languages`);
56
+ throw new Error(`Plugin ${id} must pass its language declarations through the manifest loader`);
57
57
  if (!strings(declaredKinds) || declaredKinds.length === 0 || declaredKinds.some(kind => !kinds.has(kind))) {
58
- throw new Error(`Invalid kinds for plugin ${id}`);
58
+ throw new Error(`Invalid categories for plugin ${id}`);
59
59
  }
60
60
  if (claims !== undefined && (!isRecord(claims) || Object.entries(claims).some(([key, values]) => key === 'scanOnly' ? typeof values !== 'boolean'
61
61
  : !['extensions', 'globs', 'languages'].includes(key) || !strings(values)
62
62
  || (key === 'extensions' && !values.every(isExtension))))) {
63
- throw new Error(`Invalid file claims for plugin ${id}`);
63
+ throw new Error(`Invalid file selection for plugin ${id}`);
64
64
  }
65
65
  if (providesLanguages !== undefined && (!declaredKinds.includes('language') || !validLanguages(providesLanguages))) {
66
66
  throw new Error(`Invalid provided languages for plugin ${id}`);
@@ -69,7 +69,7 @@ function manifestDeclarations(plugin) {
69
69
  throw new Error(`Plugin ${id} must declare its products`);
70
70
  if (rules !== undefined && (!Array.isArray(rules) || !rules.every(isRuleDescriptor)
71
71
  || new Set(rules.map(rule => rule.id)).size !== rules.length))
72
- throw new Error(`Invalid or duplicate rules for plugin ${id}`);
72
+ throw new Error(`Invalid or duplicate checks for plugin ${id}`);
73
73
  if (config !== undefined && typeof config !== 'boolean' && !isRecord(config))
74
74
  throw new Error(`Invalid configuration schema for plugin ${id}`);
75
75
  return { id, produces, rules };
@@ -76,9 +76,9 @@ function indexOperations(plugins) {
76
76
  const products = manifestProducts(plugin);
77
77
  const hasSettings = plugin.settings !== undefined;
78
78
  if (hasSettings && !isJsonValue(plugin.settings))
79
- throw new Error(`Plugin settings must be JSON data: ${plugin.id}`);
79
+ throw new Error(`Plugin ${plugin.id} options must be JSON data`);
80
80
  if (hasSettings && plugin.config !== undefined && !new Ajv2020().validate(plugin.config, plugin.settings)) {
81
- throw new Error(`Plugin settings violate the configuration schema: ${plugin.id}`);
81
+ throw new Error(`Plugin ${plugin.id} options do not match optionsSchema`);
82
82
  }
83
83
  for (const declaration of products.values()) {
84
84
  for (const metric of declaration.metrics ?? []) {
@@ -0,0 +1,42 @@
1
+ import type { LanguageDisplay, LanguageSyntax } from '../model/language.js';
2
+ import type { StructureMeasure } from '../model/code-structure.js';
3
+ import type { PluginCategory } from '../model/inspection-category.js';
4
+ import type { JsonValue } from '../model/plugin-data.js';
5
+ import type { Operation, Plugin, ProductDeclaration, RuleDescriptor } from './plugin.js';
6
+ export declare const pluginManifestSchema = "urn:repometry:schema:plugin:1";
7
+ export type { PluginCategory } from '../model/inspection-category.js';
8
+ type Language = LanguageDisplay & {
9
+ readonly include: readonly string[];
10
+ readonly syntax?: LanguageSyntax;
11
+ readonly measures?: readonly (Exclude<StructureMeasure, 'structuralRules'> | 'checks')[];
12
+ };
13
+ export type Check = Omit<RuleDescriptor, 'category'>;
14
+ export type ProductOutput = Omit<ProductDeclaration, 'schema'> & {
15
+ readonly valueSchema?: boolean | Readonly<Record<string, unknown>>;
16
+ };
17
+ export interface PluginManifest<Options = JsonValue> {
18
+ readonly schema: typeof pluginManifestSchema;
19
+ readonly id: string;
20
+ readonly category: PluginCategory;
21
+ readonly version?: string;
22
+ readonly include?: readonly string[];
23
+ readonly exclude?: readonly string[];
24
+ readonly languages?: readonly Language[];
25
+ readonly tools?: Readonly<Record<string, string>>;
26
+ readonly optionsSchema?: boolean | Readonly<Record<string, unknown>>;
27
+ readonly requires?: {
28
+ readonly node?: string;
29
+ readonly repometry?: string;
30
+ readonly tools?: readonly string[];
31
+ };
32
+ readonly checks?: readonly Check[];
33
+ create(options: Options | undefined, context: {
34
+ readonly root: string;
35
+ }): PluginOperations | Promise<PluginOperations>;
36
+ }
37
+ interface PluginOperations {
38
+ readonly operations: readonly Operation[];
39
+ readonly produces: readonly ProductOutput[];
40
+ }
41
+ export declare function pluginCategory(plugin: Plugin): PluginCategory;
42
+ export declare function manifestPlugin({ id, category, languages, optionsSchema, tools, checks }: Omit<PluginManifest, 'create'>, version: string): Omit<Plugin, 'operations' | 'produces' | 'settings'>;
@@ -0,0 +1,18 @@
1
+ import { category } from '../model/inspection-category.js';
2
+ import { findingCategory } from './author-contracts.js';
3
+ import { pluginApi } from './plugin.js';
4
+ export const pluginManifestSchema = 'urn:repometry:schema:plugin:1';
5
+ export function pluginCategory(plugin) {
6
+ const categories = [category.language, category.source, category.security, category.coverage];
7
+ return categories.find(value => plugin.kinds.includes(value)) ?? category.maintainability;
8
+ }
9
+ const kindsByCategory = {
10
+ language: 'language', source: 'source', maintainability: 'analysis', coverage: 'coverage', security: 'security',
11
+ };
12
+ export function manifestPlugin({ id, category, languages, optionsSchema, tools, checks }, version) {
13
+ return { id, version, api: pluginApi, kinds: [kindsByCategory[category]], config: optionsSchema, tools,
14
+ ...(checks === undefined ? {} : { rules: checks.map(check => ({ ...check, category: findingCategory(category, check.defaults?.cost !== undefined) })) }),
15
+ ...(languages === undefined ? {} : { providesLanguages: languages.map(({ include, measures, ...language }) => ({ ...language, globs: include,
16
+ ...(measures === undefined ? {} : { measures: measures.map(measure => measure === 'checks' ? 'structuralRules' : measure) }) })) }) };
17
+ }
18
+ //# sourceMappingURL=plugin-manifest.js.map
@@ -67,5 +67,7 @@ export interface Plugin {
67
67
  readonly kinds: readonly PluginKind[];
68
68
  readonly claims?: FileClaims;
69
69
  readonly providesLanguages?: readonly ProvidedLanguage[];
70
+ /** Publish parser selectors and display metadata only when a snapshot contains its files. */
71
+ readonly languageProvenanceRequiresSource?: true;
70
72
  readonly produces: readonly ProductDeclaration[];
71
73
  }
@@ -1,20 +1,13 @@
1
- export { pluginApi } from './engine/plugin.js';
2
- export { plan } from './engine/plan.js';
3
- export type { InputBinding, PlanRequest, PlannedOperation } from './engine/plan.js';
4
- export { execute } from './engine/execute.js';
5
- export type { Outcome } from './engine/execute.js';
6
- export type { DataContract, InspectionInputs, Operation, Plugin, PluginConfigSchema, Product, RuleDescriptor } from './engine/plugin.js';
7
- export type { FileClaims, MetricDescriptor, MetricScope, PluginKind, ProductDeclaration } from './engine/plugin.js';
8
- export type { OperationCache, OperationCacheOptions } from './engine/operation-cache.js';
9
- export { codeStructure, codeStructures } from './model/code-structure.js';
10
- export type { CodeStructure, FunctionComplexity, StructureMeasure, StructuralCheck, StructuralObservation } from './model/code-structure.js';
11
- export type { LanguageDisplay, LanguageSyntax, ProvidedLanguage } from './model/language.js';
1
+ export { pluginManifestSchema } from './engine/plugin-manifest.js';
2
+ export type { Check, PluginCategory, PluginManifest, ProductOutput } from './engine/plugin-manifest.js';
3
+ export type { DataContract, InspectionInputs, MetricDescriptor, MetricScope, Operation } from './engine/plugin.js';
4
+ export { codeStructure, codeStructures, findingResult } from './engine/author-contracts.js';
5
+ export type { CodeStructure, Finding, FindingResult, StructuralObservation } from './engine/author-contracts.js';
6
+ export type { FunctionComplexity, StructuralCheck } from './model/code-structure.js';
7
+ export type { LanguageDisplay, LanguageSyntax } from './model/language.js';
12
8
  export type { Candidate, CloneSource } from './model/clone-source.js';
9
+ export type { FindingLocation } from './model/finding.js';
13
10
  export { sourceFile, sourceFiles } from './model/snapshot.js';
14
- export type { InventoryFile, SourceFile, SourceSnapshot } from './model/source.js';
11
+ export type { SourceFile } from './model/source.js';
15
12
  export { measurements } from './model/measurement.js';
16
13
  export type { Measurement } from './model/measurement.js';
17
- export { findingResult } from './model/finding.js';
18
- export type { Finding, FindingLocation, FindingResult } from './model/finding.js';
19
- export type { SourceContext, SourcePlugin, SourceProvider } from './ports/source-provider.js';
20
- export type { ToolInvocation, ToolResult, ToolRunner } from './ports/tool-runner.js';
@@ -1,8 +1,5 @@
1
- export { pluginApi } from './engine/plugin.js';
2
- export { plan } from './engine/plan.js';
3
- export { execute } from './engine/execute.js';
4
- export { codeStructure, codeStructures } from './model/code-structure.js';
1
+ export { pluginManifestSchema } from './engine/plugin-manifest.js';
2
+ export { codeStructure, codeStructures, findingResult } from './engine/author-contracts.js';
5
3
  export { sourceFile, sourceFiles } from './model/snapshot.js';
6
4
  export { measurements } from './model/measurement.js';
7
- export { findingResult } from './model/finding.js';
8
5
  //# sourceMappingURL=index.js.map
@@ -17,4 +17,5 @@ export declare const typescriptType: {
17
17
  };
18
18
  export declare const fileTypes: readonly FileType[];
19
19
  export declare function fileTypeId(path: string, fallback?: string): string;
20
+ export declare function canonicalFileTypeId(id: string): string;
20
21
  export {};
@@ -22,7 +22,7 @@ export const fileTypes = [
22
22
  { id: 'kotlin', label: 'Kotlin', color: '#a97bff', extensions: ['.kt', '.kts'] },
23
23
  { id: 'ruby', label: 'Ruby', color: '#701516', extensions: ['.rb'] },
24
24
  { id: 'php', label: 'PHP', color: '#4f5d95', extensions: ['.php'] },
25
- { id: 'c-sharp', label: 'C#', color: '#178600', extensions: ['.cs'] },
25
+ { id: 'csharp', label: 'C#', color: '#178600', extensions: ['.cs'] },
26
26
  { id: 'c', label: 'C', color: '#555555', extensions: ['.c', '.h'] },
27
27
  { id: 'cpp', label: 'C++', color: '#f34b7d', extensions: ['.cc', '.cpp', '.cxx', '.hpp', '.hh'] },
28
28
  { id: 'swift', label: 'Swift', color: '#f05138', extensions: ['.swift'] },
@@ -47,4 +47,7 @@ export function fileTypeId(path, fallback) {
47
47
  return exactNames.get(basename) ?? names.get(name) ?? names.get(name.split('.', 1)[0]) ?? extensions.get(extension)
48
48
  ?? fallback ?? (extension.slice(1) || 'other');
49
49
  }
50
+ export function canonicalFileTypeId(id) {
51
+ return id === 'c-sharp' ? 'csharp' : id;
52
+ }
50
53
  //# sourceMappingURL=file-types.js.map
@@ -1,8 +1,8 @@
1
1
  import type { Finding } from './finding.js';
2
- import type { FindingIgnoreRule, IgnoredFinding } from './ignore-rule.js';
2
+ import type { RecordedFindingIgnore, IgnoredFinding } from './ignore-rule.js';
3
3
  export type { FindingIgnoreRule, IgnoredFinding } from './ignore-rule.js';
4
- export declare function normalizeFindingIgnore(value: unknown): readonly FindingIgnoreRule[];
5
- export declare function partitionFindings(items: readonly Finding[], ignore: readonly FindingIgnoreRule[]): {
4
+ export declare function normalizeFindingIgnore(value: unknown): readonly RecordedFindingIgnore[];
5
+ export declare function partitionFindings(items: readonly Finding[], ignore: readonly RecordedFindingIgnore[]): {
6
6
  findings: readonly Finding[];
7
7
  ignoredFindings: readonly IgnoredFinding[];
8
8
  };
@@ -1,27 +1,39 @@
1
+ import { category as inspection } from './inspection-category.js';
1
2
  import { isRecord } from './plugin-data.js';
2
3
  import { exclusionMatcher, normalizeExclusions } from '../profile/exclusions.js';
3
- const fields = new Set(['tool', 'rule', 'path', 'reason']);
4
+ const fields = new Set(['tool', 'rule', 'path', 'reason', 'category']);
5
+ const inspectionCategory = {
6
+ structure: inspection.maintainability, duplication: inspection.maintainability, lint: inspection.maintainability,
7
+ security: 'security', dependency: 'security', secret: 'security', infrastructure: 'security',
8
+ };
4
9
  export function normalizeFindingIgnore(value) {
5
10
  if (!Array.isArray(value))
6
- throw new Error('Profile ignore must be an array of finding rules');
11
+ throw new Error('Recorded finding ignores must be an array');
7
12
  return value.map((item) => {
8
- if (!isRecord(item) || Object.entries(item).some(([key, value]) => !fields.has(key) || typeof value !== 'string' || value.trim() === '' || /[\0\r\n]/.test(value))) {
9
- throw new Error('Finding ignore rules accept tool, rule, path and reason strings');
13
+ if (!isRecord(item) || Object.entries(item).some(([key, value]) => !fields.has(key) || (key === 'path' && Array.isArray(value) ? !value.length || !value.every(validText) : !validText(value)))) {
14
+ throw new Error('Invalid recorded ignore entry');
10
15
  }
11
- const { tool, rule, path, reason } = item;
12
- if (tool === undefined && rule === undefined && path === undefined) {
13
- throw new Error('Choose at least one of tool, rule or path for a finding ignore rule');
16
+ const { tool, rule, path, reason, category } = item;
17
+ if (category !== undefined && ![inspection.maintainability, inspection.coverage, inspection.security].includes(category)) {
18
+ throw new Error('Invalid recorded ignore category');
19
+ }
20
+ if (tool === undefined && rule === undefined && path === undefined && category === undefined) {
21
+ throw new Error('A recorded finding ignore needs at least one plugin, check, path or category selector');
14
22
  }
15
23
  return { ...(tool !== undefined && { tool }), ...(rule !== undefined && { rule }),
16
- ...(path !== undefined && { path: normalizeExclusions([path])[0] }), ...(reason !== undefined && { reason }) };
24
+ ...(path !== undefined && { path: typeof path === 'string' ? normalizeExclusions([path])[0] : normalizeExclusions(path) }), ...(reason !== undefined && { reason }), ...(category !== undefined && { category }) };
17
25
  });
18
26
  }
27
+ function validText(value) {
28
+ return typeof value === 'string' && value.trim() !== '' && !/[\0\r\n]/.test(value);
29
+ }
19
30
  export function partitionFindings(items, ignore) {
20
31
  const findings = [];
21
32
  const ignoredFindings = [];
22
- const matches = ignore.map(({ tool, rule, path }) => {
23
- const matchesPath = path === undefined ? undefined : exclusionMatcher([path]);
33
+ const matches = ignore.map(({ tool, rule, path, category }) => {
34
+ const matchesPath = path === undefined ? undefined : exclusionMatcher(typeof path === 'string' ? [path] : path);
24
35
  return (item) => (tool === undefined || tool === item.tool) && (rule === undefined || rule === item.rule)
36
+ && (category === undefined || inspectionCategory[item.category] === category)
25
37
  && (matchesPath === undefined || (item.path !== undefined && matchesPath(item.path)));
26
38
  });
27
39
  for (const finding of items) {
@@ -1,8 +1,19 @@
1
+ import type { category } from './inspection-category.js';
1
2
  import type { Finding } from './finding.js';
3
+ export type InspectionIgnoreCategory = typeof category.maintainability | typeof category.security | typeof category.coverage;
2
4
  export interface FindingIgnoreRule {
5
+ readonly category?: InspectionIgnoreCategory;
6
+ readonly plugin?: string;
7
+ readonly check?: string;
8
+ readonly path?: string | readonly string[];
9
+ readonly reason: string;
10
+ }
11
+ /** Shape used in saved reports, including reports written before inspection categories. */
12
+ export interface RecordedFindingIgnore {
13
+ readonly category?: InspectionIgnoreCategory;
3
14
  readonly tool?: string;
4
15
  readonly rule?: string;
5
- readonly path?: string;
16
+ readonly path?: string | readonly string[];
6
17
  readonly reason?: string;
7
18
  }
8
19
  export interface IgnoredFinding {
@@ -0,0 +1,8 @@
1
+ export declare const category: {
2
+ readonly language: 'language';
3
+ readonly source: 'source';
4
+ readonly maintainability: 'maintainability';
5
+ readonly coverage: 'coverage';
6
+ readonly security: 'security';
7
+ };
8
+ export type PluginCategory = typeof category[keyof typeof category];
@@ -0,0 +1,8 @@
1
+ export const category = {
2
+ language: 'language',
3
+ source: 'source',
4
+ maintainability: 'maintainability',
5
+ coverage: 'coverage',
6
+ security: 'security',
7
+ };
8
+ //# sourceMappingURL=inspection-category.js.map
@@ -13,6 +13,8 @@ export interface SourceFile {
13
13
  export type SourceLineRange = readonly [first: number, last: number];
14
14
  export declare function isMergedLineRanges(value: unknown): value is readonly SourceLineRange[];
15
15
  export declare const maxClaimedFileBytes: number;
16
+ /** How much of a file's start is searched for the NUL byte that marks it as binary. */
17
+ export declare const binaryProbeBytes = 8192;
16
18
  export declare function isClaimedText(bytes: Uint8Array): boolean;
17
19
  export interface InventoryFile {
18
20
  readonly path: string;
@@ -14,7 +14,9 @@ export function isMergedLineRanges(value) {
14
14
  return true;
15
15
  }
16
16
  export const maxClaimedFileBytes = 1024 * 1024;
17
+ /** How much of a file's start is searched for the NUL byte that marks it as binary. */
18
+ export const binaryProbeBytes = 8192;
17
19
  export function isClaimedText(bytes) {
18
- return bytes.byteLength <= maxClaimedFileBytes && !bytes.subarray(0, 8192).includes(0);
20
+ return bytes.byteLength <= maxClaimedFileBytes && !bytes.subarray(0, binaryProbeBytes).includes(0);
19
21
  }
20
22
  //# sourceMappingURL=source.js.map
@@ -7,5 +7,5 @@ export declare const generatedSourcePolicy: {
7
7
  };
8
8
  /** Detect generated text by its source-map trailer or the density of its nonblank lines. */
9
9
  export declare function isGeneratedSource(bytes: Uint8Array): boolean;
10
- export declare function normalizeExclusions(value: unknown): readonly string[];
10
+ export declare function normalizeExclusions(value: unknown, field?: string): readonly string[];
11
11
  export declare function exclusionMatcher(patterns: readonly string[]): (path: string) => boolean;
@@ -19,16 +19,16 @@ export function isGeneratedSource(bytes) {
19
19
  const lines = source.split(/\r\n|[\n\r\u2028\u2029]/).map(line => line.trim()).filter(Boolean);
20
20
  return lines.reduce((sum, line) => sum + line.length, 0) > lines.length * generatedSourcePolicy.minMeanLineLength;
21
21
  }
22
- export function normalizeExclusions(value) {
22
+ export function normalizeExclusions(value, field = 'Profile exclude') {
23
23
  if (!Array.isArray(value))
24
- throw new Error('Profile exclude must be an array of repository-relative paths or globs');
24
+ throw new Error(`${field} must be an array of repository-relative paths or globs`);
25
25
  const patterns = new Set();
26
- for (const item of value) {
26
+ for (const [index, item] of value.entries()) {
27
27
  if (typeof item !== 'string')
28
- throw new Error('Each exclusion must be a string');
28
+ throw new Error(`${field}/${index} must be a string`);
29
29
  const pattern = item.replace(/^(?:\.\/)+/, '').replace(/\/+$/, '');
30
30
  if (!isRelativePath(pattern) || /[\\\0]/.test(pattern) || /^[#!]/.test(pattern)) {
31
- throw new Error(`Invalid source exclusion: ${JSON.stringify(item)}. Use a repository-relative path or glob.`);
31
+ throw new Error(`${field}/${index} must be a repository-relative path or glob. Received ${JSON.stringify(item)}.`);
32
32
  }
33
33
  patterns.add(pattern);
34
34
  }
@@ -0,0 +1,4 @@
1
+ import type { FindingIgnoreRule, RecordedFindingIgnore } from '../model/ignore-rule.js';
2
+ export declare function readIgnoreRules(value: unknown): readonly FindingIgnoreRule[];
3
+ export declare function recordIgnoreRules(entries: readonly FindingIgnoreRule[]): readonly RecordedFindingIgnore[];
4
+ export declare function coverageIgnore(entries: readonly RecordedFindingIgnore[]): ((path: string) => boolean) | undefined;
@@ -0,0 +1,82 @@
1
+ import { category } from '../model/inspection-category.js';
2
+ import { isRecord } from '../model/plugin-data.js';
3
+ import { exclusionMatcher, normalizeExclusions } from './exclusions.js';
4
+ const coveragePlugin = 'lcov';
5
+ export function readIgnoreRules(value) {
6
+ if (!Array.isArray(value))
7
+ throw new Error('Config ignore must be an array');
8
+ return value.map(readIgnore);
9
+ }
10
+ function readIgnore(value, index) {
11
+ const base = 'Config ignore/' + index;
12
+ if (!isRecord(value))
13
+ throw new Error(base + ' must be an object');
14
+ if (Object.hasOwn(value, 'tool'))
15
+ throw new Error(base + '/tool is renamed. Write plugin.');
16
+ if (Object.hasOwn(value, 'rule'))
17
+ throw new Error(base + '/rule is renamed. Write check.');
18
+ const unknown = Object.keys(value).find(key => !['category', 'plugin', 'check', 'path', 'reason'].includes(key));
19
+ if (unknown !== undefined)
20
+ throw new Error(base + ' accepts category, plugin, check, path and reason');
21
+ const category = readCategory(value.category, base);
22
+ const plugin = readText(value.plugin, base + '/plugin', 'must name a plugin or the reporter named in an imported finding');
23
+ const check = readText(value.check, base + '/check', 'must name a check');
24
+ const path = readPaths(value.path, base + '/path');
25
+ const reason = readText(value.reason, base + '/reason', 'must give a reason');
26
+ if (reason === undefined)
27
+ throw new Error(base + '/reason is required');
28
+ if ([category, plugin, check, path].every(selector => selector === undefined)) {
29
+ throw new Error(base + ' needs at least one of category, plugin, check or path');
30
+ }
31
+ if (category === 'coverage')
32
+ validateCoverage(plugin, check, path, base);
33
+ return { ...(category === undefined ? {} : { category }), ...(plugin === undefined ? {} : { plugin }),
34
+ ...(check === undefined ? {} : { check }), ...(path === undefined ? {} : { path }), reason };
35
+ }
36
+ function validateCoverage(plugin, check, path, base) {
37
+ if (check !== undefined)
38
+ throw new Error(base + '/check is unavailable for coverage because coverage has no findings');
39
+ if (plugin !== undefined && plugin !== coveragePlugin)
40
+ throw new Error(base + '/plugin must be lcov for coverage');
41
+ if (path === undefined)
42
+ throw new Error(base + '/path is required for coverage to identify the files to exclude');
43
+ }
44
+ function readCategory(value, base) {
45
+ if (value === undefined || value === category.maintainability || value === category.security || value === category.coverage)
46
+ return value;
47
+ throw new Error(base + '/category must be maintainability, coverage or security');
48
+ }
49
+ function readText(value, path, expectation) {
50
+ if (value === undefined)
51
+ return undefined;
52
+ if (typeof value !== 'string' || !value.trim() || /[\0\r\n]/.test(value))
53
+ throw new Error(path + ' ' + expectation);
54
+ return value;
55
+ }
56
+ function readPaths(value, field) {
57
+ if (value === undefined)
58
+ return undefined;
59
+ const list = typeof value === 'string' ? [value] : value;
60
+ if (!Array.isArray(list) || list.length === 0 || list.some(path => typeof path !== 'string' || /[\0\r\n]/.test(path))) {
61
+ throw new Error(field + ' must be a glob or a nonempty list of globs');
62
+ }
63
+ let paths;
64
+ try {
65
+ paths = normalizeExclusions(list);
66
+ }
67
+ catch (error) {
68
+ throw new Error(field + ' must use repository-relative globs', { cause: error });
69
+ }
70
+ return typeof value === 'string' ? paths[0] : paths;
71
+ }
72
+ export function recordIgnoreRules(entries) {
73
+ return entries.map(({ category, plugin, check, path, reason }) => ({
74
+ ...(plugin === undefined ? {} : { tool: plugin }), ...(check === undefined ? {} : { rule: check }),
75
+ ...(path === undefined ? {} : { path }), reason, ...(category === undefined ? {} : { category }),
76
+ }));
77
+ }
78
+ export function coverageIgnore(entries) {
79
+ const paths = entries.filter(({ category }) => category === 'coverage').flatMap(({ path }) => path ?? []);
80
+ return paths.length ? exclusionMatcher(paths) : undefined;
81
+ }
82
+ //# sourceMappingURL=ignore.js.map
@@ -1,11 +1,11 @@
1
1
  import { isRecord } from '../engine/plugin.js';
2
- import { normalizeFindingIgnore } from '../model/finding-ignore.js';
2
+ import { readIgnoreRules } from './ignore.js';
3
3
  import { normalizeExclusions } from './exclusions.js';
4
4
  export function normalizeProfile(profile) {
5
5
  if (!isRecord(profile) || Object.keys(profile).some(key => key !== 'exclude' && key !== 'ignore')) {
6
6
  throw new Error('Expected a JSON profile with optional exclude and ignore arrays');
7
7
  }
8
8
  return { exclude: normalizeExclusions(profile.exclude === undefined ? [] : profile.exclude),
9
- ignore: normalizeFindingIgnore(profile.ignore === undefined ? [] : profile.ignore) };
9
+ ignore: readIgnoreRules(profile.ignore === undefined ? [] : profile.ignore) };
10
10
  }
11
11
  //# sourceMappingURL=profile.js.map
@@ -6,6 +6,7 @@ export interface AnalysisInput {
6
6
  readonly snapshot: SourceSnapshot;
7
7
  readonly excludedOutput: string | null;
8
8
  readonly excludedPaths?: readonly string[];
9
+ readonly ignoresCoverage?: (path: string) => boolean;
9
10
  readonly coverage?: {
10
11
  readonly text: string;
11
12
  readonly sourceRoot: string;
@@ -1,17 +1,18 @@
1
1
  import { isDeepStrictEqual } from 'node:util';
2
2
  import { isRecord } from '../engine/plugin.js';
3
- import { normalizeFindingIgnore, partitionFindings } from '../model/finding-ignore.js';
3
+ import { partitionFindings } from '../model/finding-ignore.js';
4
4
  import { reportSchema } from '../model/report.js';
5
5
  import { digest } from '../model/snapshot.js';
6
6
  import { normalizeExclusions, sourceExclusionMatcher } from '../profile/exclusions.js';
7
+ import { coverageIgnore, readIgnoreRules, recordIgnoreRules } from '../profile/ignore.js';
7
8
  export async function executeInspection(options, ports) {
8
9
  const excludedPaths = normalizeExclusions(options.exclude ?? []);
9
- const ignore = normalizeFindingIgnore(options.ignore ?? []);
10
+ const ignore = recordIgnoreRules(readIgnoreRules(options.ignore ?? []));
10
11
  const source = await ports.readSource(sourceExclusionMatcher(excludedPaths));
11
12
  const { snapshot, root, excludedOutput } = source;
12
13
  const lcov = await ports.readCoverage?.(source);
13
14
  const report = await ports.analyze({
14
- snapshot, excludedOutput, excludedPaths,
15
+ snapshot, excludedOutput, excludedPaths, ignoresCoverage: coverageIgnore(ignore),
15
16
  coverage: lcov === undefined ? undefined : { text: lcov.text, sourceRoot: root },
16
17
  });
17
18
  if (report.subject.kind !== snapshot.subject.kind || report.subject.id !== snapshot.subject.id) {
@@ -24,14 +25,19 @@ export async function executeInspection(options, ports) {
24
25
  const covered = lcov && lcov.inputDigests.length > 1 ? withLcovDigests(report, lcov) : report;
25
26
  const findings = ports.importFindings
26
27
  ? await ports.importFindings(covered, root, sourceExclusionMatcher(excludedPaths, snapshot.generatedExcluded)) : covered;
27
- const filtered = ignore.length === 0 ? findings : { ...findings, schema: reportSchema,
28
- appliedConfig: { ...findings.appliedConfig, findingIgnore: ignore },
29
- ...(findings.findings === undefined ? {} : partitionFindings(findings.findings, ignore)) };
28
+ const filtered = applyIgnore(findings, ignore);
30
29
  const result = snapshot.subject.kind === 'commit' && ports.recordChurn
31
30
  ? await ports.recordChurn(filtered, root, snapshot.files.map(file => file.path)) : filtered;
32
31
  await source.save(result);
33
32
  return result;
34
33
  }
34
+ function applyIgnore(report, ignore) {
35
+ if (ignore.length === 0)
36
+ return report;
37
+ return { ...report, schema: reportSchema,
38
+ appliedConfig: { ...report.appliedConfig, findingIgnore: ignore },
39
+ ...(report.findings === undefined ? {} : partitionFindings(report.findings, ignore)) };
40
+ }
35
41
  function withLcovDigests(report, { text, inputDigests }) {
36
42
  const coverage = report.appliedConfig.coverage;
37
43
  if (!isRecord(coverage) || coverage.inputDigest !== digest(text)) {
@@ -3,7 +3,7 @@ import { isRecord } from '../model/plugin-data.js';
3
3
  import { classifyIssues, debtEffect } from './review-effect.js';
4
4
  export const coverageDefaults = { minimumPercent: 80, minimumLines: 20 };
5
5
  const hostOperations = new Set(['git/churn', 'source/claims']);
6
- const settingsNote = 'This change edits Repometry settings, which can hide issues from this check.';
6
+ const settingsNote = 'This change edits the Repometry configuration, which can hide issues from this check.';
7
7
  export function projectReview(options, inputs) {
8
8
  checkOptions(options, inputs.coverage !== null);
9
9
  const { number, maxNewIssues = 0 } = options;