@cplieger/deadset-ts 8.0.0-dev.17 → 8.0.0-dev.19

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 (86) hide show
  1. package/dist/src/analysis.js +30 -72
  2. package/dist/src/augmentations.js +1 -1
  3. package/dist/src/calls.js +267 -48
  4. package/dist/src/commands/held.js +499 -0
  5. package/dist/src/commands/read.js +16 -10
  6. package/dist/src/commands/shell.js +109 -15
  7. package/dist/src/commands/tools.js +1540 -149
  8. package/dist/src/conformance-record.js +1 -1
  9. package/dist/src/contract/contract.generated.js +9 -2
  10. package/dist/src/entries/conventions.js +7 -6
  11. package/dist/src/entries/test-runners.js +6 -40
  12. package/dist/src/entries/workflow-steps.js +202 -28
  13. package/dist/src/exempt.js +0 -26
  14. package/dist/src/exposure.js +400 -0
  15. package/dist/src/findings/completion.js +4 -17
  16. package/dist/src/findings/emitters.js +22 -33
  17. package/dist/src/findings/intra-function.js +3 -3
  18. package/dist/src/findings/non-code-artifacts.js +11 -5
  19. package/dist/src/findings/reads-and-writes.js +71 -15
  20. package/dist/src/findings/unused-declarations.js +2 -22
  21. package/dist/src/findings/visibility-narrowing.js +14 -20
  22. package/dist/src/inventory.js +18 -0
  23. package/dist/src/{components.js → liveness/components.js} +1 -1
  24. package/dist/src/{graph.js → liveness/graph.js} +38 -21
  25. package/dist/src/liveness/matrix.js +99 -0
  26. package/dist/src/liveness/sweep.js +558 -0
  27. package/dist/src/query.js +46 -0
  28. package/dist/src/references/sink.js +87 -1
  29. package/dist/src/references.js +1 -1
  30. package/dist/src/roots/manifest.js +47 -4
  31. package/dist/src/roots/published-reach.js +4 -4
  32. package/dist/src/roots/root-set.js +14 -16
  33. package/dist/src/text/named-files.js +257 -34
  34. package/dist/src/verbs/analyze.js +16 -1
  35. package/dist/src/verbs/explain.js +73 -152
  36. package/dist/src/verbs/print-retained.js +1 -1
  37. package/jsr.json +1 -1
  38. package/package.json +1 -1
  39. package/src/analysis.ts +54 -108
  40. package/src/augmentations.ts +1 -1
  41. package/src/calls.ts +326 -52
  42. package/src/commands/held.ts +632 -0
  43. package/src/commands/read.ts +26 -12
  44. package/src/commands/shell.ts +117 -15
  45. package/src/commands/tools.ts +1972 -202
  46. package/src/conformance-record.ts +1 -1
  47. package/src/contract/contract.generated.ts +9 -2
  48. package/src/dependencies.ts +1 -1
  49. package/src/entries/conventions.ts +8 -12
  50. package/src/entries/test-runners.ts +12 -45
  51. package/src/entries/workflow-steps.ts +227 -38
  52. package/src/exempt.ts +31 -46
  53. package/src/exposure.ts +492 -0
  54. package/src/file-facts.ts +5 -0
  55. package/src/finding.ts +1 -1
  56. package/src/findings/boundary.ts +7 -0
  57. package/src/findings/completion.ts +5 -19
  58. package/src/findings/emitters.ts +23 -41
  59. package/src/findings/interfaces.ts +3 -3
  60. package/src/findings/intra-function.ts +3 -3
  61. package/src/findings/non-code-artifacts.ts +16 -5
  62. package/src/findings/reads-and-writes.ts +99 -26
  63. package/src/findings/unused-declarations.ts +4 -28
  64. package/src/findings/visibility-narrowing.ts +25 -26
  65. package/src/interface-satisfaction.ts +1 -1
  66. package/src/inventory.ts +19 -0
  67. package/src/{components.ts → liveness/components.ts} +3 -3
  68. package/src/{graph.ts → liveness/graph.ts} +74 -26
  69. package/src/liveness/matrix.ts +162 -0
  70. package/src/liveness/sweep.ts +855 -0
  71. package/src/query.ts +81 -0
  72. package/src/references/sink.ts +101 -0
  73. package/src/references.ts +8 -1
  74. package/src/roots/manifest.ts +53 -8
  75. package/src/roots/published-reach.ts +9 -4
  76. package/src/roots/root-set.ts +18 -16
  77. package/src/stores.ts +2 -1
  78. package/src/tests/file-class.ts +19 -2
  79. package/src/text/named-files.ts +333 -36
  80. package/src/verbs/analyze.ts +16 -1
  81. package/src/verbs/explain.ts +81 -199
  82. package/src/verbs/print-retained.ts +1 -1
  83. package/dist/src/matrix.js +0 -275
  84. package/dist/src/sweep.js +0 -234
  85. package/src/matrix.ts +0 -466
  86. package/src/sweep.ts +0 -384
