@cplieger/deadset-ts 8.0.0-dev.7 → 8.0.0-dev.8

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 (78) hide show
  1. package/dist/bin/node-host.js +21 -3
  2. package/dist/src/analysis.js +13 -14
  3. package/dist/src/config.js +6 -83
  4. package/dist/src/configured-declarations.js +15 -20
  5. package/dist/src/consumers.js +2 -2
  6. package/dist/src/contract/config.generated.js +544 -0
  7. package/dist/src/contract/report.generated.js +3 -2
  8. package/dist/src/discover.js +1 -1
  9. package/dist/src/edges.js +36 -112
  10. package/dist/src/exempt-classes.js +0 -2
  11. package/dist/src/exempt.js +1 -1
  12. package/dist/src/findings/completion.js +5 -4
  13. package/dist/src/findings/emitters.js +1 -1
  14. package/dist/src/findings/intra-function.js +1 -1
  15. package/dist/src/findings/non-code-artifacts.js +2 -2
  16. package/dist/src/findings/unused-declarations.js +1 -1
  17. package/dist/src/findings/visibility-narrowing.js +2 -2
  18. package/dist/src/findings-pass.js +1 -1
  19. package/dist/src/framework-lifecycle.js +7 -7
  20. package/dist/src/fs/document.js +59 -0
  21. package/dist/src/injection-container.js +1 -1
  22. package/dist/src/json-document.js +194 -67
  23. package/dist/src/kinds.js +0 -7
  24. package/dist/src/print.js +10 -79
  25. package/dist/src/report-schema.js +3 -224
  26. package/dist/src/resolve.js +245 -715
  27. package/dist/src/run.js +48 -55
  28. package/dist/src/schema.js +320 -344
  29. package/dist/src/scope.js +33 -101
  30. package/dist/src/serialization-contract.js +1 -1
  31. package/dist/src/suppress-file.js +15 -17
  32. package/dist/src/suppress.js +3 -3
  33. package/dist/src/template-field.js +4 -4
  34. package/dist/src/usage.js +10 -0
  35. package/dist/src/verbs/analyze.js +12 -15
  36. package/dist/src/verbs/explain.js +3 -3
  37. package/dist/src/verbs/print-projects.js +2 -2
  38. package/jsr.json +1 -1
  39. package/package.json +1 -1
  40. package/src/analysis.ts +30 -26
  41. package/src/config.ts +31 -298
  42. package/src/configured-declarations.ts +18 -23
  43. package/src/consumers.ts +4 -4
  44. package/src/contract/config.generated.ts +798 -0
  45. package/src/contract/report.generated.ts +3 -2
  46. package/src/discover.ts +1 -1
  47. package/src/edges.ts +39 -124
  48. package/src/exempt-classes.ts +0 -5
  49. package/src/exempt.ts +4 -4
  50. package/src/findings/completion.ts +5 -6
  51. package/src/findings/emitter.ts +2 -2
  52. package/src/findings/emitters.ts +1 -1
  53. package/src/findings/intra-function.ts +1 -1
  54. package/src/findings/non-code-artifacts.ts +4 -4
  55. package/src/findings/unused-declarations.ts +1 -1
  56. package/src/findings/visibility-narrowing.ts +2 -2
  57. package/src/findings-pass.ts +3 -3
  58. package/src/framework-lifecycle.ts +7 -7
  59. package/src/fs/document.ts +74 -0
  60. package/src/host.ts +12 -5
  61. package/src/injection-container.ts +1 -1
  62. package/src/json-document.ts +236 -76
  63. package/src/kinds.ts +0 -8
  64. package/src/print.ts +11 -92
  65. package/src/report-schema.ts +3 -299
  66. package/src/resolve.ts +281 -1105
  67. package/src/run.ts +50 -63
  68. package/src/schema.ts +391 -389
  69. package/src/scope.ts +39 -119
  70. package/src/serialization-contract.ts +1 -1
  71. package/src/suppress-file.ts +15 -20
  72. package/src/suppress.ts +3 -3
  73. package/src/template-field.ts +10 -7
  74. package/src/usage.ts +10 -0
  75. package/src/verbs/analyze.ts +12 -23
  76. package/src/verbs/explain.ts +3 -7
  77. package/src/verbs/print-projects.ts +2 -2
  78. package/src/verbs/verb.ts +2 -2
@@ -1,770 +1,300 @@
1
- import { SEVERITIES, LANGUAGES, CONFIDENCES, FORMATS, FAMILY_KEY_LENGTH, } from "./contract/contract.generated.js";
2
- import { ConfigError, defaultConfig, } from "./config.js";
1
+ import { SETTINGS } from "./contract/config.generated.js";
2
+ import { FAMILY_KEY_LENGTH } from "./contract/contract.generated.js";
3
+ import {} from "./config.js";
3
4
  import { CONVENTION_ROWS } from "./convention-rows.js";
4
- import { EXEMPTION_CLASS_NAMES } from "./exempt-classes.js";
5
- import { FIXED_SEVERITY_CODES, LIVE_CODES } from "./kinds.js";
6
- import { checkDocument, malformed, nestFlags, SCHEMA_ROOT, SEVERITY_SECTION, } from "./schema.js";
5
+ import { refuseOverBound } from "./fs/document.js";
6
+ import { dotted, isRecord, locatedFault, placeIn, pointerOf, readStrict, StrictJSONError, } from "./json-document.js";
7
+ import { FIXED_SEVERITY_CODES } from "./kinds.js";
8
+ import { LANGUAGE } from "./product.js";
9
+ import { firstRefusal } from "./schema.js";
7
10
  import { bytewise } from "./text/compare.js";
8
- import { isRecord } from "./json-document.js";
9
- import { message } from "./product.js";
10
- /** Names the command-line flags in a refusal, where a document is named by its path. */
11
- const FLAGS_LABEL = "the command-line flags";
12
- const SEVERITY_KEY = /^DS[0-9]{2}([0-9]{2})?$/u;
13
- const CONTRACT_VERSION_PATTERN = /^[0-9]+\.[0-9]+\.[0-9]+$/u;
14
- const ANALYZER_NAME = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/u;
15
- const PROVIDER_SOURCE = /^(go|npm):[^ \t\r\n]+$/u;
16
- const PROVIDER_VERSION = /^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$/u;
17
- const PROVIDER_DIGEST = /^sha256:[0-9a-f]{64}$/u;
18
- /** The members only an acquirable provider entry carries. */
19
- const ACQUIRABLE_MEMBERS = ["source", "version", "digest"];
20
- /** The members only a platform build configuration carries. */
21
- const PLATFORM_MEMBERS = ["os", "arch", "tags"];
22
- /** The member only a project build configuration carries. */
23
- const PROJECT_MEMBER = "project";
11
+ import { UsageError } from "./usage.js";
12
+ const ROWS = new Map(SETTINGS.map((row) => [row.key, row]));
13
+ /** The schema of a section or a keyed section's value, so the validator words its refusal. */
14
+ const OBJECT = { type: "object" };
24
15
  /**
25
- * One segment of a project path: not empty, not `.` or `..`, and holding no
26
- * solidus or control character.
16
+ * The settings whose entries name rows of this analyzer's own data, which the
17
+ * Contract's schema cannot list: a disabled convention names a convention row.
27
18
  */
