@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
@@ -1,9 +1,11 @@
1
1
  /**
2
- * The classes of the target a value of one type carries, as a serializer walking the
3
- * value reaches them: through union and intersection constituents, array and tuple
4
- * elements, and the data members of the target's classes and of object types the
5
- * target writes. The walk stops at `any`, `unknown`, a type parameter, a function and
6
- * an interface or class of another program, so an instance held only there is missed.
2
+ * The classes of the target a value of one type carries, and the members of the other
3
+ * object types the target writes that it carries, as a serializer walking the value
4
+ * reaches them: through union and intersection constituents, array and tuple elements,
5
+ * and the data members and index signatures of the target's classes and of the
6
+ * interfaces and object types the target writes. The walk stops at `any`, `unknown`, a
7
+ * type parameter, a function and an interface or class of another program, so an
8
+ * instance held only there is missed.
7
9
  */
8
10
 
9
11
  import {
@@ -23,12 +25,25 @@ const WRITTEN = ObjectFlags.ObjectLiteral | ObjectFlags.Mapped;
23
25
  /** The symbols of an anonymous object type the target writes as a type. */
24
26
  const LITERAL_SYMBOLS = SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral;
25
27
 
26
- /** The classes a type's values carry, each asked of the checker once. */
28
+ /** What a value of one type carries that the target declares. */
29
+ export interface Reached {
30
+ /** The identifiers of the target's classes. */
31
+ readonly classes: ReadonlySet<string>;
32
+ /**
33
+ * The members of the interfaces and object types the target writes, other than its
34
+ * classes: each data member, and each method named `toJSON` or `toString`.
35
+ */
36
+ readonly members: readonly TSSymbol[];
37
+ }
38
+
39
+ /** What each type's values carry, each type asked of the checker once. */
27
40
  export interface ValueReach {
28
- /** The identifiers of the target's classes a value of `type` carries. */
29
- classesOf(type: Type): ReadonlySet<string>;
41
+ reachedFrom(type: Type): Reached;
30
42
  }
31
43
 
44
+ /** The two conversion methods a serializer or a formatter resolves on a value's own shape. */
45
+ const CONVERSION_NAMES: ReadonlySet<string> = new Set(["toJSON", "toString"]);
46
+
32
47
  /** The global array types, whose element type is what an array value carries. */
33
48
  function arrayTargets<Brand>(project: ProjectView<Brand>): ReadonlySet<number> {
34
49
  const checker = project.checker;
@@ -105,6 +120,29 @@ export function valueReach<Brand>(project: ProjectView<Brand>, held: Inventory):
105
120
  ];
106
121
  };
107
122
 
123
+ /** Whether the walk reads one type's members because the target writes the type, not as a class. */
124
+ const writtenObject = (type: Type): boolean => {
125
+ if (!type.isObjectType() || classOf(type) !== undefined) {
126
+ return false;
127
+ }
128
+ const target = targetOf(type);
129
+ const isList =
130
+ type.isTypeReference() &&
131
+ (arrays.has(target.id) ||
132
+ (target.isObjectType() && (target.objectFlags & ObjectFlags.Tuple) !== 0));
133
+ return !isList && isWritten(type);
134
+ };
135
+
136
+ /** The data members and conversion methods of one written object type. */
137
+ const carried = (type: Type): readonly TSSymbol[] =>
138
+ checker
139
+ .getPropertiesOfType(type)
140
+ .filter(
141
+ (property) =>
142
+ (property.flags & SymbolFlags.Property) !== 0 ||
143
+ ((property.flags & SymbolFlags.Method) !== 0 && CONVERSION_NAMES.has(property.name)),
144
+ );
145
+
108
146
  /** The types a value of one type holds, read once per type. */
109
147
  const childrenOf = (type: Type): readonly Type[] => {
110
148
  const known = children.get(type.id);
@@ -131,8 +169,9 @@ export function valueReach<Brand>(project: ProjectView<Brand>, held: Inventory):
131
169
  };
132
170
 