@@ -1,13 +1,30 @@
1
- /**
2
- * Layer 3 of the command reader: the files and the package names a command's text names, read
3
- * as plain text. The text is searched for each name, which every spelling of what it names
4
- * contains, so no part of it is split, unquoted or skipped first.
5
- */
1
+ /** Layer 3 of the command reader: the files its words name, and the package names a command's text names. */
6
2
 
3
+ import type { HeldWord } from "../commands/held.ts";
4
+ import { PART } from "../commands/shell.ts";
5
+ import { APPENDED_EXTENSIONS, extensionOf } from "../extensions.ts";
7
6
  import { dirnamePath, normalizePath, relativePath } from "../paths.ts";
8
7
 
9
- /** The extension a source or an emitted file carries: a JavaScript or TypeScript one, or a declaration's. */
10
- const SOURCE_EXTENSION = /\.(?:d\.[cm]?ts|[cm]?[jt]s|[jt]sx)$/u;
8
+ /** The extensions a name of a file drops: a source's, an emitted file's, and a declaration's (roots.13). */
9
+ const NAMED_EXTENSIONS = [...APPENDED_EXTENSIONS, ".d.ts", ".d.mts", ".d.cts"];
10
+
11
+ /** A character a package's or a command's name may hold, so one beside a name makes it part of a longer one. */
12
+ const NAME_CHARACTER = /[\w.@-]/u;
13
+
14
+ const SEPARATOR = /[/\\]/u;
15
+
16
+ /**
17
+ * What makes one name of a file a path where it appears: a `stem`, a last segment without its
18
+ * extension, may have the extension after it; a `segment`, a whole last segment, is one where
19
+ * it holds an extension of its own; a `directory`, an `index` file's, may have a separator
20
+ * after it; and `root` is `.`, the package's own directory.
21
+ */
22
+ type NameKind = "stem" | "segment" | "directory" | "root";
23
+
24
+ interface FileName {
25
+ readonly text: string;
26
+ readonly kind: NameKind;
27
+ }
11
28
 
12
29
  /** One file, and every path it is spelled by: its own and each one the project writes it to. */
