@cplieger/deadset-ts 3.12.0 → 3.13.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 (63) hide show
  1. package/README.md +2 -2
  2. package/dist/src/analysis.js +100 -27
  3. package/dist/src/components.js +4 -2
  4. package/dist/src/configured-declarations.js +36 -0
  5. package/dist/src/conformance-record.js +2 -2
  6. package/dist/src/edges.js +4 -1
  7. package/dist/src/findings/completion.js +37 -8
  8. package/dist/src/findings/emitters.js +5 -5
  9. package/dist/src/findings/intra-function.js +91 -2
  10. package/dist/src/findings/self-check.js +30 -7
  11. package/dist/src/findings/unused-declarations.js +15 -3
  12. package/dist/src/findings-pass.js +18 -11
  13. package/dist/src/graph.js +7 -7
  14. package/dist/src/intra-function-parts.js +643 -0
  15. package/dist/src/kinds.js +337 -35
  16. package/dist/src/reflective-lookup.js +35 -2
  17. package/dist/src/report.js +11 -2
  18. package/dist/src/reporters/sarif.js +20 -15
  19. package/dist/src/reporters/template.js +64 -5
  20. package/dist/src/roots.js +13 -8
  21. package/dist/src/serialization-contract.js +41 -22
  22. package/dist/src/signatures.js +32 -0
  23. package/dist/src/suppress-file.js +27 -6
  24. package/dist/src/suppress-inline.js +8 -1
  25. package/dist/src/suppress.js +27 -0
  26. package/dist/src/value-reach.js +33 -9
  27. package/dist/src/verbs/analyze.js +19 -11
  28. package/dist/src/verbs/describe.js +12 -8
  29. package/dist/src/version.js +1 -1
  30. package/jsr.json +1 -1
  31. package/package.json +1 -1
  32. package/src/analysis.ts +167 -48
  33. package/src/components.ts +4 -2
  34. package/src/configured-declarations.ts +57 -1
  35. package/src/conformance-record.ts +2 -2
  36. package/src/edges.ts +4 -1
  37. package/src/finding.ts +5 -1
  38. package/src/findings/completion.ts +46 -10
  39. package/src/findings/emitter.ts +3 -0
  40. package/src/findings/emitters.ts +9 -5
  41. package/src/findings/intra-function.ts +106 -3
  42. package/src/findings/self-check.ts +48 -7
  43. package/src/findings/unused-declarations.ts +18 -4
  44. package/src/findings-pass.ts +26 -11
  45. package/src/graph.ts +7 -7
  46. package/src/intra-function-parts.ts +871 -0
  47. package/src/kinds.ts +355 -41
  48. package/src/reflective-lookup.ts +42 -2
  49. package/src/report.ts +18 -2
  50. package/src/reporters/sarif.ts +24 -16
  51. package/src/reporters/template.ts +69 -6
  52. package/src/roots.ts +14 -9
  53. package/src/serialization-contract.ts +47 -30
  54. package/src/signatures.ts +55 -0
  55. package/src/suppress-file.ts +34 -6
  56. package/src/suppress-inline.ts +8 -1
  57. package/src/suppress.ts +31 -0
  58. package/src/value-reach.ts +53 -12
  59. package/src/verbs/analyze.ts +26 -11
  60. package/src/verbs/describe.ts +13 -9
  61. package/src/version.ts +1 -1
  62. package/dist/src/reporters/rules.js +0 -178
  63. package/src/reporters/rules.ts +0 -195
@@ -111,7 +111,15 @@ function messageOf(code, judged) {
111
111
  return `${subject} has no reference in the target`;
112
112
  }
113
113
  /** The findings of the unused-declarations family, `DS1000` to `DS1099`. */
