@cplieger/deadset-ts 5.1.1 → 5.2.1

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 (60) hide show
  1. package/dist/src/analysis.js +7 -4
  2. package/dist/src/config.js +3 -0
  3. package/dist/src/configuration-files.js +23 -24
  4. package/dist/src/conformance-record.js +2 -2
  5. package/dist/src/contextual-uses.js +25 -4
  6. package/dist/src/convention-rows.js +7 -0
  7. package/dist/src/conventions.js +97 -33
  8. package/dist/src/dependencies.js +8 -0
  9. package/dist/src/entry-point-gaps.js +10 -26
  10. package/dist/src/entry-points.js +4 -0
  11. package/dist/src/findings/completion.js +27 -11
  12. package/dist/src/findings/interfaces.js +2 -6
  13. package/dist/src/findings/intra-function.js +15 -3
  14. package/dist/src/findings/unused-declarations.js +5 -6
  15. package/dist/src/findings/visibility-narrowing.js +6 -1
  16. package/dist/src/generated-file.js +72 -12
  17. package/dist/src/graph.js +5 -4
  18. package/dist/src/html-entries.js +137 -0
  19. package/dist/src/kinds.js +2 -2
  20. package/dist/src/manifest.js +5 -1
  21. package/dist/src/matrix.js +9 -3
  22. package/dist/src/namespace-objects.js +158 -0
  23. package/dist/src/partial.js +1 -1
  24. package/dist/src/references.js +120 -3
  25. package/dist/src/roots.js +52 -3
  26. package/dist/src/sweep.js +17 -0
  27. package/dist/src/test-support.js +35 -23
  28. package/dist/src/version.js +1 -1
  29. package/jsr.json +1 -1
  30. package/package.json +2 -2
  31. package/src/analysis.ts +12 -5
  32. package/src/config.ts +3 -0
  33. package/src/configuration-files.ts +28 -24
  34. package/src/conformance-record.ts +2 -2
  35. package/src/contextual-uses.ts +31 -4
  36. package/src/convention-rows.ts +15 -0
  37. package/src/conventions.ts +119 -30
  38. package/src/dependencies.ts +9 -0
  39. package/src/entry-point-gaps.ts +11 -28
  40. package/src/entry-points.ts +7 -1
  41. package/src/exempt.ts +1 -4
  42. package/src/file-facts.ts +1 -1
  43. package/src/findings/completion.ts +31 -11
  44. package/src/findings/interfaces.ts +2 -9
  45. package/src/findings/intra-function.ts +17 -3
  46. package/src/findings/unused-declarations.ts +5 -8
  47. package/src/findings/visibility-narrowing.ts +7 -1
  48. package/src/generated-file.ts +80 -12
  49. package/src/graph.ts +5 -4
  50. package/src/html-entries.ts +170 -0
  51. package/src/kinds.ts +2 -2
  52. package/src/manifest.ts +9 -3
  53. package/src/matrix.ts +21 -3
  54. package/src/namespace-objects.ts +216 -0
  55. package/src/partial.ts +1 -1
  56. package/src/references.ts +161 -3
  57. package/src/roots.ts +69 -10
  58. package/src/sweep.ts +19 -0
  59. package/src/test-support.ts +34 -22
  60. package/src/version.ts +1 -1
@@ -1,8 +1,8 @@
1
1
  /**
2
- * Test-support code: a file that is not a test file by name and that only test code
3
- * imports. At least one test file reaches it, directly or through other such files, and
4
- * nothing else does, so it is judged with the tests: what it references is referenced by
5
- * test code, and a declaration of it is live while test code references it.
2
+ * Test-support code: the files only tests reach. A test reaches each one through a chain
3
+ * of references, and every reference to a declaration of one, an import for its effects
4
+ * included, is written in a test file or in another such file, so it is judged with the
5
+ * tests: what it references is referenced by test code.
6
6
  */
7
7
 
8
8
  import type { InventorySymbol } from "./inventory.ts";
@@ -13,10 +13,11 @@ import type { Root } from "./roots.ts";
13
13
  const SKIP_ROOT = "type-error";
14
14
 
15
15
  /**
16
- * The files of one project that are test-support code, below the target root. A file
17
- * holding a root is not one, because a root has a caller outside the import graph: a
18
- * runtime, a tool, a configuration, or a consumer of a library's published API.
19
- * `testFiles` are the files the test-file rules classified.
16
+ * The files of one project that are test-support code, below the target root: the
17
+ * largest set of files a test file reaches, none of them a test file or holding a root,
18
+ * whose every user outside the set is a test file. A root has a caller outside the
19
+ * reference graph: a runtime, a tool, a configuration, or a consumer of a library's
20
+ * published API. `testFiles` are the files the test-file rules classified.
20
21
  */
21
22
  export function testSupportFiles(
22
23
  symbols: readonly InventorySymbol[],
@@ -26,34 +27,45 @@ export function testSupportFiles(
26
27
  ): ReadonlySet<string> {
27
28
  const fileOf = new Map(symbols.map((symbol) => [symbol.id, symbol.position.path]));
28
29
  const users = new Map<string, Set<string>>();
30
+ const uses = new Map<string, Set<string>>();
31
+ const add = (map: Map<string, Set<string>>, key: string, value: string): void => {
32
+ const held = map.get(key);
33
+ if (held === undefined) {
34
+ map.set(key, new Set([value]));
35
+ } else {
36
+ held.add(value);
37
+ }
38
+ };
29
39
  for (const reference of references) {
30
40
  const used = fileOf.get(reference.to);
31
41
  const from = reference.position.path;
32
42
  if (reference.consumer !== undefined || used === undefined || used === from) {
33
43
  continue;
34
44
  }
35
- const held = users.get(used);
36
- if (held === undefined) {
37
- users.set(used, new Set([from]));
38
- } else {
39
- held.add(from);
40
- }
45
+ add(users, used, from);
46
+ add(uses, from, used);
41
47
  }
42
48
  const tests = new Set(testFiles);
43
49
  const rooted = new Set(
44
50
  roots.filter((root) => root.kind !== SKIP_ROOT).flatMap((root) => fileOf.get(root.id) ?? []),
45
51
  );
46
- const candidates = [...users.keys()].filter((path) => !tests.has(path) && !rooted.has(path));
47
- const support = new Set<string>();
52
+ const reached = new Set<string>();
53
+ const queue = [...tests];
54
+ for (let path = queue.pop(); path !== undefined; path = queue.pop()) {
55
+ for (const next of uses.get(path) ?? []) {
56
+ if (!reached.has(next) && !tests.has(next)) {
57
+ reached.add(next);
58
+ queue.push(next);
59
+ }
60
+ }
61
+ }
62
+ const support = new Set([...reached].filter((path) => !rooted.has(path)));
48
63
  for (let changed = true; changed;) {
49
64
  changed = false;
50
- for (const path of candidates) {
51
- if (support.has(path)) {
52
- continue;
53
- }
65
+ for (const path of support) {
54
66
  const from = users.get(path) ?? new Set<string>();
55
- if ([...from].every((one) => tests.has(one) || support.has(one))) {
56
- support.add(path);
67
+ if (![...from].every((one) => tests.has(one) || support.has(one))) {
68
+ support.delete(path);
57
69
  changed = true;
58
70
  }
59
71
  }
package/src/version.ts CHANGED
@@ -4,4 +4,4 @@
4
4
  * independently of the analyzer's own version, which is the one the host answers
5
5
  * from the package the analyzer was installed from.
6
6
  */
7
- export const CONTRACT_VERSION = "5.2.0";
7
+ export const CONTRACT_VERSION = "5.3.0";