133
171
  return {
134
- classesOf: (type) => {
135
- const found = new Set<string>();
172
+ reachedFrom: (type) => {
173
+ const classes = new Set<string>();
174
+ const members: TSSymbol[] = [];
136
175
  const seen = new Set<number>();
137
176
  const pending: Type[] = [type];
138
177
  for (let next = pending.pop(); next !== undefined; next = pending.pop()) {
@@ -142,11 +181,13 @@ export function valueReach<Brand>(project: ProjectView<Brand>, held: Inventory):
142
181
  seen.add(next.id);
143
182
  const owner = classOf(next);
144
183
  if (owner !== undefined) {
145
- found.add(owner);
184
+ classes.add(owner);
185
+ } else if (writtenObject(next)) {
186
+ members.push(...carried(next));
146
187
  }
147
188
  pending.push(...childrenOf(next));
148
189
  }
149
- return found;
190
+ return { classes, members };
150
191
  },
151
192
  };
152
193
  }
@@ -1,8 +1,8 @@
1
- import { runAnalysis, type RunProject } from "../analysis.ts";
1
+ import { runAnalysis, runBaselineWrite, type RunAnalysis, type RunProject } from "../analysis.ts";
2
2
  import { ConfigError, type Format } from "../config.ts";
3
3
  import { CONFORMANCE, DECLARED_GAPS } from "../conformance.ts";
4
4
  import { moduleIdentity } from "../consumers.ts";
5
- import { analyzerProvenance, recordedFindings, verdictOf } from "../findings-pass.ts";
5
+ import { analyzerProvenance, verdictOf } from "../findings-pass.ts";
6
6
  import { joinPath, normalizePath, relativePath, resolvePath } from "../paths.ts";
7
7
  import type { Host } from "../host.ts";