114
- export const unusedDeclarations = (input) => {
114
+ export const unusedDeclarations = (input) => familyFindings(input, false);
115
+ /**
116
+ * The finding each member of a dead container would carry were its container live: what
117
+ * a record on such a member is matched against, since the report carries the container's
118
+ * finding rather than one of the member's own.
119
+ */
120
+ export const fallenMembers = (input) => familyFindings(input, true);
121
+ /** The family's findings, or, where `fallen` is set, its dead containers' members' alone. */
122
+ function familyFindings(input, fallen) {
115
123
  const union = input.swept.matrix.union;
116
124
  const dead = new Set(input.swept.sweep.candidates.map((candidate) => candidate.id));
117
125
  const unreachable = unreachableExports(input);
@@ -122,11 +130,15 @@ export const unusedDeclarations = (input) => {
122
130
  if (symbol === undefined) {
123
131
  continue;
124
132
  }
133
+ const containerDead = dead.has(symbol.parent);
134
+ if (fallen !== containerDead) {
135
+ continue;
136
+ }
125
137
  const judged = {
126
138
  candidate,
127
139
  symbol,
128
140
  test: union.test[at] === true,
129
- containerDead: dead.has(symbol.parent),
141
+ containerDead: containerDead && !fallen,
130
142
  deprecated: input.deprecated.has(symbol.id),
131
143
  unreachable: unreachable.has(symbol.id),
132
144
  };
@@ -148,4 +160,4 @@ export const unusedDeclarations = (input) => {
148
160
  });
149
161
  }
150
162
  return found;
151
- };
163
+ }
@@ -76,18 +76,25 @@ export function verdictOf(result, config) {
76
76
  return failing ? EXIT_FINDINGS : EXIT_CLEAN;
77
77
  }
78
78
  /**
79
- * The findings of a report as a baseline records them, in report order. A finding about a
80
- * row of a document is not recorded: no record withholds one, so a row recording it would
81
- * be stale on the first read back.
79
+ * The rows one round of a baseline write records from its findings, in their order. A
80
+ * finding about a row of a document is not recorded: no record withholds one, so a row
81
+ * recording it would be stale on the first read back. Two findings that would record the
82
+ * same row, two parts of one declaration under one code, record it once.
82
83
  */
83
- export function recordedFindings(result) {
84
- return result.findings
85
- .filter((finding) => !isRowSubject(finding.symbol.kind))
86
- .map((finding) => ({
87
- code: finding.code,
88
- symbol: finding.symbol.ref,
89
- path: finding.position.path,
90
- }));
84
+ export function recordedFindings(findings) {
85
+ const rows = new Map();
86
+ for (const finding of findings) {
87
+ if (isRowSubject(finding.symbol.kind)) {
88
+ continue;
89
+ }
90
+ const row = { code: finding.code, symbol: finding.symbol.ref, path: finding.position.path };
91
+ rows.set(rowKey(row), rows.get(rowKey(row)) ?? row);
92
+ }
93
+ return [...rows.values()];
94
+ }
95
+ /** One row's identity: its code, its symbol and its path. */
96
+ export function rowKey(row) {
97
+ return `${row.code}\u0000${row.symbol}\u0000${row.path}`;
91
98
  }
92
99
  /** The analyzer identity a baseline this analyzer writes names as its rows' provenance. */
93
100
  export function analyzerProvenance(version) {
package/dist/src/graph.js CHANGED
@@ -32,15 +32,15 @@ const SWEPT = {
32
32
  };
33
33
  /**
34
34
  * Whether a root of each kind names a caller, which holds it live under both relations: a
35
- * tool reads the configuration it loads, a runtime runs a test file, a setup file and a
36
- * worker, and a configured root asserts a caller. The other kinds only suppose a consumer
37
- * that imports what a manifest entry, a binary or an entry file exports, or names a
38
- * library's published API, so such a root is live under reachability alone.
35
+ * tool reads the configuration it loads, a runtime runs a test file, a setup file, a
36
+ * worker and a command, the manifest names what enters the package, and an entry file, a
37
+ * configured root and a pattern assert a caller. A library's published API only supposes
38
+ * a consumer the run may not see, so it is live under reachability alone.
39
39
  */
40
40
  const NAMES_A_CALLER = {
41
- "entry-file": false,
42
- "manifest-entry": false,
43
- "manifest-binary": false,
41
+ "entry-file": true,
42
+ "manifest-entry": true,
43
+ "manifest-binary": true,
44
44
  "published-api": false,
45
45
  configured: true,
46
46
  pattern: true,