13
30
  interface Spelled<File> {
@@ -16,60 +33,340 @@ interface Spelled<File> {
16
33
  }
17
34
 
18
35
  /**
19
- * The names whose presence in a text holds one path below `dir`: its last name without the
20
- * extension, or with it where nothing else is left, and for an `index` file its directory's
21
- * last name, and `.` too where that is `dir`. Every spelling of the path relative to `dir`,
22
- * with or without `./`, `/` or `\`, its extension or its `/index` part, and every longer path
23
- * ending in one, holds one of them. None is empty, because an empty name is in every text.
36
+ * The names whose appearance as a path in a text holds one path below `dir`: its last segment
37
+ * without the extension, or whole where nothing else is left or it has none, and for an
38
+ * `index` file its directory's last segment, and `.` too where that is `dir`. Every spelling
39
+ * of the path that writes it as a path holds one of them (roots.13). None is empty, because
40
+ * an empty name is in every text.
24
41
  */
25
- function stemsOf(path: string, dir: string): readonly string[] {
42
+ function namesOf(path: string, dir: string): readonly FileName[] {
26
43
  const last = path.slice(path.lastIndexOf("/") + 1);
27
- const bare = last.replace(SOURCE_EXTENSION, "");
28
- const name = bare === "" ? last : bare;
29
- if (name !== "index") {
30
- return [name];
44
+ const bare = last.slice(0, last.length - (extensionOf(last, NAMED_EXTENSIONS)?.length ?? 0));
45
+ const own: FileName =
46
+ bare === "" || bare === last ? { text: last, kind: "segment" } : { text: bare, kind: "stem" };
47
+ if (own.text !== "index") {
48
+ return [own];
31
49
  }
32
50
  const parent = dirnamePath(path);
51
+ const directory = parent.slice(parent.lastIndexOf("/") + 1);
33
52
  return [
34
- name,
35
- parent.slice(parent.lastIndexOf("/") + 1),
36
- ...(parent === normalizePath(dir) ? ["."] : []),
37
- ].filter((stem) => stem !== "");
53
+ own,
54
+ ...(directory === "" ? [] : [{ text: directory, kind: "directory" as const }]),
55
+ ...(parent === normalizePath(dir) ? [{ text: ".", kind: "root" as const }] : []),
56
+ ];
57
+ }
58
+
59
+ /**
60
+ * Whether a name that ends at `end` ends there as a path: no name character follows, nor a
61
+ * separator, which goes on to a path below it, nor a part, whose text goes on with the name,
62
+ * nor a `.` that a word character or a part follows, which goes on to another extension.
63
+ */
64
+ function endsAt(text: string, end: number): boolean {
65
+ const next = text.charAt(end);
66
+ const after = text.charAt(end + 1);
67
+ return (
68
+ !/[\w@/\\-]/u.test(next) &&
69
+ next !== PART &&
70
+ !(next === "." && (/\w/u.test(after) || after === PART))
71
+ );
72
+ }
73
+
74
+ /** A character a word that writes a path may hold, a part only its run knows among them. */
75
+ const PATH_CHARACTER = new RegExp(`[\\w.@+/\\\\${PART}-]`, "u");
76
+
77
+ /** A run of {@link PATH_CHARACTER}s: a word as {@link noFileEnd} reads one. */
78
+ const PATH_WORD = new RegExp(`${PATH_CHARACTER.source}+`, "gu");
79
+
80
+ const SCOPED_PACKAGE = /^@[\w-][\w.-]*\/[\w-][\w.-]*(?:@[\w.-]*)?$/u;
81
+
82
+ /**
83
+ * The end of what `text` writes from `start`, where `word` starts, that names an image or a
84
+ * package and never a file, or `start` where it names none (roots.13): a value of a `docker:`
85
+ * that starts no longer name, and a scoped package's name, which no part goes on with, since
86
+ * a part beside it may make it a path.
87
+ */
88
+ function noFileEnd(text: string, start: number, word: string): number {
89
+ const end = start + word.length;
90
+ const image =
91
+ word.startsWith("//") &&
92
+ start >= 7 &&
93
+ text.startsWith("docker:", start - 7) &&
94
+ !NAME_CHARACTER.test(text.charAt(start - 8));
95
+ return image || (SCOPED_PACKAGE.test(word) && !holdsExtension(word)) ? end : start;
96
+ }
97
+
98
+ /** Each place of `text` that {@link noFileEnd} rules out, as a 1. */
99
+ function placesNamingNoFile(text: string): Uint8Array {
100
+ const ruledOut = new Uint8Array(text.length);
101
+ for (const { 0: word, index: start } of text.matchAll(PATH_WORD)) {
102
+ ruledOut.fill(1, start, noFileEnd(text, start, word));
103
+ }
104
+ return ruledOut;
105
+ }
106
+
107
+ /** The place after the separators `text` holds from `at`. */
108
+ function pastSeparators(text: string, at: number): number {
109
+ let after = at;
110
+ while (SEPARATOR.test(text.charAt(after))) {
111
+ after += 1;
112
+ }
113
+ return after;
114
+ }
115
+
116
+ /** Whether `name`, found in `text` at `at`, appears there as a path (roots.13). */
117
+ function appearsAsPath(text: string, at: number, name: FileName): boolean {
118
+ const before = text.charAt(at - 1);
119
+ const end = at + name.text.length;
120
+ if (before === PART) {
121
+ return false;
122
+ }
123
+ if (name.kind === "root") {
124
+ const after = pastSeparators(text, end);
125
+ return (
126
+ [before, text.charAt(after)].every(
127
+ (one) => !NAME_CHARACTER.test(one) && !SEPARATOR.test(one),
128
+ ) && text.charAt(after) !== PART
129
+ );
130
+ }
131
+ if (NAME_CHARACTER.test(before)) {
132
+ return false;
133
+ }
134
+ const after = pastSeparators(text, end);
135
+ if (name.kind === "directory" && after > end && endsAt(text, after)) {
136
+ return true;
137
+ }
138
+ if (
139
+ (SEPARATOR.test(before) || (name.kind === "segment" && name.text.indexOf(".", 1) > 0)) &&
140
+ endsAt(text, end)
141
+ ) {
142
+ return true;
143
+ }
144
+ return (
145
+ name.kind === "stem" &&
146
+ NAMED_EXTENSIONS.some(
147
+ (extension) => text.startsWith(extension, end) && endsAt(text, end + extension.length),
148
+ )
149
+ );
150
+ }
151
+
152
+ /** Whether some text holds one of the extensions as a whole. */
153
+ function holdsExtension(written: string): boolean {
154
+ return NAMED_EXTENSIONS.some((extension) =>
155
+ new RegExp(`${extension.replaceAll(".", "\\.")}(?!\\w)`, "u").test(written),
156
+ );
157
+ }
158
+
159
+ /**
160
+ * A word with a part only its run knows: the text a path it names ends in after a `/`, split
161
+ * at each part, and whether it names a directory.
162
+ */
163
+ interface DynamicWord {
164
+ readonly glob: readonly string[];
165
+ readonly directory: boolean;
166
+ }
167
+
168
+ /** Whether a word's segment writes path text: text beside its parts other than `.` and `..`. */
169
+ function writesPath(segment: string): boolean {
170
+ return segment.split(PART).some((piece) => piece !== "" && piece !== "." && piece !== "..");
38
171
  }
39
172
 
40
173
  /**
41
- * Every file of `files` below `dir` that `text` names: one whose {@link stemsOf} a path of it
42
- * spells appears anywhere in the text. A file the text does not name may be held too, and no
43
- * file it names is missed.
174
+ * Each run of path characters of `word`, at `start`, whose last segment holds a part, read as
175
+ * roots.13 reads one from past its last segment before the last that writes no path: one that
176
+ * writes none names nothing and is `unwritten` where the word may write the file a command runs,
177
+ * where a bare one names a file too. The word stands `depth` segments below the target root,
178
+ * whose own directories no checkout names alike: a leading `..` past it writes none, and an
179
+ * absolute run reads from its last segment that writes a path, `unwritten` where more is left.
180
+ */
181
+ function dynamicWords(
182
+ word: HeldWord,
183
+ start: number,
184
+ ruledOut: Uint8Array,
185
+ depth: number,
186
+ ): { readonly found: readonly DynamicWord[]; readonly unwritten: boolean } {
187
+ const { text, runs } = word;
188
+ const found: DynamicWord[] = [];
189
+ let unwritten = false;
190
+ const read = (from: number, next: number): void => {
191
+ const entry = next < 0;
192
+ // A `.` the word ends with ends a sentence, as endsAt reads one after a name.
193
+ const run = entry ? text : text.slice(from, next).replace(/\.+$/u, "");
194
+ const all = run.replaceAll("\\", "/").split("/");
195
+ const directory = all.length > 1 && all.at(-1) === "";
196
+ const written = all.filter((segment) => segment !== "" && segment !== ".");
197
+ const last = (written.at(-1) ?? "").split(PART);
198
+ // A runtime's entry is a path whatever it looks like, a scoped package's name among them.
199
+ if (!entry && (last.length < 2 || ruledOut[start + from] === 1)) {
200
+ return;
201
+ }
202
+ const climbs = written.findIndex((segment) => segment !== "..");
203
+ const above = Math.max(0, (climbs < 0 ? written.length : climbs) - depth);
204
+ const segments = written.filter((_, at) => at < climbs || at >= climbs + above);
205
+ if (!segments.some(writesPath)) {
206
+ unwritten ||= runs && (!entry || above > 0);
207
+ } else if (all.length > 1 || holdsExtension(last.join("")) || runs) {
208
+ const kept = directory ? segments.length : segments.length - 1;
209
+ const anyDirectory = segments.slice(0, kept).findLastIndex((one) => !writesPath(one));
210
+ const absolute = all[0] === "" && all.length > 1 && anyDirectory < 0;
211
+ const from = absolute ? segments.findLastIndex(writesPath) : anyDirectory + 1;
212
+ unwritten ||= runs && absolute && from < segments.length - 1;
213
+ const glob = segments.slice(from).join("/");
214
+ found.push({ glob: glob === "" ? ["", ""] : glob.split(PART), directory });
215
+ }
216
+ };
217
+ if (runs && !text.includes(PART)) {
218
+ read(0, -1);
219
+ }
220
+ let at = text.indexOf(PART);
221
+ while (at >= 0) {
222
+ let from = at;
223
+ while (from > 0 && PATH_CHARACTER.test(text.charAt(from - 1))) {
224
+ from -= 1;
225
+ }
226
+ let next = at;
227
+ while (next < text.length && PATH_CHARACTER.test(text.charAt(next))) {
228
+ next += 1;
229
+ }
230
+ read(from, next);
231
+ at = text.indexOf(PART, Math.max(next, at + 1));
232
+ }
233
+ return { found, unwritten };
234
+ }
235
+
236
+ /** Whether `segment` is the text `glob` writes, any text standing between two of its parts. */
237
+ function standsFor(glob: readonly string[], segment: string): boolean {
238
+ const first = glob[0] ?? "";
239
+ const last = glob.at(-1) ?? "";
240
+ if (glob.length === 1) {
241
+ return segment === first;
242
+ }
243
+ if (
244
+ !segment.startsWith(first) ||
245
+ !segment.endsWith(last) ||
246
+ first.length + last.length > segment.length
247
+ ) {
248
+ return false;
249
+ }
250
+ let at = first.length;
251
+ const end = segment.length - last.length;
252
+ for (const middle of glob.slice(1, -1)) {
253
+ const found = segment.indexOf(middle, at);
254
+ if (found < 0 || found + middle.length > end) {
255
+ return false;
256
+ }
257
+ at = found + middle.length;
258
+ }
259
+ return true;
260
+ }
261
+
262
+ /** Whether a word's glob may write `path` or the end of it after a `/`. */
263
+ function mayStandFor(glob: readonly string[], path: string): boolean {
264
+ let at = 0;
265
+ while (!standsFor(glob, path.slice(at))) {
266
+ const slash = path.indexOf("/", at);
267
+ if (slash < 0) {
268
+ return false;
269
+ }
270
+ at = slash + 1;
271
+ }
272
+ return true;
273
+ }
274
+
275
+ /**
276
+ * Each spelling of one path below `dir` a word may write the end of: the whole path from `root`,
277
+ * so a word may write the directories between them too, but no checkout's own, without its
278
+ * extension, and without its `/index` part, which alone is a directory's spelling.
279
+ */
280
+ function spellingsBelow(
281
+ path: string,
282
+ dir: string,
283
+ root: string,
284
+ ): { readonly file: readonly string[]; readonly directory: readonly string[] } {
285
+ const fromRoot = relativePath(root, path);
286
+ if (relativePath(dir, path) === undefined || fromRoot === undefined) {
287
+ return { file: [], directory: [] };
288
+ }
289
+ const whole = `/${fromRoot}`;
290
+ const extension = extensionOf(whole, NAMED_EXTENSIONS);
291
+ const bare = extension === undefined ? whole : whole.slice(0, -extension.length);
292
+ const directory = bare.endsWith("/index") ? [bare.slice(0, -"/index".length)] : [];
293
+ return { file: [whole, bare, ...directory], directory };
294
+ }
295
+
296
+ /**
297
+ * Every file of `files` below `dir` that `words` name: one of whose {@link namesOf} a path of it
298
+ * has appears in a word as a path, or a spelling of one of whose paths a word that writes a
299
+ * path with a part only its run knows may stand for, and whether a word that may write the
300
+ * file a command runs writes no path text. A file the words do not name may be named too, and
301
+ * no file a word writes as a path outside an image's or a package's name is missed.
44
302
  */
45
303
  export function spelledFiles<File>(
46
- text: string,
304
+ words: readonly HeldWord[],
47
305
  dir: string,
306
+ root: string,
48
307
  files: readonly Spelled<File>[],
49
- ): readonly File[] {
50
- const byStem = new Map<string, File[]>();
308
+ ): { readonly files: readonly File[]; readonly unwritten: boolean } {
309
+ const byName = new Map<string, { readonly file: File; readonly name: FileName }[]>();
51
310
  for (const { file, paths } of files) {
52
311
  const [own] = paths;
53
312
  if (own === undefined || relativePath(dir, own) === undefined) {
54
313
  continue;
55
314
  }
56
- for (const stem of new Set(paths.flatMap((path) => stemsOf(path, dir)))) {
57
- byStem.set(stem, [...(byStem.get(stem) ?? []), file]);
315
+ const seen = new Set<string>();
316
+ for (const name of paths.flatMap((path) => namesOf(path, dir))) {
317
+ const key = `${name.kind}\u0000${name.text}`;
318
+ if (!seen.has(key)) {
319
+ seen.add(key);
320
+ byName.set(name.text, [...(byName.get(name.text) ?? []), { file, name }]);
321
+ }
58
322
  }
59
323
  }
60
324
  const found = new Set<File>();
61
- // One pass per stem length: each place of the text is looked up once for every length.
62
- for (const length of new Set([...byStem.keys()].map((stem) => stem.length))) {
325
+ const text = words.map((word) => word.text).join("\n");
326
+ const ruledOut = placesNamingNoFile(text);
327
+ // One pass per name length: each place of the text is looked up once for every length.
328
+ for (const length of new Set([...byName.keys()].map((name) => name.length))) {
63
329
  for (let at = 0; at + length <= text.length; at += 1) {
64
- byStem.get(text.slice(at, at + length))?.forEach((file) => found.add(file));
330
+ for (const { file, name } of byName.get(text.slice(at, at + length)) ?? []) {
331
+ if (!found.has(file) && ruledOut[at] !== 1 && appearsAsPath(text, at, name)) {
332
+ found.add(file);
333
+ }
334
+ }
65
335
  }
66
336
  }
67
- return [...found];
337
+ const dynamic: DynamicWord[] = [];
338
+ let unwritten = false;
339
+ let start = 0;
340
+ const depth =
341
+ normalizePath(dir) === normalizePath(root)
342
+ ? 0
343
+ : (relativePath(root, dir)?.split("/").length ?? 0);
344
+ for (const word of words) {
345
+ const read = dynamicWords(word, start, ruledOut, depth);
346
+ dynamic.push(...read.found);
347
+ unwritten ||= read.unwritten;
348
+ start += word.text.length + 1;
349
+ }
350
+ if (dynamic.length > 0) {
351
+ for (const { file, paths } of files) {
352
+ const spellings = paths.map((path) => spellingsBelow(path, dir, root));
353
+ if (
354
+ !found.has(file) &&
355
+ dynamic.some((word) =>
356
+ spellings.some((spelled) =>
357
+ (word.directory ? spelled.directory : spelled.file).some((one) =>
358
+ mayStandFor(word.glob, one),
359
+ ),
360
+ ),
361
+ )
362
+ ) {
363
+ found.add(file);
364
+ }
365
+ }
366
+ }
367
+ return { files: [...found], unwritten };
68
368
  }
69
369
 
70
- /** A character a package's or a command's name may hold, so one beside a name makes it part of a longer one. */
71
- const NAME_CHARACTER = /[\w.@-]/u;
72
-
73
370
  /**
74
371
  * Each of `names`, a package's or a command's name, that `text` holds with no name character
75
372
  * before it and no character after it but one a path or a version may go on with, `/`, `.` or
@@ -137,13 +137,28 @@ function unseenLoadNotes(loads: readonly UnseenLoad[]): readonly ReportNote[] {
137
137
  /** One note per package whose command strings name files a configuration holds, naming every such file. */
138
138
  function heldScriptNotes(held: readonly HeldScripts[], targetRoot: string): readonly ReportNote[] {
139
139
  const files = new Map<string, Set<string>>();
140
+ const unwritten = new Set<string>();
140
141
  for (const one of held) {
141
142
  files.set(one.dir, new Set([...(files.get(one.dir) ?? []), ...one.files]));
143
+ if (one.unwritten) {
144
+ unwritten.add(one.dir);
145
+ }
142
146
  }
143
147
  return [...files].map(([dir, paths]) => ({
144
148
  kind: "unread-command",
145
149
  path: relativePath(targetRoot, dir) ?? ".",
146
- message: `commands the analysis does not read name ${[...paths].sort(bytewise).join(", ")}, so no finding is reported about ${paths.size === 1 ? "that file itself or the names it exports" : "those files themselves or the names they export"}`,
150
+ message: [
151
+ ...(paths.size === 0
152
+ ? []
153
+ : [
154
+ `commands the analysis does not read name ${[...paths].sort(bytewise).join(", ")}, so no finding is reported about ${paths.size === 1 ? "that file itself or the names it exports" : "those files themselves or the names they export"}`,
155
+ ]),
156
+ ...(unwritten.has(dir)
157
+ ? [
158
+ "a command runs a file whose path no word of it writes, so a finding that a file of the package is never built or never imported is possible at most",
159
+ ]
160
+ : []),
161
+ ].join("; "),
147
162
  }));
148
163
  }
149
164