28
- const PROJECT_SEGMENT = String.raw `(?:[^/.\x00-\x1f\x7f][^/\x00-\x1f\x7f]*|\.[^/.\x00-\x1f\x7f][^/\x00-\x1f\x7f]*|\.\.[^/\x00-\x1f\x7f]+)`;
29
- /**
30
- * A project path: segments joined by a solidus, so the path is relative, below
31
- * the root it is read against, and spelled one way on every machine.
32
- */
33
- const PROJECT_PATH = new RegExp(`^${PROJECT_SEGMENT}(?:/${PROJECT_SEGMENT})*$`, "u");
34
- const TARGET_KINDS = ["application", "library"];
35
- const GENERATED_FILES = ["exclude", "include"];
36
- const CONSUMER_TESTS = ["test", "production"];
37
- const SORTS = ["position", "size"];
38
- const CASCADES = ["roots", "full"];
39
- /**
40
- * The origin one setting of this source carries. A flag names itself per setting,
41
- * because one invocation carries many.
42
- */
43
- function originOf(source, path) {
44
- if (source.kind === "flag") {
45
- return { source: "flag", label: source.flagLabels.get(path) ?? "" };
46
- }
47
- return { source: source.kind, label: source.label };
48
- }
49
- function member(parent, name) {
50
- if (parent === undefined || !Object.hasOwn(parent, name)) {
51
- return undefined;
52
- }
53
- return parent[name];
54
- }
55
- function section(parent, name, path, label) {
56
- const value = member(parent, name);
57
- if (value === undefined) {
58
- return undefined;
19
+ const OWN_VOCABULARIES = new Map([
20
+ ["ts.disabled_conventions", new Set(CONVENTION_ROWS.map((row) => row.name))],
21
+ ]);
22
+ function malformed(label, path, detail) {
23
+ return new UsageError(path === "" ? `${label}: ${detail}` : `${label}: ${path}: ${detail}`);
24
+ }
25
+ /** A key the closed key list does not declare, with the reason where there is more to say. */
26
+ function unimplemented(label, path, reason = "") {
27
+ const why = reason === "" ? "" : `: ${reason}`;
28
+ return new UsageError(`${label}: key ${JSON.stringify(path)} is not implemented${why}`);
29
+ }
30
+ /** Why a well-formed severity key the vocabulary does not hold names no setting. */
31
+ function severityKeyRefused(key) {
32
+ const fixed = FIXED_SEVERITY_CODES.filter((code) => code === key || (key.length === FAMILY_KEY_LENGTH && code.startsWith(key))).sort(bytewise);
33
+ if (fixed.length > 0) {
34
+ const named = fixed.length < 2
35
+ ? fixed.join("")
36
+ : `${fixed.slice(0, -1).join(", ")} and ${String(fixed.at(-1))}`;
37
+ return `the Contract fixes the severity of ${named}, which this key names`;
38
+ }
39
+ return key.length === FAMILY_KEY_LENGTH
40
+ ? `no issue kind carries a code of the family ${key}`
41
+ : `no issue kind carries the code ${key}`;
42
+ }
43
+ /** A value with every object's members in ascending order, so it prints one way. */
44
+ function canonical(value) {
45
+ if (Array.isArray(value)) {
46
+ return value.map(canonical);
59
47
  }
60
48
  if (!isRecord(value)) {
61
- throw malformed(label, path, "is not an object");
62
- }
63
- return value;
64
- }
65
- function spell(values) {
66
- return values.map((value) => JSON.stringify(value)).join(", ");
67
- }
68
- function readEnum(parent, name, path, label, allowed) {
69
- const value = member(parent, name);
70
- if (value === undefined) {
71
- return undefined;
72
- }
73
- if (typeof value !== "string") {
74
- throw malformed(label, path, "is not a string");
75
- }
76
- if (!allowed.includes(value)) {
77
- throw malformed(label, path, `${JSON.stringify(value)} is not one of ${spell(allowed)}`);
78
- }
79
- return value;
80
- }
81
- function readString(parent, name, path, label) {
82
- const value = member(parent, name);
83
- if (value === undefined) {
84
- return undefined;
85
- }
86
- if (typeof value !== "string") {
87
- throw malformed(label, path, "is not a string");
88
- }
89
- return value;
90
- }
91
- function readBoolean(parent, name, path, label) {
92
- const value = member(parent, name);
93
- if (value === undefined) {
94
- return undefined;
95
- }
96
- if (typeof value !== "boolean") {
97
- throw malformed(label, path, "is not a boolean");
98
- }
99
- return value;
100
- }
101
- function readCount(parent, name, path, label) {
102
- const value = member(parent, name);
103
- if (value === undefined) {
104
- return undefined;
105
- }
106
- if (typeof value !== "number" || !Number.isInteger(value)) {
107
- throw malformed(label, path, "is not an integer");
108
- }
109
- if (value < 0) {
110
- throw malformed(label, path, `${String(value)} is below the minimum of 0`);
49
+ return value;
111
50
  }
112
- return value;
51
+ return Object.fromEntries(Object.keys(value)
52
+ .sort(bytewise)
53
+ .map((name) => [name, canonical(value[name])]));
113
54
  }
114
55
  /**
115
- * One array of strings, refusing an array shorter than its minimum, one holding an
116
- * empty entry, one naming an entry twice, and, where a closed set is given, one
117
- * holding an entry outside it.
56
+ * The walk of one source over the closed key list. The members of an object are checked
57
+ * in ascending order and a key is checked whole before the next. A key this analyzer's
58
+ * language does not read is accepted unread, and of a key written per language, every
59
+ * other language's member.
118
60
  */
119
- function readStrings(parent, name, path, label, minItems, allowed) {
120
- const value = member(parent, name);
121
- if (value === undefined) {
122
- return undefined;
123
- }
124
- if (!Array.isArray(value)) {
125
- throw malformed(label, path, "is not an array");
126
- }
127
- if (value.length < minItems) {
128
- throw malformed(label, path, `holds ${String(value.length)} entries, want at least ${String(minItems)}`);
129
- }
130
- const seen = new Set();
131
- for (const [index, entry] of value.entries()) {
132
- const at = `${path}[${String(index)}]`;
133
- if (typeof entry !== "string") {
134
- throw malformed(label, at, "is not a string");
61
+ class Walk {
62
+ label;
63
+ fractions;
64
+ into;
65
+ constructor(label, fractions, into) {
66
+ this.label = label;
67
+ this.fractions = fractions;
68
+ this.into = into;
69
+ }
70
+ section(at, members) {
71
+ for (const name of Object.keys(members).sort(bytewise)) {
72
+ const key = at === "" ? name : `${at}.${name}`;
73
+ const row = ROWS.get(key);
74
+ if (name.includes(".")) {
75
+ const reason = row === undefined ? "" : "it is one setting, written as nested objects";
76
+ throw unimplemented(this.label, key, reason);
77
+ }
78
+ if (row === undefined) {
79
+ throw unimplemented(this.label, key);
80
+ }
81
+ if (row.read) {
82
+ this.key(row, members[name]);
83
+ }
135
84
  }
136
- if (entry === "") {
137
- throw malformed(label, at, "is empty");
85
+ }
86
+ key(row, value) {
87
+ if (row.role === "section") {
88
+ this.refuse(row.key.split("."), value, firstRefusal(OBJECT, value));
89
+ this.section(row.key, value);
138
90
  }
139
- if (seen.has(entry)) {
140
- throw malformed(label, at, `names ${JSON.stringify(entry)} again`);
91
+ else if (row.role === "setting") {
92
+ const read = row.perLanguage === undefined ? value : this.narrowed(row, value);
93
+ this.setting(row, read);
94
+ this.into.values.set(row.key, canonical(read));
141
95
  }
142
- if (allowed !== undefined && !allowed.includes(entry)) {
143
- throw malformed(label, at, `${JSON.stringify(entry)} is not one of ${spell(allowed)}`);
96
+ else {
97
+ const members = this.keyed(row, value);
98
+ if (row.role === "keyed") {
99
+ this.into.keyed.set(row.key, members);
100
+ }
144
101
  }
145
- seen.add(entry);
146
- }
147
- return value;
148
- }
149
- /**
150
- * The target kind, a string or an object naming every language. The walk has
151
- * already refused an undeclared member, so an object is refused for the first
152
- * language it leaves out, then for the first language whose value is refused,
153
- * each in the vocabulary's language order.
154
- */
155
- function readTargetKind(target, label) {
156
- const value = member(target, "kind");
157
- const perLanguage = `an object naming the kind of each of ${spell(LANGUAGES)}`;
158
- if (value === undefined) {
159
- return undefined;
160
102
  }
161
- if (typeof value === "string") {
162
- if (!TARGET_KINDS.includes(value)) {
163
- throw malformed(label, "target.kind", `${JSON.stringify(value)} is not one of ${spell(TARGET_KINDS)}, nor ${perLanguage}`);
103
+ /** A per-language value as this language reads it: of the object form, its own member alone. */
104
+ narrowed(row, value) {
105
+ if (!isRecord(value)) {
106
+ return value;
164
107
  }
165
- return value;
166
- }
167
- if (!isRecord(value)) {
168
- throw malformed(label, "target.kind", `${JSON.stringify(value)} is neither one of ${spell(TARGET_KINDS)} nor ${perLanguage}`);
169
- }
170
- const missing = LANGUAGES.find((language) => !Object.hasOwn(value, language));
171
- if (missing !== undefined) {
172
- throw malformed(label, `target.kind.${missing}`, `is not set, and ${perLanguage} names each`);
173
- }
174
- for (const language of LANGUAGES) {
175
- const kind = value[language];
176
- if (typeof kind !== "string" || !TARGET_KINDS.includes(kind)) {
177
- throw malformed(label, `target.kind.${language}`, `${JSON.stringify(kind)} is not one of ${spell(TARGET_KINDS)}`);
108
+ const others = row.perLanguage ?? [];
109
+ return Object.fromEntries(Object.entries(value).filter(([name]) => name === LANGUAGE || !others.includes(name)));
110
+ }
111
+ setting(row, value) {
112
+ this.refuse(row.key.split("."), value, firstRefusal(row.value ?? {}, value));
113
+ const text = this.fractions.get(pointerOf(row.key.split(".")));
114
+ if (typeof value === "number" && text !== undefined) {
115
+ throw malformed(this.label, row.key, `holds ${text}, want an integer written as an optional minus sign and digits alone`);
178
116
  }
179
- }
180
- return { go: value["go"], ts: value["ts"] };
181
- }
182
- /** A component file's extension: a full stop followed by letters and digits. */
183
- const COMPONENT_EXTENSION = /^\.[A-Za-z0-9]+$/u;
184
- function readComponentExtensions(ts, label) {
185
- const extensions = readStrings(ts, "component_extensions", "ts.component_extensions", label, 0);
186
- const wrong = extensions?.findIndex((one) => !COMPONENT_EXTENSION.test(one)) ?? -1;
187
- if (extensions !== undefined && wrong !== -1) {
188
- throw malformed(label, `ts.component_extensions[${String(wrong)}]`, `${JSON.stringify(extensions[wrong])} is not a full stop followed by letters and digits`);
189
- }
190
- return extensions;
191
- }
192
- /** The names of the convention rows this analyzer's table carries. */
193
- const CONVENTION_NAMES = new Set(CONVENTION_ROWS.map((row) => row.name));
194
- function readDisabledConventions(ts, label) {
195
- const names = readStrings(ts, "disabled_conventions", "ts.disabled_conventions", label, 0);
196
- const unknown = names?.findIndex((one) => !CONVENTION_NAMES.has(one)) ?? -1;
197
- if (names !== undefined && unknown !== -1) {
198
- throw malformed(label, `ts.disabled_conventions[${String(unknown)}]`, `${JSON.stringify(names[unknown])} names no convention row this analyzer carries`);
199
- }
200
- return names;
201
- }
202
- function requireMember(value, path, label) {
203
- if (value === undefined || value === "") {
204
- throw malformed(label, path, "is required and names nothing");
205
- }
206
- return value;
207
- }
208
- /** One build configuration entry as a platform: an identifier, an operating system and an architecture. */
209
- function readPlatform(entry, at, label) {
210
- return {
211
- shape: "platform",
212
- id: requireMember(readString(entry, "id", `${at}.id`, label), `${at}.id`, label),
213
- os: requireMember(readString(entry, "os", `${at}.os`, label), `${at}.os`, label),
214
- arch: requireMember(readString(entry, "arch", `${at}.arch`, label), `${at}.arch`, label),
215
- tags: readStrings(entry, "tags", `${at}.tags`, label, 0) ?? [],
216
- };
217
- }
218
- /** One build configuration entry as a project: an identifier and a configuration file below the target root. */
219
- function readProject(entry, at, label) {
220
- const id = requireMember(readString(entry, "id", `${at}.id`, label), `${at}.id`, label);
221
- const path = `${at}.${PROJECT_MEMBER}`;
222
- const project = requireMember(readString(entry, PROJECT_MEMBER, path, label), path, label);
223
- if (!PROJECT_PATH.test(project)) {
224
- throw malformed(label, path, `${JSON.stringify(project)} is not a path below the target root: segments joined by /, ` +
225
- "none empty, . or .., and no control character");
226
- }
227
- return { shape: "project", id, project };
228
- }
229
- /**
230
- * One build configuration entry, read as the one shape its members name: a member
231
- * only a platform carries makes it a platform, the member only a project carries
232
- * makes it a project, and an entry naming members of both, or of neither, is
233
- * refused at the entry, because the two shapes are exclusive.
234
- */
235
- function readConfiguration(entry, at, label) {
236
- if (!isRecord(entry)) {
237
- throw malformed(label, at, "is not an object");
238
- }
239
- const platform = PLATFORM_MEMBERS.filter((name) => Object.hasOwn(entry, name));
240
- const project = Object.hasOwn(entry, PROJECT_MEMBER);
241
- if (platform.length > 0 && project) {
242
- throw malformed(label, at, `carries ${spell(platform)} of a platform and ${JSON.stringify(PROJECT_MEMBER)} of a ` +
243
- "project, and an entry is one shape or the other");
244
- }
245
- if (project) {
246
- return readProject(entry, at, label);
247
- }
248
- if (platform.length === 0) {
249
- throw malformed(label, at, `names neither a platform's "os" and "arch" nor a project's ${JSON.stringify(PROJECT_MEMBER)}`);
250
- }
251
- return readPlatform(entry, at, label);
252
- }
253
- /** The build matrix, one entry in one shape at a time. */
254
- function readConfigurations(analysis, label) {
255
- const value = member(analysis, "configurations");
256
- if (value === undefined) {
257
- return undefined;
258
- }
259
- if (!Array.isArray(value)) {
260
- throw malformed(label, "analysis.configurations", "is not an array");
261
- }
262
- return value.map((entry, index) => readConfiguration(entry, `analysis.configurations[${String(index)}]`, label));
263
- }
264
- /**
265
- * The action delimiter pair: once a document names the object both members are
266
- * required, because a pair carrying one member names no delimiters at all, so the
267
- * refusal names the member the document left out rather than pairing the one it
268
- * named with a default.
269
- */
270
- function readDelimiters(analysis, label) {
271
- const at = "analysis.template_delimiters";
272
- const pair = section(analysis, "template_delimiters", at, label);
273
- if (pair === undefined) {
274
- return undefined;
275
- }
276
- return {
277
- left: requireMember(readString(pair, "left", `${at}.left`, label), `${at}.left`, label),
278
- right: requireMember(readString(pair, "right", `${at}.right`, label), `${at}.right`, label),
279
- };
280
- }
281
- /**
282
- * A severity key that names no setting: it names no live kind, or the Contract
283
- * fixes the severity of the kind or kinds it names.
284
- */
285
- function unimplementedSeverityKey(label, path, reason) {
286
- return new ConfigError("unimplemented-key", path, `${label}: key ${JSON.stringify(path)} is not implemented: ${reason}`);
287
- }
288
- /**
289
- * Every code whose severity the Contract fixes that one severity key names, in
290
- * ascending code order: the code itself, or every code of the family its
291
- * two-digit prefix names. A family key covers every such code, so a refusal names
292
- * them all rather than the first one found.
293
- */
294
- function fixedByContract(code) {
295
- return FIXED_SEVERITY_CODES.filter((candidate) => code === candidate || (code.length === FAMILY_KEY_LENGTH && candidate.startsWith(code))).sort(bytewise);
296
- }
297
- /** The codes a refusal names: one on its own, and several with the last joined by and. */
298
- function spellCodes(codes) {
299
- if (codes.length < 2) {
300
- return codes.join("");
301
- }
302
- return `${codes.slice(0, -1).join(", ")} and ${String(codes[codes.length - 1])}`;
303
- }
304
- /** Whether one severity key names a live kind: the code itself, or a family holding one. */
305
- function namesLiveKind(code) {
306
- return LIVE_CODES.some((candidate) => code === candidate || (code.length === FAMILY_KEY_LENGTH && candidate.startsWith(code)));
307
- }
308
- /**
309
- * The severity object, one code at a time.
310
- *
311
- * A key is one issue-kind code or one two-digit family prefix. A key naming no
312
- * live kind, and a key naming a kind whose severity the Contract fixes or a family
313
- * prefix whose range holds one, is an unimplemented key rather than a setting.
314
- *
315
- * Whether a key names a kind this analyzer reports is not decided here: a live
316
- * kind of another language is a setting the analyzer of that language reads.
317
- */
318
- function readSeverity(document, label) {
319
- const object = section(document, SEVERITY_SECTION, SEVERITY_SECTION, label);
320
- if (object === undefined) {
321
- return undefined;
322
- }
323
- const severity = new Map();
324
- for (const code of Object.keys(object).sort(bytewise)) {
325
- const path = `${SEVERITY_SECTION}.${code}`;
326
- if (!SEVERITY_KEY.test(code)) {
327
- throw unimplementedSeverityKey(label, path, "a severity key is one issue-kind code or one two-digit family prefix");
117
+ const own = OWN_VOCABULARIES.get(row.key);
118
+ if (own !== undefined) {
119
+ const names = value;
120
+ const unknown = names.findIndex((name) => !own.has(name));
121
+ if (unknown !== -1) {
122
+ throw malformed(this.label, `${row.key}[${String(unknown)}]`, `${JSON.stringify(names[unknown])} names no row this analyzer carries`);
123
+ }
328
124
  }
329
- if (!namesLiveKind(code)) {
330
- throw unimplementedSeverityKey(label, path, code.length === FAMILY_KEY_LENGTH
331
- ? "the family this prefix names holds no live issue kind"
332
- : "the code names no live issue kind");
125
+ }
126
+ /** A keyed or an ignored section: an object whose member names its key pattern admits. */
127
+ keyed(row, value) {
128
+ this.refuse(row.key.split("."), value, firstRefusal(OBJECT, value));
129
+ const members = value;
130
+ const shape = new RegExp(row.keyPattern ?? "", "u");
131
+ for (const name of Object.keys(members).sort(bytewise)) {
132
+ const at = `${row.key}.${name}`;
133
+ if (!shape.test(name)) {
134
+ throw unimplemented(this.label, at, `the name does not match ${String(row.keyPattern)}`);
135
+ }
136
+ if (row.values !== undefined && !row.values.includes(name)) {
137
+ throw unimplemented(this.label, at, severityKeyRefused(name));
138
+ }
139
+ const member = members[name];
140
+ this.refuse([...row.key.split("."), name], member, firstRefusal(row.value ?? {}, member));
333
141
  }
334
- const fixed = fixedByContract(code);
335
- if (fixed.length > 0) {
336
- throw unimplementedSeverityKey(label, path, `the Contract fixes the severity of ${spellCodes(fixed)}, which this key names`);
142
+ return members;
143
+ }
144
+ /** Throws the refusal the schema makes of `value`, at `at`, naming the place inside it. */
145
+ refuse(at, value, refused) {
146
+ if (refused === undefined) {
147
+ return;
337
148
  }
338
- const value = readEnum(object, code, path, label, SEVERITIES);
339
- if (value !== undefined) {
340
- severity.set(code, value);
149
+ const place = dotted([...at, ...placeIn(value, refused.pointer, refused.member)]);
150
+ switch (refused.keyword) {
151
+ case "additionalProperties":
152
+ throw unimplemented(this.label, place);
153
+ case "required":
154
+ throw malformed(this.label, place, "is required and absent");
341
155
  }
156
+ throw malformed(this.label, place, refused.reason);
342
157
  }
343
- return severity;
344
- }
345
- /** The exemption classes named for switching off, each one the vocabulary holds. */
346
- function readExemptions(document, label) {
347
- const exemptions = section(document, "exemptions", "exemptions", label);
348
- return readStrings(exemptions, "disabled", "exemptions.disabled", label, 0, EXEMPTION_CLASS_NAMES);
349
158
  }
350
- /** The members that name a declaration, each belonging to exactly one shape. */
351
- const SHAPE_MEMBERS = ["symbol", "module", "name", "global"];
352
- /** The prefix of a stable symbol reference in the TypeScript form. */
353
- const SYMBOL_PREFIX = "ts://";
354
- /**
355
- * A bare specifier: neither relative nor absolute, and not one the package's own
356
- * imports field maps, each of which names a file of the analyzed program.
357
- */
358
- const BARE_SPECIFIER = /^[^./#]/u;
359
- /**
360
- * One declaration entry, read as the one shape its members name. An entry carrying
361
- * members of two shapes, or of none, is refused at the entry, as is a module named
362
- * without the declaration's path or a path without its module.
363
- */
364
- function readDeclaration(entry, at, label) {
365
- if (!isRecord(entry)) {
366
- throw malformed(label, at, "is not an object");
159
+ const supplies = () => ({ values: new Map(), keyed: new Map() });
160
+ /** Reads and checks one configuration document. */
161
+ function documentSource(source, document) {
162
+ const { text, label } = document;
163
+ refuseOverBound(label, text);
164
+ let read;
165
+ try {
166
+ read = readStrict(text);
367
167
  }
368
- const named = SHAPE_MEMBERS.filter((name) => Object.hasOwn(entry, name));
369
- if (named.length === 1 && named[0] === "symbol") {
370
- const symbol = requireMember(readString(entry, "symbol", `${at}.symbol`, label), `${at}.symbol`, label);
371
- if (!symbol.startsWith(SYMBOL_PREFIX)) {
372
- throw malformed(label, `${at}.symbol`, `${JSON.stringify(symbol)} is not a ts:// reference`);
168
+ catch (error) {
169
+ if (!(error instanceof StrictJSONError)) {
170
+ throw error;
373
171
  }
374
- return { shape: "symbol", symbol };
172
+ throw malformed(label, dotted(error.place), locatedFault(text, error));
375
173
  }
376
- if (named.length === 1 && named[0] === "global") {
377
- const path = `${at}.global`;
378
- return {
379
- shape: "global",
380
- global: requireMember(readString(entry, "global", path, label), path, label),
381
- };
174
+ if (!isRecord(read.value)) {
175
+ throw malformed(label, "", "is not one JSON object");
382
176
  }
383
- if (named.length === 2 && named.includes("module") && named.includes("name")) {
384
- const module = requireMember(readString(entry, "module", `${at}.module`, label), `${at}.module`, label);
385
- if (!BARE_SPECIFIER.test(module)) {
386
- throw malformed(label, `${at}.module`, `${JSON.stringify(module)} is not a bare specifier: a file of the analyzed program is named by its symbol`);
177
+ const supplied = supplies();
178
+ new Walk(label, read.fractions, supplied).section("", read.value);
179
+ return { source, label, supplied };
180
+ }
181
+ /** The command line as a source: each flag checked as the one-setting document it supplies. */
182
+ function flagSource(flags) {
183
+ const supplied = supplies();
184
+ for (const key of [...flags.keys()].sort(bytewise)) {
185
+ const row = ROWS.get(key);
186
+ const text = flags.get(key) ?? "";
187
+ if (row?.option === undefined) {
188
+ throw unimplemented("the command line", key, "no flag supplies it");
387
189
  }
388
- const path = `${at}.name`;
389
- return {
390
- shape: "module",
391
- module,
392
- name: requireMember(readString(entry, "name", path, label), path, label),
393
- };
394
- }
395
- throw malformed(label, at, named.length === 0
396
- ? 'names no declaration: an entry carries "symbol", "module" with "name", or "global"'
397
- : `carries ${spell(named)}, which is not one of "symbol", "module" with "name", or "global"`);
398
- }
399
- /** One array of declaration entries, absent where the document does not write it. */
400
- function readDeclarations(parent, name, path, label) {
401
- const value = member(parent, name);
402
- if (value === undefined) {
403
- return undefined;
404
- }
405
- if (!Array.isArray(value)) {
406
- throw malformed(label, path, "is not an array");
407
- }
408
- return value.map((entry, index) => readDeclaration(entry, `${path}[${String(index)}]`, label));
409
- }
410
- /**
411
- * One lifecycle contract. The member names are required, and the entry names at least
412
- * one component declaration or one base class, because a contract naming neither
413
- * makes no class a component and so retains nothing.
414
- */
415
- function readLifecycleContract(entry, at, label) {
416
- if (!isRecord(entry)) {
417
- throw malformed(label, at, "is not an object");
418
- }
419
- const components = readDeclarations(entry, "components", `${at}.components`, label) ?? [];
420
- const bases = readDeclarations(entry, "bases", `${at}.bases`, label) ?? [];
421
- const members = readStrings(entry, "members", `${at}.members`, label, 1);
422
- if (members === undefined) {
423
- throw malformed(label, `${at}.members`, "is required and names nothing");
424
- }
425
- if (components.length === 0 && bases.length === 0) {
426
- throw malformed(label, at, 'names no declaration in "components" and no class in "bases", so it makes no class a component');
427
- }
428
- return { components, bases, members };
429
- }
430
- /** The lifecycle contracts, one per framework the project declares. */
431
- function readLifecycleContracts(ts, label) {
432
- const path = "ts.lifecycle_contracts";
433
- const value = member(ts, "lifecycle_contracts");
434
- if (value === undefined) {
435
- return undefined;
436
- }
437
- if (!Array.isArray(value)) {
438
- throw malformed(label, path, "is not an array");
190
+ const integer = row.value?.["type"] === "integer" && /^-?[0-9]+$/u.test(text);
191
+ let document = integer ? Number(text) : text;
192
+ for (const name of key.split(".").reverse()) {
193
+ document = { [name]: document };
194
+ }
195
+ new Walk(`--${row.option}`, new Map(), supplied).section("", document);
439
196
  }
440
- return value.map((entry, index) => readLifecycleContract(entry, `${path}[${String(index)}]`, label));
197
+ return { source: "flag", label: "", supplied };
441
198
  }
442
- /** One string member a provider entry requires, refused where it fails `pattern`. */
443
- function readMatching(entry, name, at, label, pattern) {
444
- const path = `${at}.${name}`;
445
- const value = requireMember(readString(entry, name, path, label), path, label);
446
- if (!pattern.test(value)) {
447
- throw malformed(label, path, `${JSON.stringify(value)} does not match ${pattern.source}`);
448
- }
449
- return value;
199
+ function originOf(held, key) {
200
+ const label = held.source === "flag" ? `--${String(ROWS.get(key)?.option)}` : held.label;
201
+ return { source: held.source, label };
450
202
  }
451
- /**
452
- * One provider entry, read as the one shape its members name: a member only an
453
- * acquirable analyzer carries makes it acquirable, and then it carries all three.
454
- */
455
- function readProvider(entry, at, label) {
456
- if (!isRecord(entry)) {
457
- throw malformed(label, at, "is not an object");
458
- }
459
- const name = readMatching(entry, "name", at, label, ANALYZER_NAME);
460
- const languages = readStrings(entry, "languages", `${at}.languages`, label, 1, LANGUAGES);
461
- if (languages === undefined) {
462
- throw malformed(label, `${at}.languages`, "is required and names nothing");
463
- }
464
- const commandPath = `${at}.command`;
465
- const command = requireMember(readString(entry, "command", commandPath, label), commandPath, label);
466
- if (!ACQUIRABLE_MEMBERS.some((member) => Object.hasOwn(entry, member))) {
467
- return { shape: "installed", name, languages, command };
468
- }
469
- return {
470
- shape: "acquirable",
471
- name,
472
- languages,
473
- command,
474
- source: readMatching(entry, "source", at, label, PROVIDER_SOURCE),
475
- version: readMatching(entry, "version", at, label, PROVIDER_VERSION),
476
- digest: readMatching(entry, "digest", at, label, PROVIDER_DIGEST),
477
- };
203
+ function searched(named, document) {
204
+ return `${named} (${document === undefined ? "not present" : document.label})`;
478
205
  }
479
- /**
480
- * The provider list. Every file a run writes for an analyzer is keyed by the
481
- * entry's name, so a list naming one name twice is refused at the later entry.
482
- */
483
- function readProviders(providers, label) {
484
- const path = "providers.analyzers";
485
- const value = member(providers, "analyzers");
486
- if (value === undefined) {
487
- return undefined;
206
+ /** Sets the value at one dotted key of the resolved tree, whose sections the table lists first. */
207
+ function setAt(tree, key, value) {
208
+ const names = key.split(".");
209
+ let into = tree;
210
+ for (const name of names.slice(0, -1)) {
211
+ into = into[name];
488
212
  }
489
- if (!Array.isArray(value)) {
490
- throw malformed(label, path, "is not an array");
491
- }
492
- const read = value.map((entry, index) => readProvider(entry, `${path}[${String(index)}]`, label));
493
- const first = new Map();
494
- read.forEach((entry, index) => {
495
- const earlier = first.get(entry.name);
496
- if (earlier !== undefined) {
497
- throw malformed(label, `${path}[${String(index)}].name`, `${JSON.stringify(entry.name)} is already the name of ${path}[${String(earlier)}], ` +
498
- "and every entry's name keys the files a run writes for it");
499
- }
500
- first.set(entry.name, index);
501
- });
502
- return read;
213
+ into[names.at(-1) ?? key] = value;
503
214
  }
504
215
  /**
505
- * Reads one already-parsed configuration document as the settings it supplies,
506
- * refusing every constraint the closed key list declares that a parse cannot
507
- * express: a value of the wrong type, a value outside a closed set, an array that
508
- * repeats an entry or holds too few, and a count below its minimum.
216
+ * Every setting this analyzer reads, each from the highest-ranked source carrying it,
217
+ * else its default, in the closed key list's order. A setting with no default no
218
+ * source supplies is refused where its row is required and `enforce` holds, and left
219
+ * unset otherwise. A keyed section's members overlay its default's, member by member.
509
220
  */
510
- function readDoc(value, label) {
511
- if (!isRecord(value)) {
512
- throw malformed(label, "", "is not one JSON object");
513
- }
514
- const analysis = section(value, "analysis", "analysis", label);
515
- const matrix = section(analysis, "matrix", "analysis.matrix", label);
516
- const target = section(value, "target", "target", label);
517
- const consumers = section(value, "consumers", "consumers", label);
518
- const roots = section(value, "roots", "roots", label);
519
- const reporters = section(value, "reporters", "reporters", label);
520
- const providers = section(value, "providers", "providers", label);
521
- const ts = section(value, "ts", "ts", label);
522
- section(value, "go", "go", label);
523
- section(value, "provenance", "provenance", label);
524
- const contractVersion = readString(value, "contract_version", "contract_version", label);
525
- if (contractVersion !== undefined && !CONTRACT_VERSION_PATTERN.test(contractVersion)) {
526
- throw malformed(label, "contract_version", `${JSON.stringify(contractVersion)} is not a semantic version`);
527
- }
528
- return {
529
- contractVersion,
530
- targetKind: readTargetKind(target, label),
531
- languages: readStrings(analysis, "languages", "analysis.languages", label, 0, LANGUAGES),
532
- minConfidence: readEnum(analysis, "min_confidence", "analysis.min_confidence", label, CONFIDENCES),
533
- generatedFiles: readEnum(analysis, "generated_files", "analysis.generated_files", label, GENERATED_FILES),
534
- consumerTests: readEnum(analysis, "consumer_tests", "analysis.consumer_tests", label, CONSUMER_TESTS),
535
- configurations: readConfigurations(analysis, label),
536
- matrixComplete: readBoolean(matrix, "complete", "analysis.matrix.complete", label),
537
- templateDirs: readStrings(analysis, "template_dirs", "analysis.template_dirs", label, 0),
538
- templateDelimiters: readDelimiters(analysis, label),
539
- consumersComplete: readBoolean(consumers, "complete", "consumers.complete", label),
540
- rootPatterns: readStrings(roots, "patterns", "roots.patterns", label, 0),
541
- severity: readSeverity(value, label),
542
- exemptionsDisabled: readExemptions(value, label),
543
- formats: readStrings(reporters, "formats", "reporters.formats", label, 1, FORMATS),
544
- sort: readEnum(reporters, "sort", "reporters.sort", label, SORTS),
545
- cascade: readEnum(reporters, "cascade", "reporters.cascade", label, CASCADES),
546
- maxFindings: readCount(reporters, "max_findings", "reporters.max_findings", label),
547
- failOn: readEnum(reporters, "fail_on", "reporters.fail_on", label, SEVERITIES),
548
- providers: readProviders(providers, label),
549
- testFiles: readStrings(ts, "test_files", "ts.test_files", label, 1),
550
- entryFiles: readStrings(ts, "entry_files", "ts.entry_files", label, 0),
551
- componentExtensions: readComponentExtensions(ts, label),
552
- disabledConventions: readDisabledConventions(ts, label),
553
- injectionRegistrations: readDeclarations(ts, "injection_registrations", "ts.injection_registrations", label),
554
- lifecycleContracts: readLifecycleContracts(ts, label),
555
- serializers: readDeclarations(ts, "serializers", "ts.serializers", label),
556
- rootsComplete: readBoolean(ts, "roots_complete", "ts.roots_complete", label),
557
- };
558
- }
559
- /** Parses one document's text and walks it against the closed key list. */
560
- function parseDocument(text, node, label) {
561
- let value;
562
- try {
563
- value = JSON.parse(text);
221
+ function settle(inputs, enforce) {
222
+ const sources = [];
223
+ if (inputs.flags !== undefined && inputs.flags.size > 0) {
224
+ sources.push(flagSource(inputs.flags));
564
225
  }
565
- catch (error) {
566
- throw malformed(label, "", message(error));
226
+ if (inputs.repository !== undefined) {
227
+ sources.push(documentSource("repository", inputs.repository));
567
228
  }
568
- checkDocument(text, node, label);
569
- return value;
570
- }
571
- /** Names a document in a refusal: the path the invocation passed, or what it is. */
572
- function labelOr(label, named) {
573
- return label === undefined || label === "" ? named : label;
574
- }
575
- /**
576
- * Decodes the documents one invocation supplies, in the order they outrank each
577
- * other, skipping every source it does not carry.
578
- */
579
- function readSources(inputs) {
580
- const sources = [];
581
- const flagLabels = inputs.flagLabels ?? new Map();
582
- if (inputs.flags !== undefined) {
583
- const flat = parseDocument(inputs.flags, { kind: "map" }, FLAGS_LABEL);
584
- if (!isRecord(flat)) {
585
- throw malformed(FLAGS_LABEL, "", "is not one JSON object");
586
- }
587
- sources.push({
588
- doc: readDoc(nestFlags(flat, FLAGS_LABEL), FLAGS_LABEL),
589
- kind: "flag",
590
- label: "",
591
- flagLabels,
592
- });
229
+ if (inputs.central !== undefined) {
230
+ sources.push(documentSource("central", inputs.central));
593
231
  }
594
- const held = [
595
- {
596
- kind: "repository",
597
- named: "the repository configuration",
598
- ...(inputs.repository === undefined ? {} : { text: inputs.repository }),
599
- ...(inputs.repositoryLabel === undefined ? {} : { label: inputs.repositoryLabel }),
600
- },
601
- {
602
- kind: "central",
603
- named: "the central configuration",
604
- ...(inputs.central === undefined ? {} : { text: inputs.central }),
605
- ...(inputs.centralLabel === undefined ? {} : { label: inputs.centralLabel }),
606
- },
607
- ];
608
- for (const entry of held) {
609
- if (entry.text === undefined) {
232
+ const tree = {};
233
+ const provenance = new Map();
234
+ for (const row of SETTINGS) {
235
+ if (!row.read || row.role === "ignored") {
610
236
  continue;
611
237
  }
612
- const label = labelOr(entry.label, entry.named);
613
- sources.push({
614
- doc: readDoc(parseDocument(entry.text, SCHEMA_ROOT, label), label),
615
- kind: entry.kind,
616
- label: entry.label ?? "",
617
- flagLabels,
618
- });
619
- }
620
- return sources;
621
- }
622
- /**
623
- * The value the highest-ranked source carrying one supplies, with where it came
624
- * from recorded, or the default.
625
- */
626
- function settle(fallback, path, provenance, sources, read) {
627
- for (const source of sources) {
628
- const value = read(source.doc);
629
- if (value !== undefined) {
630
- provenance.set(path, originOf(source, path));
631
- return value;
632
- }
633
- }
634
- provenance.set(path, { source: "default", label: "" });
635
- return fallback;
636
- }
637
- /**
638
- * The severity object, resolved one code at a time so a code only the central
639
- * configuration names keeps its central value. An object that resolves empty
640
- * carries one entry for the object itself.
641
- */
642
- function settleSeverity(provenance, sources) {
643
- const codes = new Set();
644
- for (const source of sources) {
645
- for (const code of source.doc.severity?.keys() ?? []) {
646
- codes.add(code);
238
+ if (row.role === "section") {
239
+ setAt(tree, row.key, {});
647
240
  }
648
- }
649
- const severity = new Map();
650
- for (const code of [...codes].sort(bytewise)) {
651
- const path = `${SEVERITY_SECTION}.${code}`;
652
- for (const source of sources) {
653
- const value = source.doc.severity?.get(code);
654
- if (value === undefined) {
655
- continue;
241
+ else if (row.role === "keyed") {
242
+ const members = isRecord(row.default) ? { ...row.default } : {};
243
+ provenance.set(row.key, { source: "default", label: "" });
244
+ for (const name of Object.keys(members)) {
245
+ provenance.set(`${row.key}.${name}`, { source: "default", label: "" });
656
246
  }
657
- severity.set(code, value);
658
- provenance.set(path, originOf(source, path));
659
- break;
660
- }
661
- }
662
- if (codes.size > 0) {
663
- return severity;
664
- }
665
- provenance.set(SEVERITY_SECTION, { source: "default", label: "" });
666
- for (const source of sources) {
667
- if (source.doc.severity !== undefined) {
668
- provenance.set(SEVERITY_SECTION, originOf(source, SEVERITY_SECTION));
669
- break;
247
+ for (const held of sources.toReversed()) {
248
+ const named = held.supplied.keyed.get(row.key);
249
+ if (named === undefined) {
250
+ continue;
251
+ }
252
+ provenance.set(row.key, originOf(held, row.key));
253
+ for (const [name, value] of Object.entries(named)) {
254
+ members[name] = value;
255
+ provenance.set(`${row.key}.${name}`, originOf(held, row.key));
256
+ }
257
+ }
258
+ if (Object.keys(members).length > 0) {
259
+ provenance.delete(row.key);
260
+ }
261
+ setAt(tree, row.key, canonical(members));
670
262
  }
671
- }
672
- return severity;
673
- }
674
- /** Names one configuration source and whether the invocation carried it. */
675
- function describeSource(named, text, label) {
676
- if (text === undefined) {
677
- return `${named} (not present)`;
678
- }
679
- return `${named} (${labelOr(label, "unnamed")})`;
680
- }
681
- /**
682
- * Refuses a provenance entry whose source names no file or flag, which would
683
- * print a provenance value the closed key list refuses to read back.
684
- */
685
- function checkLabels(provenance) {
686
- for (const path of [...provenance.keys()].sort(bytewise)) {
687
- const origin = provenance.get(path);
688
- if (origin !== undefined && origin.source !== "default" && origin.label === "") {
689
- throw malformed(origin.source === "flag" ? FLAGS_LABEL : origin.source, path, `came from ${origin.source}, which names no file or flag`);
263
+ else {
264
+ const held = sources.find((one) => one.supplied.values.has(row.key));
265
+ if (held !== undefined) {
266
+ setAt(tree, row.key, held.supplied.values.get(row.key));
267
+ provenance.set(row.key, originOf(held, row.key));
268
+ }
269
+ else if (row.default !== undefined) {
270
+ setAt(tree, row.key, canonical(row.default));
271
+ provenance.set(row.key, { source: "default", label: "" });
272
+ }
273
+ else if (enforce && row.required === true) {
274
+ throw new UsageError(`${row.key} is not set, it has no default and is never inferred: searched ` +
275
+ `${searched("the repository configuration", inputs.repository)} and ` +
276
+ searched("the central configuration", inputs.central));
277
+ }
690
278
  }
691
279
  }
280
+ // gen-config.ts marks a member optional exactly where this loop may leave it unset.
281
+ return { config: tree, provenance };
692
282
  }
693
283
  /**
694
- * Applies a command-line flag over the repository configuration over the central
284
+ * Applies the command-line flags over the repository configuration over the central
695
285
  * configuration over the default each key declares, and returns the resolved
696
- * configuration with the origin of every setting.
697
- *
698
- * It throws a {@link ConfigError} for a document that names a key the closed key
699
- * list does not declare, a document that names one key twice, and a resolved
700
- * configuration no source supplied a target kind for. Every one of them maps to
701
- * the usage exit code.
286
+ * configuration with the origin of every setting: its keys in the closed key list's
287
+ * order, every object's members inside a value ascending. Every refusal is a
288
+ * {@link UsageError}.
702
289
  */
703
290
  export function resolve(inputs) {
704
- const { config, provenance } = settleAll(inputs);
705
- if (config.targetKind === "") {
706
- throw new ConfigError("missing-target-kind", "target.kind", "target.kind is not set, it has no default and is never inferred: searched " +
707
- `${describeSource("the repository configuration", inputs.repository, inputs.repositoryLabel)} and ` +
708
- describeSource("the central configuration", inputs.central, inputs.centralLabel));
709
- }
710
- checkLabels(provenance);
711
- return { config, provenance };
291
+ const { config, provenance } = settle(inputs, true);
292
+ return { config: config, provenance };
712
293
  }
713
294
  /**
714
- * The configuration the documents resolve to, every document read and refused as
715
- * {@link resolve} refuses it, with no target kind required of them: which projects a
716
- * run analyzes does not depend on the kind, so a question about the projects asks
717
- * none. The kind is empty where no document names one.
295
+ * The configuration the sources resolve to, refused as {@link resolve} refuses it but
296
+ * with no target kind required: which projects a run analyzes asks none.
718
297
  */
719
- export function resolveUnkinded(inputs) {
720
- return settleAll(inputs).config;
721
- }
722
- /**
723
- * Every setting the documents supply, each from the highest-ranked source carrying
724
- * it, with the origin of each. The target kind is empty where no source names one.
725
- */
726
- function settleAll(inputs) {
727
- const sources = readSources(inputs);
728
- const defaults = defaultConfig();
729
- const provenance = new Map();
730
- const at = (path, fallback, read) => settle(fallback, path, provenance, sources, read);
731
- const config = {
732
- contractVersion: at("contract_version", defaults.contractVersion, (doc) => doc.contractVersion),
733
- targetKind: at("target.kind", "", (doc) => doc.targetKind),
734
- analysis: {
735
- languages: at("analysis.languages", defaults.analysis.languages, (doc) => doc.languages),
736
- minConfidence: at("analysis.min_confidence", defaults.analysis.minConfidence, (doc) => doc.minConfidence),
737
- generatedFiles: at("analysis.generated_files", defaults.analysis.generatedFiles, (doc) => doc.generatedFiles),
738
- consumerTests: at("analysis.consumer_tests", defaults.analysis.consumerTests, (doc) => doc.consumerTests),
739
- configurations: at("analysis.configurations", defaults.analysis.configurations, (doc) => doc.configurations),
740
- matrixComplete: at("analysis.matrix.complete", defaults.analysis.matrixComplete, (doc) => doc.matrixComplete),
741
- templateDirs: at("analysis.template_dirs", defaults.analysis.templateDirs, (doc) => doc.templateDirs),
742
- templateDelimiters: at("analysis.template_delimiters", defaults.analysis.templateDelimiters, (doc) => doc.templateDelimiters),
743
- },
744
- consumersComplete: at("consumers.complete", defaults.consumersComplete, (doc) => doc.consumersComplete),
745
- rootPatterns: at("roots.patterns", defaults.rootPatterns, (doc) => doc.rootPatterns),
746
- severity: settleSeverity(provenance, sources),
747
- exemptionsDisabled: at("exemptions.disabled", defaults.exemptionsDisabled, (doc) => doc.exemptionsDisabled),
748
- reporters: {
749
- formats: at("reporters.formats", defaults.reporters.formats, (doc) => doc.formats),
750
- sort: at("reporters.sort", defaults.reporters.sort, (doc) => doc.sort),
751
- cascade: at("reporters.cascade", defaults.reporters.cascade, (doc) => doc.cascade),
752
- maxFindings: at("reporters.max_findings", defaults.reporters.maxFindings, (doc) => doc.maxFindings),
753
- failOn: at("reporters.fail_on", defaults.reporters.failOn, (doc) => doc.failOn),
754
- },
755
- providers: {
756
- analyzers: at("providers.analyzers", defaults.providers.analyzers, (doc) => doc.providers),
757
- },
758
- ts: {
759
- testFiles: at("ts.test_files", defaults.ts.testFiles, (doc) => doc.testFiles),
760
- entryFiles: at("ts.entry_files", defaults.ts.entryFiles, (doc) => doc.entryFiles),
761
- componentExtensions: at("ts.component_extensions", defaults.ts.componentExtensions, (doc) => doc.componentExtensions),
762
- disabledConventions: at("ts.disabled_conventions", defaults.ts.disabledConventions, (doc) => doc.disabledConventions),
763
- injectionRegistrations: at("ts.injection_registrations", defaults.ts.injectionRegistrations, (doc) => doc.injectionRegistrations),
764
- lifecycleContracts: at("ts.lifecycle_contracts", defaults.ts.lifecycleContracts, (doc) => doc.lifecycleContracts),
765
- serializers: at("ts.serializers", defaults.ts.serializers, (doc) => doc.serializers),
766
- rootsComplete: at("ts.roots_complete", defaults.ts.rootsComplete, (doc) => doc.rootsComplete),
767
- },
768
- };
769
- return { config, provenance };
298
+ export function resolvePartial(inputs) {
299
+ return settle(inputs, false).config;
770
300
  }