8
8
  import {
@@ -16,7 +16,7 @@ import { json } from "../reporters/json.ts";
16
16
  import { RENDERINGS } from "../reporters/reporters.ts";
17
17
  import { parseTemplate, TemplateError, type Template } from "../reporters/template.ts";
18
18
  import { resolve } from "../resolve.ts";
19
- import { writeBaseline, type Recorded } from "../suppress-file.ts";
19
+ import { rowReason, writeBaseline, type Recorded } from "../suppress-file.ts";
20
20
  import { CONTRACT_VERSION } from "../version.ts";
21
21
  import { EXIT_CLEAN, EXIT_FAILURE, type Verb, type VerbOptions } from "./verb.ts";
22
22
 
@@ -153,8 +153,9 @@ interface Documents {
153
153
  /**
154
154
  * Analyzes the scope under the configuration and writes the JSON report to the path
155
155
  * `--report` names, each rendering `--format` names beside it at the report's path with the
156
- * format's suffix appended, and a baseline of every finding where `--baseline-write` names a
157
- * path. The template format renders the template `--template` names. Nothing is written to
156
+ * format's suffix appended, and where `--baseline-write` names a path the baseline a fixpoint
157
+ * over the analysis records, the report then being its first round, which reads no
158
+ * baseline. The template format renders the template `--template` names. Nothing is written to
158
159
  * the output stream; diagnostics go to the error stream and the verdict is the exit code, or 0
159
160
  * under `--exit-code=off`, and a rendering that cannot be written ends the run with 3.
160
161
  */
@@ -204,9 +205,26 @@ export const analyzeVerb: Verb = ({ err, host, inputs, scope, openClient, option
204
205
  let verdict: number;
205
206
  try {
206
207
  const root = runRelative(invoked, targetRoot);
207
- const { result, run } = runAnalysis(openClient(false), host, scoped, config, provenance, {
208
- production: true,
209
- });
208
+ const mode = { production: true };
209
+ let analysis: RunAnalysis;
210
+ if (documents.baseline === undefined) {
211
+ analysis = runAnalysis(openClient(false), host, scoped, config, provenance, mode);
212
+ recorded = [];
213
+ } else {
214
+ const reason = rowReason(analyzerProvenance(version));
215
+ const write = runBaselineWrite(
216
+ openClient(false),
217
+ host,
218
+ scoped,
219
+ config,
220
+ provenance,
221
+ mode,
222
+ reason,
223
+ );
224
+ analysis = write.first;
225
+ recorded = write.rows;
226
+ }
227
+ const { result, run } = analysis;
210
228
  const built = buildReport({
211
229
  contractVersion: CONTRACT_VERSION,
212
230
  version,
@@ -222,9 +240,6 @@ export const analyzeVerb: Verb = ({ err, host, inputs, scope, openClient, option
222
240
  result,
223
241
  testFileRules: run.testFileRules,
224
242
  });
225
- // The baseline records every finding, so its rows are taken before the cap bounds what
226
- // a rendering prints: a baseline missing a reported finding fails the next run on it.
227
- recorded = recordedFindings(result);
228
243
  report = capFindings(sortFindings(built, config.reporters.sort), config.reporters.maxFindings);
229
244
  verdict = verdictOf(result, config);
230
245
  } catch (error: unknown) {
@@ -1,25 +1,29 @@
1
1
  import { CONFORMANCE, type Conformance } from "../conformance.ts";
2
- import { ANALYZER_NAME, LANGUAGE, SCHEMA_VERSION } from "../report.ts";
2
+ import { ANALYZER_NAME, LANGUAGE, SCHEMA_VERSIONS_ACCEPTED } from "../report.ts";
3
3
  import { CONTRACT_VERSION } from "../version.ts";
4
4
  import { EXIT_CLEAN, EXIT_FAILURE, EXIT_USAGE, type Verb } from "./verb.ts";
5
5
 
6
6
  /**
7
7
  * The document `describe` writes: the analyzer, the Contract version it implements, the
8
8
  * report schema versions it reads, the languages it claims, and its recorded result over
9
- * the conformance corpus.
9
+ * the conformance corpus, a member the document omits where no run is recorded.
10
10
  */
11
- export function describeDocument(version: string, recorded: Conformance): string {
11
+ export function describeDocument(version: string, recorded: Conformance | undefined): string {
12
12
  const document = {
13
13
  name: ANALYZER_NAME,
14
14
  version,
15
15
  contract_version: CONTRACT_VERSION,
16
- schema_versions_accepted: [SCHEMA_VERSION],
16
+ schema_versions_accepted: SCHEMA_VERSIONS_ACCEPTED,
17
17
  languages: [LANGUAGE],
18
- conformance: {
19
- corpus_version: recorded.corpusVersion,
20
- result: recorded.result,
21
- digest: recorded.digest,
22
- },
18
+ ...(recorded === undefined
19
+ ? {}
20
+ : {
21
+ conformance: {
22
+ corpus_version: recorded.corpusVersion,
23
+ result: recorded.result,
24
+ digest: recorded.digest,
25
+ },
26
+ }),
23
27
  };
24
28
  return `${JSON.stringify(document, null, 2)}\n`;
25
29
  }
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 = "3.2.0";
7
+ export const CONTRACT_VERSION = "4.0.0";
@@ -1,178 +0,0 @@
1
- /**
2
- * The text of every live issue kind this analyzer's language carries, which a SARIF rule
3
- * describes the kind with, written out rather than read at run time. A test compares this
4
- * table against the Contract release the analyzer is written against.
5
- */
6
- /** Every live issue kind whose languages include this analyzer's, by code, in ascending order. */
7
- export const RULE_TEXTS = new Map([
8
- [
9
- "DS1001",
10
- {
11
- rule: "An exported symbol with no reference in the target and no reference from any loaded consumer. A symbol referenced only from its own declaration site counts as unreferenced.",
12
- },
13
- ],
14
- [
15
- "DS1002",
16
- {
17
- rule: "An unexported symbol with no reference in the target. A symbol referenced only from its own declaration site counts as unreferenced.",
18
- },
19
- ],
20
- [
21
- "DS1003",
22
- {
23
- rule: "A struct field, class member or type member with no reference, a private member included. A member referenced only from its own declaration site counts as unreferenced.",
24
- },
25
- ],
26
- [
27
- "DS1004",
28
- {
29
- rule: "A symbol with zero production references and at least one test reference: an unused-exported or unused-unexported candidate whose test reference count is not zero, reported once under this code. A reference from a consumer's test files is a test reference unless the configuration counts consumer tests as production.",
30
- },
31
- ],
32
- [
33
- "DS1005",
34
- {
35
- rule: "A test symbol whose set of referenced target symbols is non-empty and every member of that set is reported dead. A test that references at least one live target symbol is never reported, no notion of a test's subject and no name matching enters the rule, and the message states the rule. The test joins the dead component of the symbols it references.",
36
- },
37
- ],
38
- [
39
- "DS1006",
40
- {
41
- rule: "A symbol carrying a deprecation marker and no production reference: an unused-exported, unused-unexported or unused-member candidate whose symbol is deprecated, reported once under this code. Go identifies the marker by the convention the standard tools recognize, TypeScript by the documentation tag its tools recognize.",
42
- },
43
- ],
44
- [
45
- "DS1101",
46
- {
47
- rule: "An exported symbol whose every reference is inside the symbol's own package or module, reported as a candidate for unexporting. The subject is a package-level declaration or a method, and three subjects are excluded: an interface method, whose exportedness is the contract of the interface that declares it; a struct field, which an encoder reads by name; and a method that satisfies an interface some symbol uses as a type, which cannot be unexported without its type ceasing to satisfy that interface. The finding names the narrower visibility the references support. A declared cross-language edge counts as an out-of-package reference; where the edge's other side is unknown to the analyzer the finding is emitted pending.",
48
- precondition: "Closed world only. Reported always for a main package and an internal/ directory tree, and for a published package only when the configuration declares the consumer set complete and every declared consumer loads. A library with no consumer loaded and no complete consumer set declared gets this finding on its internal/ tree and its main packages and never on its published API.",
49
- },
50
- ],
51
- [
52
- "DS1103",
53
- {
54
- rule: "An unused exported symbol in a package or file no external code can import: an unused-exported candidate whose enclosing package or file is unimportable from outside, reported once under this code at the certain class, because unimportability is a property of the package graph rather than of the consumer set.",
55
- },
56
- ],
57
- [
58
- "DS1104",
59
- {
60
- rule: "An exported declaration used only inside its own file, reported as a candidate for removing the export keyword. The finding names the narrower visibility the references support.",
61
- precondition: "Closed world only. Reported in a file that is not an entry file and that either belongs to a project whose consumer set the configuration declares complete or is reached by no manifest export. A declared cross-language edge counts as a reference from outside the file; where the edge's other side is unknown to the analyzer the finding is emitted pending.",
62
- },
63
- ],
64
- [
65
- "DS1201",
66
- {
67
- rule: "An interface no symbol uses as a type, counting uses from every loaded module. The finding names the concrete implementations and their positions, and the interface's members join its dead component rather than being reported as independent unused declarations.",
68
- },
69
- ],
70
- [
71
- "DS1203",
72
- {
73
- rule: "An interface method that no call site invokes or selects through the interface, whatever the number of implementations. The finding names the concrete implementations and their positions.",
74
- precondition: "Exempt: every method of an interface that declares an unexported method, the sum-type shape whose method set exists to restrict the implementors; and every marker method, an interface method whose every implementation carries an empty body.",
75
- },
76
- ],
77
- [
78
- "DS1301",
79
- {
80
- rule: "A package-level or module-level variable, struct field, class member or collection that production code writes and never reads. In production mode a read from a test file counts as no read. A comparison of struct values reads every field of the type: in Go, a value of a struct type used as an operand of `==` or `!=`, as a map key, or as a `switch` tag or `case` expression is a read of every field of that type, transitively through the fields of every struct type it holds, recorded at the comparison, because equality reads every field and a field that decides equality carries information. In TypeScript a comparison of two object references reads no member, because `===` compares identity and never a member. The finding names each write position, so the deletion set is visible.",
81
- },
82
- ],
83
- [
84
- "DS1302",
85
- {
86
- rule: "An enumerated member that no symbol names, at the reachability class derived for the member and with no confidence ceiling below it. Every member of a type that carries a string, text or binary conversion method, or that a conversion from an integer or a wire value produces, is retained by the enum-group exemption first, so a member reached only by value is never a candidate.",
87
- },
88
- ],
89
- [
90
- "DS1303",
91
- {
92
- rule: "A type parameter of a function or method that no part of the declaration's signature and no part of the declaration's body names, at the certain class. The deletion is local to the declaration and the explicit instantiations the reference set already lists.",
93
- precondition: "Function and method type parameters only. A type parameter of a type declaration is never reported, because a phantom type parameter such as `type ID[T any] int` makes two instantiations distinct types while naming the parameter nowhere, so deleting it changes the program.",
94
- },
95
- ],
96
- [
97
- "DS1501",
98
- {
99
- rule: "A source file no configuration in the build matrix builds. On the Go side the finding names the build constraint that excluded the file. A file whose build constraint is the ignore tag is never reported: the toolchain applies no build constraint to a file named on its own command line, so that tag is the toolchain's convention for a file built by hand. A file any other custom tag excludes is reported under a matrix the configuration declares complete, because completeness is the maintainer's assertion that the listed configurations are every one the target builds, and a configuration the maintainer builds by hand belongs in that list.",
100
- precondition: 'Reported only when the configuration declares the build matrix complete, and never for a file the toolchain ignored solely because it imports "C" under a build with cgo disabled; such a file is recorded as excluded by cgo rather than as never built.',
101
- },
102
- ],
103
- [
104
- "DS1502",
105
- {
106
- rule: "A source file that no import reaches, that no root names, and in which no declared cross-language edge names a declaration. An edge's side names a declaration as a root names one, so a file holding a declaration an edge names is evaluated with the edge rather than reported: whether that declaration is dead is the edge evaluation's to say, and the merge resolves it against the paired side.",
107
- },
108
- ],
109
- [
110
- "DS1601",
111
- {
112
- rule: "A directly declared dependency that no import in the target needs. On the Go side, a direct require whose module provides no package any target package or test variant imports. On the TypeScript side, a manifest dependency, development dependency or peer dependency the project's import closure does not need. A deletion finding whose fix would remove the last use of a dependency names that dependency.",
113
- precondition: "On the Go side the rule is the semantics of `go mod tidy -diff` exactly: a requirement marked indirect is never reported, because it exists to pin a transitive version and removing it changes the build list.",
114
- },
115
- ],
116
- [
117
- "DS1701",
118
- {
119
- rule: "A suppression that carries no reason, in any of the three documents: an inline directive, an ignore-file entry or a baseline row. For the ignore file and the baseline, an entry or a row whose reason field is absent, empty or whitespace only is refused and reported rather than matched.",
120
- },
121
- ],
122
- [
123
- "DS1702",
124
- {
125
- rule: "An ignore-file entry or a baseline row that names a symbol and no file path. The entry is reported rather than matched, so a bare name cannot mask a match anywhere else in the project; the inline directive is scoped by its position and cannot be unscoped.",
126
- },
127
- ],
128
- [
129
- "DS1703",
130
- {
131
- rule: "A suppression that matches no current finding, at either mechanism and in the baseline alike. The run exits with the findings code when at least one is reported. The kind is fixed on at deny: no flag, no severity setting and no per-mechanism exception reduces it below a finding, and a configuration naming this code under a severity key is an unimplemented key.",
132
- },
133
- ],
134
- [
135
- "DS1704",
136
- {
137
- rule: "A configured root that matches no symbol, or a configured root pattern that matches no symbol. A root set nobody checks silently changes every result, so a stale one is a finding. The kind is fixed on at deny: no flag, no severity setting and no exception reduces it below a finding, and a configuration naming this code under a severity key is an unimplemented key.",
138
- },
139
- ],
140
- [
141
- "DS1705",
142
- {
143
- rule: "A declared cross-language edge with a side that at least one analyzer evaluated and every evaluation of that side reports absent, so no analyzer that ran enumerates that side's symbol. Emitted by the merge, once per edge, never by an analyzer, so a stale edge is visible rather than silently inert. A dead side paired with an absent side drops its pending finding, and the edge is the reported defect: a misspelled reference must not turn a live pairing into a deletion.",
144
- },
145
- ],
146
- [
147
- "DS1801",
148
- {
149
- rule: "A parameter with no reference inside its function body, on a function whose signature is free to change.",
150
- precondition: "The signature must be free, defined as follows: the function is not a method retained by interface satisfaction, is not used as a value, is not a go:linkname or cgo target, and is not a stub whose body is empty or only panics. A parameter its body never names is dead whatever the callers, so a published declaration of a library is reported too, with the fixability the vocabulary gives the kind: the signature change is a breaking change.",
151
- },
152
- ],
153
- [
154
- "DS1803",
155
- {
156
- rule: "A result value that no call site of the function uses, on a function whose signature is free to change.",
157
- precondition: "The same free-signature rule as unused-parameter, plus a closed-world condition: every call site of the function must be in the loaded graph, because an unknown caller may consume the result, so the kind reports only for a function whose callers are all visible.",
158
- },
159
- ],
160
- [
161
- "DS1805",
162
- {
163
- rule: "A statement that control flow cannot reach, at the precision the language's compiler applies to the same construct.",
164
- },
165
- ],
166
- [
167
- "DS1807",
168
- {
169
- rule: "A write to a local variable with no read before the next write to it or the end of its scope, computed on the same read-and-write classification the write-only-symbol kind uses. The finding names the write position.",
170
- },
171
- ],
172
- [
173
- "DS1809",
174
- {
175
- rule: "A switch case whose type or value an earlier case in the same switch already covers.",
176
- },
177
- ],
178
- ]);
@@ -1,195 +0,0 @@
1
- /**
2
- * The text of every live issue kind this analyzer's language carries, which a SARIF rule
3
- * describes the kind with, written out rather than read at run time. A test compares this
4
- * table against the Contract release the analyzer is written against.
5
- */
6
-
7
- /** The text one rule is described with. */
8
- interface RuleText {
9
- /** The kind's rule, whole. */
10
- readonly rule: string;
11
- /** The condition the kind reports under, where it declares one. */
12
- readonly precondition?: string;
13
- }
14
-
15
- /** Every live issue kind whose languages include this analyzer's, by code, in ascending order. */
16
- export const RULE_TEXTS: ReadonlyMap<string, RuleText> = new Map<string, RuleText>([
17
- [
18
- "DS1001",
19
- {
20
- rule: "An exported symbol with no reference in the target and no reference from any loaded consumer. A symbol referenced only from its own declaration site counts as unreferenced.",
21
- },
22
- ],
23
- [
24
- "DS1002",
25
- {
26
- rule: "An unexported symbol with no reference in the target. A symbol referenced only from its own declaration site counts as unreferenced.",
27
- },
28
- ],
29
- [
30
- "DS1003",
31
- {
32
- rule: "A struct field, class member or type member with no reference, a private member included. A member referenced only from its own declaration site counts as unreferenced.",
33
- },
34
- ],
35
- [
36
- "DS1004",
37
- {
38
- rule: "A symbol with zero production references and at least one test reference: an unused-exported or unused-unexported candidate whose test reference count is not zero, reported once under this code. A reference from a consumer's test files is a test reference unless the configuration counts consumer tests as production.",
39
- },
40
- ],
41
- [
42
- "DS1005",
43
- {
44
- rule: "A test symbol whose set of referenced target symbols is non-empty and every member of that set is reported dead. A test that references at least one live target symbol is never reported, no notion of a test's subject and no name matching enters the rule, and the message states the rule. The test joins the dead component of the symbols it references.",
45
- },
46
- ],
47
- [
48
- "DS1006",
49
- {
50
- rule: "A symbol carrying a deprecation marker and no production reference: an unused-exported, unused-unexported or unused-member candidate whose symbol is deprecated, reported once under this code. Go identifies the marker by the convention the standard tools recognize, TypeScript by the documentation tag its tools recognize.",
51
- },
52
- ],
53
- [
54
- "DS1101",
55
- {
56
- rule: "An exported symbol whose every reference is inside the symbol's own package or module, reported as a candidate for unexporting. The subject is a package-level declaration or a method, and three subjects are excluded: an interface method, whose exportedness is the contract of the interface that declares it; a struct field, which an encoder reads by name; and a method that satisfies an interface some symbol uses as a type, which cannot be unexported without its type ceasing to satisfy that interface. The finding names the narrower visibility the references support. A declared cross-language edge counts as an out-of-package reference; where the edge's other side is unknown to the analyzer the finding is emitted pending.",
57
- precondition:
58
- "Closed world only. Reported always for a main package and an internal/ directory tree, and for a published package only when the configuration declares the consumer set complete and every declared consumer loads. A library with no consumer loaded and no complete consumer set declared gets this finding on its internal/ tree and its main packages and never on its published API.",
59
- },
60
- ],
61
- [
62
- "DS1103",
63
- {
64
- rule: "An unused exported symbol in a package or file no external code can import: an unused-exported candidate whose enclosing package or file is unimportable from outside, reported once under this code at the certain class, because unimportability is a property of the package graph rather than of the consumer set.",
65
- },
66
- ],
67
- [
68
- "DS1104",
69
- {
70
- rule: "An exported declaration used only inside its own file, reported as a candidate for removing the export keyword. The finding names the narrower visibility the references support.",
71
- precondition:
72
- "Closed world only. Reported in a file that is not an entry file and that either belongs to a project whose consumer set the configuration declares complete or is reached by no manifest export. A declared cross-language edge counts as a reference from outside the file; where the edge's other side is unknown to the analyzer the finding is emitted pending.",
73
- },
74
- ],
75
- [
76
- "DS1201",
77
- {
78
- rule: "An interface no symbol uses as a type, counting uses from every loaded module. The finding names the concrete implementations and their positions, and the interface's members join its dead component rather than being reported as independent unused declarations.",
79
- },
80
- ],
81
- [
82
- "DS1203",
83
- {
84
- rule: "An interface method that no call site invokes or selects through the interface, whatever the number of implementations. The finding names the concrete implementations and their positions.",
85
- precondition:
86
- "Exempt: every method of an interface that declares an unexported method, the sum-type shape whose method set exists to restrict the implementors; and every marker method, an interface method whose every implementation carries an empty body.",
87
- },
88
- ],
89
- [
90
- "DS1301",
91
- {
92
- rule: "A package-level or module-level variable, struct field, class member or collection that production code writes and never reads. In production mode a read from a test file counts as no read. A comparison of struct values reads every field of the type: in Go, a value of a struct type used as an operand of `==` or `!=`, as a map key, or as a `switch` tag or `case` expression is a read of every field of that type, transitively through the fields of every struct type it holds, recorded at the comparison, because equality reads every field and a field that decides equality carries information. In TypeScript a comparison of two object references reads no member, because `===` compares identity and never a member. The finding names each write position, so the deletion set is visible.",
93
- },
94
- ],
95
- [
96
- "DS1302",
97
- {
98
- rule: "An enumerated member that no symbol names, at the reachability class derived for the member and with no confidence ceiling below it. Every member of a type that carries a string, text or binary conversion method, or that a conversion from an integer or a wire value produces, is retained by the enum-group exemption first, so a member reached only by value is never a candidate.",
99
- },
100
- ],
101
- [
102
- "DS1303",
103
- {
104
- rule: "A type parameter of a function or method that no part of the declaration's signature and no part of the declaration's body names, at the certain class. The deletion is local to the declaration and the explicit instantiations the reference set already lists.",
105
- precondition:
106
- "Function and method type parameters only. A type parameter of a type declaration is never reported, because a phantom type parameter such as `type ID[T any] int` makes two instantiations distinct types while naming the parameter nowhere, so deleting it changes the program.",
107
- },
108
- ],
109
- [
110
- "DS1501",
111
- {
112
- rule: "A source file no configuration in the build matrix builds. On the Go side the finding names the build constraint that excluded the file. A file whose build constraint is the ignore tag is never reported: the toolchain applies no build constraint to a file named on its own command line, so that tag is the toolchain's convention for a file built by hand. A file any other custom tag excludes is reported under a matrix the configuration declares complete, because completeness is the maintainer's assertion that the listed configurations are every one the target builds, and a configuration the maintainer builds by hand belongs in that list.",
113
- precondition:
114
- 'Reported only when the configuration declares the build matrix complete, and never for a file the toolchain ignored solely because it imports "C" under a build with cgo disabled; such a file is recorded as excluded by cgo rather than as never built.',
115
- },
116
- ],
117
- [
118
- "DS1502",
119
- {
120
- rule: "A source file that no import reaches, that no root names, and in which no declared cross-language edge names a declaration. An edge's side names a declaration as a root names one, so a file holding a declaration an edge names is evaluated with the edge rather than reported: whether that declaration is dead is the edge evaluation's to say, and the merge resolves it against the paired side.",
121
- },
122
- ],
123
- [
124
- "DS1601",
125
- {
126
- rule: "A directly declared dependency that no import in the target needs. On the Go side, a direct require whose module provides no package any target package or test variant imports. On the TypeScript side, a manifest dependency, development dependency or peer dependency the project's import closure does not need. A deletion finding whose fix would remove the last use of a dependency names that dependency.",
127
- precondition:
128
- "On the Go side the rule is the semantics of `go mod tidy -diff` exactly: a requirement marked indirect is never reported, because it exists to pin a transitive version and removing it changes the build list.",
129
- },
130
- ],
131
- [
132
- "DS1701",
133
- {
134
- rule: "A suppression that carries no reason, in any of the three documents: an inline directive, an ignore-file entry or a baseline row. For the ignore file and the baseline, an entry or a row whose reason field is absent, empty or whitespace only is refused and reported rather than matched.",
135
- },
136
- ],
137
- [
138
- "DS1702",
139
- {
140
- rule: "An ignore-file entry or a baseline row that names a symbol and no file path. The entry is reported rather than matched, so a bare name cannot mask a match anywhere else in the project; the inline directive is scoped by its position and cannot be unscoped.",
141
- },
142
- ],
143
- [
144
- "DS1703",
145
- {
146
- rule: "A suppression that matches no current finding, at either mechanism and in the baseline alike. The run exits with the findings code when at least one is reported. The kind is fixed on at deny: no flag, no severity setting and no per-mechanism exception reduces it below a finding, and a configuration naming this code under a severity key is an unimplemented key.",
147
- },
148
- ],
149
- [
150
- "DS1704",
151
- {
152
- rule: "A configured root that matches no symbol, or a configured root pattern that matches no symbol. A root set nobody checks silently changes every result, so a stale one is a finding. The kind is fixed on at deny: no flag, no severity setting and no exception reduces it below a finding, and a configuration naming this code under a severity key is an unimplemented key.",
153
- },
154
- ],
155
- [
156
- "DS1705",
157
- {
158
- rule: "A declared cross-language edge with a side that at least one analyzer evaluated and every evaluation of that side reports absent, so no analyzer that ran enumerates that side's symbol. Emitted by the merge, once per edge, never by an analyzer, so a stale edge is visible rather than silently inert. A dead side paired with an absent side drops its pending finding, and the edge is the reported defect: a misspelled reference must not turn a live pairing into a deletion.",
159
- },
160
- ],
161
- [
162
- "DS1801",
163
- {
164
- rule: "A parameter with no reference inside its function body, on a function whose signature is free to change.",
165
- precondition:
166
- "The signature must be free, defined as follows: the function is not a method retained by interface satisfaction, is not used as a value, is not a go:linkname or cgo target, and is not a stub whose body is empty or only panics. A parameter its body never names is dead whatever the callers, so a published declaration of a library is reported too, with the fixability the vocabulary gives the kind: the signature change is a breaking change.",
167
- },
168
- ],
169
- [
170
- "DS1803",
171
- {
172
- rule: "A result value that no call site of the function uses, on a function whose signature is free to change.",
173
- precondition:
174
- "The same free-signature rule as unused-parameter, plus a closed-world condition: every call site of the function must be in the loaded graph, because an unknown caller may consume the result, so the kind reports only for a function whose callers are all visible.",
175
- },
176
- ],
177
- [
178
- "DS1805",
179
- {
180
- rule: "A statement that control flow cannot reach, at the precision the language's compiler applies to the same construct.",
181
- },
182
- ],
183
- [
184
- "DS1807",
185
- {
186
- rule: "A write to a local variable with no read before the next write to it or the end of its scope, computed on the same read-and-write classification the write-only-symbol kind uses. The finding names the write position.",
187
- },
188
- ],
189
- [
190
- "DS1809",
191
- {
192
- rule: "A switch case whose type or value an earlier case in the same switch already covers.",
193
- },
194
- ],
195
- ]);