@opensip-cli/checks-typescript 0.1.9 → 0.1.11
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.
- package/README.md +4 -2
- package/dist/__tests__/all-checks-execute.test.d.ts.map +1 -1
- package/dist/__tests__/all-checks-execute.test.js +0 -1
- package/dist/__tests__/all-checks-execute.test.js.map +1 -1
- package/dist/__tests__/behavior-fixtures-2.test.d.ts.map +1 -1
- package/dist/__tests__/behavior-fixtures-2.test.js +0 -1
- package/dist/__tests__/behavior-fixtures-2.test.js.map +1 -1
- package/dist/__tests__/behavior-fixtures-3.test.d.ts.map +1 -1
- package/dist/__tests__/behavior-fixtures-3.test.js +0 -1
- package/dist/__tests__/behavior-fixtures-3.test.js.map +1 -1
- package/dist/__tests__/behavior-fixtures-4.test.d.ts.map +1 -1
- package/dist/__tests__/behavior-fixtures-4.test.js +0 -1
- package/dist/__tests__/behavior-fixtures-4.test.js.map +1 -1
- package/dist/__tests__/behavior-fixtures-5.test.d.ts.map +1 -1
- package/dist/__tests__/behavior-fixtures-5.test.js +0 -1
- package/dist/__tests__/behavior-fixtures-5.test.js.map +1 -1
- package/dist/__tests__/behavior-fixtures-6.test.js +10 -0
- package/dist/__tests__/behavior-fixtures-6.test.js.map +1 -1
- package/dist/__tests__/behavior-fixtures.test.d.ts.map +1 -1
- package/dist/__tests__/behavior-fixtures.test.js +2 -4
- package/dist/__tests__/behavior-fixtures.test.js.map +1 -1
- package/dist/__tests__/branch-fixtures-2.test.d.ts.map +1 -1
- package/dist/__tests__/branch-fixtures-2.test.js +0 -1
- package/dist/__tests__/branch-fixtures-2.test.js.map +1 -1
- package/dist/__tests__/branch-fixtures-3.test.d.ts.map +1 -1
- package/dist/__tests__/branch-fixtures-3.test.js +0 -1
- package/dist/__tests__/branch-fixtures-3.test.js.map +1 -1
- package/dist/__tests__/branch-fixtures.test.d.ts.map +1 -1
- package/dist/__tests__/branch-fixtures.test.js +0 -1
- package/dist/__tests__/branch-fixtures.test.js.map +1 -1
- package/dist/checks/architecture/__tests__/live-view-through-cli-live.test.d.ts +2 -0
- package/dist/checks/architecture/__tests__/live-view-through-cli-live.test.d.ts.map +1 -0
- package/dist/checks/architecture/__tests__/live-view-through-cli-live.test.js +13 -0
- package/dist/checks/architecture/__tests__/live-view-through-cli-live.test.js.map +1 -0
- package/dist/checks/architecture/contracts-schema-consistency.d.ts.map +1 -1
- package/dist/checks/architecture/contracts-schema-consistency.js +0 -3
- package/dist/checks/architecture/contracts-schema-consistency.js.map +1 -1
- package/dist/checks/architecture/drizzle-orm-migration-guardrails.d.ts.map +1 -1
- package/dist/checks/architecture/drizzle-orm-migration-guardrails.js +1 -0
- package/dist/checks/architecture/drizzle-orm-migration-guardrails.js.map +1 -1
- package/dist/checks/architecture/index.d.ts +1 -0
- package/dist/checks/architecture/index.d.ts.map +1 -1
- package/dist/checks/architecture/index.js +1 -0
- package/dist/checks/architecture/index.js.map +1 -1
- package/dist/checks/architecture/live-view-through-cli-live.d.ts +8 -0
- package/dist/checks/architecture/live-view-through-cli-live.d.ts.map +1 -0
- package/dist/checks/architecture/live-view-through-cli-live.js +43 -0
- package/dist/checks/architecture/live-view-through-cli-live.js.map +1 -0
- package/dist/checks/architecture/missing-type-exports.d.ts.map +1 -1
- package/dist/checks/architecture/missing-type-exports.js +1 -1
- package/dist/checks/architecture/missing-type-exports.js.map +1 -1
- package/dist/checks/architecture/module-coupling-fan-out.d.ts.map +1 -1
- package/dist/checks/architecture/module-coupling-fan-out.js +6 -2
- package/dist/checks/architecture/module-coupling-fan-out.js.map +1 -1
- package/dist/checks/architecture/no-bootstrap-tool-import.d.ts.map +1 -1
- package/dist/checks/architecture/no-bootstrap-tool-import.js +1 -0
- package/dist/checks/architecture/no-bootstrap-tool-import.js.map +1 -1
- package/dist/checks/architecture/no-run-done-result.d.ts.map +1 -1
- package/dist/checks/architecture/no-run-done-result.js +1 -0
- package/dist/checks/architecture/no-run-done-result.js.map +1 -1
- package/dist/checks/architecture/package-json-exports-field.d.ts.map +1 -1
- package/dist/checks/architecture/package-json-exports-field.js +1 -1
- package/dist/checks/architecture/package-json-exports-field.js.map +1 -1
- package/dist/checks/architecture/phantom-dependency-detection.d.ts.map +1 -1
- package/dist/checks/architecture/phantom-dependency-detection.js +0 -3
- package/dist/checks/architecture/phantom-dependency-detection.js.map +1 -1
- package/dist/checks/architecture/tsconfig-extends-validation.d.ts.map +1 -1
- package/dist/checks/architecture/tsconfig-extends-validation.js +0 -2
- package/dist/checks/architecture/tsconfig-extends-validation.js.map +1 -1
- package/dist/checks/quality/code-structure/__tests__/duplicate-utility-lang-substrate.test.d.ts +5 -0
- package/dist/checks/quality/code-structure/__tests__/duplicate-utility-lang-substrate.test.d.ts.map +1 -0
- package/dist/checks/quality/code-structure/__tests__/duplicate-utility-lang-substrate.test.js +17 -0
- package/dist/checks/quality/code-structure/__tests__/duplicate-utility-lang-substrate.test.js.map +1 -0
- package/dist/checks/quality/code-structure/duplicate-utility-functions-config.d.ts +18 -0
- package/dist/checks/quality/code-structure/duplicate-utility-functions-config.d.ts.map +1 -0
- package/dist/checks/quality/code-structure/duplicate-utility-functions-config.js +36 -0
- package/dist/checks/quality/code-structure/duplicate-utility-functions-config.js.map +1 -0
- package/dist/checks/quality/code-structure/duplicate-utility-functions-helpers.d.ts +15 -0
- package/dist/checks/quality/code-structure/duplicate-utility-functions-helpers.d.ts.map +1 -0
- package/dist/checks/quality/code-structure/duplicate-utility-functions-helpers.js +288 -0
- package/dist/checks/quality/code-structure/duplicate-utility-functions-helpers.js.map +1 -0
- package/dist/checks/quality/code-structure/duplicate-utility-functions.d.ts +1 -26
- package/dist/checks/quality/code-structure/duplicate-utility-functions.d.ts.map +1 -1
- package/dist/checks/quality/code-structure/duplicate-utility-functions.js +3 -407
- package/dist/checks/quality/code-structure/duplicate-utility-functions.js.map +1 -1
- package/dist/checks/quality/data-integrity/__tests__/null-safety-fp.test.js +39 -2
- package/dist/checks/quality/data-integrity/__tests__/null-safety-fp.test.js.map +1 -1
- package/dist/checks/quality/data-integrity/array-validation-detectors.d.ts +17 -0
- package/dist/checks/quality/data-integrity/array-validation-detectors.d.ts.map +1 -0
- package/dist/checks/quality/data-integrity/array-validation-detectors.js +184 -0
- package/dist/checks/quality/data-integrity/array-validation-detectors.js.map +1 -0
- package/dist/checks/quality/data-integrity/array-validation.d.ts +0 -2
- package/dist/checks/quality/data-integrity/array-validation.d.ts.map +1 -1
- package/dist/checks/quality/data-integrity/array-validation.js +2 -360
- package/dist/checks/quality/data-integrity/array-validation.js.map +1 -1
- package/dist/checks/quality/data-integrity/database-schema-validation.d.ts.map +1 -1
- package/dist/checks/quality/data-integrity/database-schema-validation.js +0 -1
- package/dist/checks/quality/data-integrity/database-schema-validation.js.map +1 -1
- package/dist/checks/quality/data-integrity/null-safety-analyze.d.ts +33 -0
- package/dist/checks/quality/data-integrity/null-safety-analyze.d.ts.map +1 -0
- package/dist/checks/quality/data-integrity/null-safety-analyze.js +164 -0
- package/dist/checks/quality/data-integrity/null-safety-analyze.js.map +1 -0
- package/dist/checks/quality/data-integrity/null-safety-config.d.ts +50 -0
- package/dist/checks/quality/data-integrity/null-safety-config.d.ts.map +1 -0
- package/dist/checks/quality/data-integrity/null-safety-config.js +69 -0
- package/dist/checks/quality/data-integrity/null-safety-config.js.map +1 -0
- package/dist/checks/quality/data-integrity/null-safety-heuristics.d.ts +76 -0
- package/dist/checks/quality/data-integrity/null-safety-heuristics.d.ts.map +1 -0
- package/dist/checks/quality/data-integrity/null-safety-heuristics.js +276 -0
- package/dist/checks/quality/data-integrity/null-safety-heuristics.js.map +1 -0
- package/dist/checks/quality/data-integrity/null-safety-prefixes.d.ts +13 -0
- package/dist/checks/quality/data-integrity/null-safety-prefixes.d.ts.map +1 -0
- package/dist/checks/quality/data-integrity/null-safety-prefixes.js +333 -0
- package/dist/checks/quality/data-integrity/null-safety-prefixes.js.map +1 -0
- package/dist/checks/quality/data-integrity/null-safety.d.ts +2 -82
- package/dist/checks/quality/data-integrity/null-safety.d.ts.map +1 -1
- package/dist/checks/quality/data-integrity/null-safety.js +3 -796
- package/dist/checks/quality/data-integrity/null-safety.js.map +1 -1
- package/dist/checks/quality/frontend/test-only-frontend-modules.d.ts.map +1 -1
- package/dist/checks/quality/frontend/test-only-frontend-modules.js +0 -2
- package/dist/checks/quality/frontend/test-only-frontend-modules.js.map +1 -1
- package/dist/checks/quality/linting/typescript-frontend.d.ts.map +1 -1
- package/dist/checks/quality/linting/typescript-frontend.js +1 -0
- package/dist/checks/quality/linting/typescript-frontend.js.map +1 -1
- package/dist/checks/quality/observability/logger-event-name-format.d.ts.map +1 -1
- package/dist/checks/quality/observability/logger-event-name-format.js +0 -1
- package/dist/checks/quality/observability/logger-event-name-format.js.map +1 -1
- package/dist/checks/quality/observability/no-hardcoded-correlation-id.d.ts.map +1 -1
- package/dist/checks/quality/observability/no-hardcoded-correlation-id.js +2 -3
- package/dist/checks/quality/observability/no-hardcoded-correlation-id.js.map +1 -1
- package/dist/checks/quality/patterns/__tests__/async-waterfall-sequential.test.d.ts +8 -0
- package/dist/checks/quality/patterns/__tests__/async-waterfall-sequential.test.d.ts.map +1 -0
- package/dist/checks/quality/patterns/__tests__/async-waterfall-sequential.test.js +87 -0
- package/dist/checks/quality/patterns/__tests__/async-waterfall-sequential.test.js.map +1 -0
- package/dist/checks/quality/patterns/__tests__/error-handling-probes.test.d.ts +2 -0
- package/dist/checks/quality/patterns/__tests__/error-handling-probes.test.d.ts.map +1 -0
- package/dist/checks/quality/patterns/__tests__/error-handling-probes.test.js +51 -0
- package/dist/checks/quality/patterns/__tests__/error-handling-probes.test.js.map +1 -0
- package/dist/checks/quality/patterns/__tests__/result-pattern-registration-guards.test.d.ts +2 -0
- package/dist/checks/quality/patterns/__tests__/result-pattern-registration-guards.test.d.ts.map +1 -0
- package/dist/checks/quality/patterns/__tests__/result-pattern-registration-guards.test.js +89 -0
- package/dist/checks/quality/patterns/__tests__/result-pattern-registration-guards.test.js.map +1 -0
- package/dist/checks/quality/patterns/__tests__/throws-documentation-analyze.test.d.ts +5 -0
- package/dist/checks/quality/patterns/__tests__/throws-documentation-analyze.test.d.ts.map +1 -0
- package/dist/checks/quality/patterns/__tests__/throws-documentation-analyze.test.js +78 -0
- package/dist/checks/quality/patterns/__tests__/throws-documentation-analyze.test.js.map +1 -0
- package/dist/checks/quality/patterns/__tests__/toctou-fp.test.js +44 -0
- package/dist/checks/quality/patterns/__tests__/toctou-fp.test.js.map +1 -1
- package/dist/checks/quality/patterns/async-waterfall-analysis.d.ts +17 -0
- package/dist/checks/quality/patterns/async-waterfall-analysis.d.ts.map +1 -0
- package/dist/checks/quality/patterns/async-waterfall-analysis.js +215 -0
- package/dist/checks/quality/patterns/async-waterfall-analysis.js.map +1 -0
- package/dist/checks/quality/patterns/async-waterfall-branch-keys.d.ts +6 -0
- package/dist/checks/quality/patterns/async-waterfall-branch-keys.d.ts.map +1 -0
- package/dist/checks/quality/patterns/async-waterfall-branch-keys.js +54 -0
- package/dist/checks/quality/patterns/async-waterfall-branch-keys.js.map +1 -0
- package/dist/checks/quality/patterns/async-waterfall-detection.d.ts.map +1 -1
- package/dist/checks/quality/patterns/async-waterfall-detection.js +3 -352
- package/dist/checks/quality/patterns/async-waterfall-detection.js.map +1 -1
- package/dist/checks/quality/patterns/containing-function-name.d.ts +3 -0
- package/dist/checks/quality/patterns/containing-function-name.d.ts.map +1 -0
- package/dist/checks/quality/patterns/containing-function-name.js +21 -0
- package/dist/checks/quality/patterns/containing-function-name.js.map +1 -0
- package/dist/checks/quality/patterns/error-handling-quality.d.ts +3 -0
- package/dist/checks/quality/patterns/error-handling-quality.d.ts.map +1 -1
- package/dist/checks/quality/patterns/error-handling-quality.js +150 -30
- package/dist/checks/quality/patterns/error-handling-quality.js.map +1 -1
- package/dist/checks/quality/patterns/result-pattern-consistency.d.ts +3 -0
- package/dist/checks/quality/patterns/result-pattern-consistency.d.ts.map +1 -1
- package/dist/checks/quality/patterns/result-pattern-consistency.js +136 -69
- package/dist/checks/quality/patterns/result-pattern-consistency.js.map +1 -1
- package/dist/checks/quality/patterns/throws-documentation-analyze.d.ts +14 -0
- package/dist/checks/quality/patterns/throws-documentation-analyze.d.ts.map +1 -0
- package/dist/checks/quality/patterns/throws-documentation-analyze.js +352 -0
- package/dist/checks/quality/patterns/throws-documentation-analyze.js.map +1 -0
- package/dist/checks/quality/patterns/throws-documentation-constants.d.ts +15 -0
- package/dist/checks/quality/patterns/throws-documentation-constants.d.ts.map +1 -0
- package/dist/checks/quality/patterns/throws-documentation-constants.js +94 -0
- package/dist/checks/quality/patterns/throws-documentation-constants.js.map +1 -0
- package/dist/checks/quality/patterns/throws-documentation.d.ts +1 -11
- package/dist/checks/quality/patterns/throws-documentation.d.ts.map +1 -1
- package/dist/checks/quality/patterns/throws-documentation.js +4 -472
- package/dist/checks/quality/patterns/throws-documentation.js.map +1 -1
- package/dist/checks/quality/patterns/toctou-race-condition-classify.d.ts +23 -0
- package/dist/checks/quality/patterns/toctou-race-condition-classify.d.ts.map +1 -0
- package/dist/checks/quality/patterns/toctou-race-condition-classify.js +125 -0
- package/dist/checks/quality/patterns/toctou-race-condition-classify.js.map +1 -0
- package/dist/checks/quality/patterns/toctou-race-condition-collection.d.ts +24 -0
- package/dist/checks/quality/patterns/toctou-race-condition-collection.d.ts.map +1 -0
- package/dist/checks/quality/patterns/toctou-race-condition-collection.js +248 -0
- package/dist/checks/quality/patterns/toctou-race-condition-collection.js.map +1 -0
- package/dist/checks/quality/patterns/toctou-race-condition-constants.d.ts +32 -0
- package/dist/checks/quality/patterns/toctou-race-condition-constants.d.ts.map +1 -0
- package/dist/checks/quality/patterns/toctou-race-condition-constants.js +115 -0
- package/dist/checks/quality/patterns/toctou-race-condition-constants.js.map +1 -0
- package/dist/checks/quality/patterns/toctou-race-condition.d.ts +1 -29
- package/dist/checks/quality/patterns/toctou-race-condition.d.ts.map +1 -1
- package/dist/checks/quality/patterns/toctou-race-condition.js +11 -536
- package/dist/checks/quality/patterns/toctou-race-condition.js.map +1 -1
- package/dist/checks/quality/unused-config-options.d.ts.map +1 -1
- package/dist/checks/quality/unused-config-options.js +0 -4
- package/dist/checks/quality/unused-config-options.js.map +1 -1
- package/dist/checks/resilience/__tests__/detached-promises-sync-detection.test.d.ts +2 -0
- package/dist/checks/resilience/__tests__/detached-promises-sync-detection.test.d.ts.map +1 -0
- package/dist/checks/resilience/__tests__/detached-promises-sync-detection.test.js +98 -0
- package/dist/checks/resilience/__tests__/detached-promises-sync-detection.test.js.map +1 -0
- package/dist/checks/resilience/callback-invocation-safe.d.ts.map +1 -1
- package/dist/checks/resilience/callback-invocation-safe.js +0 -1
- package/dist/checks/resilience/callback-invocation-safe.js.map +1 -1
- package/dist/checks/resilience/context-leakage.d.ts.map +1 -1
- package/dist/checks/resilience/context-leakage.js +1 -0
- package/dist/checks/resilience/context-leakage.js.map +1 -1
- package/dist/checks/resilience/detached-promises-detection.d.ts +7 -0
- package/dist/checks/resilience/detached-promises-detection.d.ts.map +1 -0
- package/dist/checks/resilience/detached-promises-detection.js +228 -0
- package/dist/checks/resilience/detached-promises-detection.js.map +1 -0
- package/dist/checks/resilience/detached-promises-sync-constants.d.ts +36 -0
- package/dist/checks/resilience/detached-promises-sync-constants.d.ts.map +1 -0
- package/dist/checks/resilience/detached-promises-sync-constants.js +299 -0
- package/dist/checks/resilience/detached-promises-sync-constants.js.map +1 -0
- package/dist/checks/resilience/detached-promises-sync-detection.d.ts +14 -0
- package/dist/checks/resilience/detached-promises-sync-detection.d.ts.map +1 -0
- package/dist/checks/resilience/detached-promises-sync-detection.js +69 -0
- package/dist/checks/resilience/detached-promises-sync-detection.js.map +1 -0
- package/dist/checks/resilience/detached-promises.d.ts +1 -14
- package/dist/checks/resilience/detached-promises.d.ts.map +1 -1
- package/dist/checks/resilience/detached-promises.js +2 -598
- package/dist/checks/resilience/detached-promises.js.map +1 -1
- package/dist/checks/resilience/no-raw-fetch.d.ts.map +1 -1
- package/dist/checks/resilience/no-raw-fetch.js +1 -0
- package/dist/checks/resilience/no-raw-fetch.js.map +1 -1
- package/dist/checks/resilience/no-unbounded-concurrency.d.ts.map +1 -1
- package/dist/checks/resilience/no-unbounded-concurrency.js +1 -0
- package/dist/checks/resilience/no-unbounded-concurrency.js.map +1 -1
- package/dist/checks/security/sql-injection.d.ts.map +1 -1
- package/dist/checks/security/sql-injection.js +0 -1
- package/dist/checks/security/sql-injection.js.map +1 -1
- package/dist/display/architecture.d.ts.map +1 -1
- package/dist/display/architecture.js +1 -0
- package/dist/display/architecture.js.map +1 -1
- package/dist/display/types.d.ts.map +1 -1
- package/dist/display/types.js +0 -1
- package/dist/display/types.js.map +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
// @fitness-ignore-file throws-documentation -- Functions throw self-documenting typed errors
|
|
2
|
+
/**
|
|
3
|
+
* AST analysis helpers for the throws-documentation check.
|
|
4
|
+
*/
|
|
5
|
+
import * as ts from 'typescript';
|
|
6
|
+
import { isSelfDocumentingError } from './throws-documentation-constants.js';
|
|
7
|
+
function isFunctionLikeNode(n) {
|
|
8
|
+
return (ts.isFunctionDeclaration(n) ||
|
|
9
|
+
ts.isFunctionExpression(n) ||
|
|
10
|
+
ts.isArrowFunction(n) ||
|
|
11
|
+
ts.isMethodDeclaration(n));
|
|
12
|
+
}
|
|
13
|
+
function findThrowStatements(node) {
|
|
14
|
+
const throws = [];
|
|
15
|
+
const visit = (n) => {
|
|
16
|
+
if (isFunctionLikeNode(n) && n !== node) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (ts.isThrowStatement(n)) {
|
|
20
|
+
throws.push(n);
|
|
21
|
+
}
|
|
22
|
+
ts.forEachChild(n, visit);
|
|
23
|
+
};
|
|
24
|
+
visit(node);
|
|
25
|
+
return throws;
|
|
26
|
+
}
|
|
27
|
+
function commentRangesIncludeThrows(fullText, pos) {
|
|
28
|
+
const comments = ts.getLeadingCommentRanges(fullText, pos);
|
|
29
|
+
if (!comments)
|
|
30
|
+
return false;
|
|
31
|
+
for (const comment of comments) {
|
|
32
|
+
const commentText = fullText.slice(comment.pos, comment.end);
|
|
33
|
+
if (commentText.includes('@throws')) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
function hasThrowsJSDoc(node, sourceFile) {
|
|
40
|
+
return commentRangesIncludeThrows(sourceFile.getFullText(), node.getFullStart());
|
|
41
|
+
}
|
|
42
|
+
function hasPropertyAssignmentThrowsJSDoc(arrow, sourceFile) {
|
|
43
|
+
const parent = arrow.parent;
|
|
44
|
+
if (!ts.isPropertyAssignment(parent))
|
|
45
|
+
return false;
|
|
46
|
+
return commentRangesIncludeThrows(sourceFile.getFullText(), parent.name.getFullStart());
|
|
47
|
+
}
|
|
48
|
+
function isReturnedClosure(node) {
|
|
49
|
+
const parent = node.parent;
|
|
50
|
+
if (ts.isReturnStatement(parent))
|
|
51
|
+
return true;
|
|
52
|
+
if (ts.isPropertyAssignment(parent)) {
|
|
53
|
+
let current = parent.parent;
|
|
54
|
+
while (current) {
|
|
55
|
+
if (ts.isReturnStatement(current))
|
|
56
|
+
return true;
|
|
57
|
+
if (isFunctionLikeNode(current))
|
|
58
|
+
return false;
|
|
59
|
+
current = current.parent;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
function isFactoryBodyConstArrow(node) {
|
|
65
|
+
const parent = node.parent;
|
|
66
|
+
if (!ts.isVariableDeclaration(parent) || parent.initializer !== node)
|
|
67
|
+
return false;
|
|
68
|
+
const stmt = parent.parent.parent;
|
|
69
|
+
if (!ts.isVariableStatement(stmt))
|
|
70
|
+
return false;
|
|
71
|
+
let current = stmt.parent;
|
|
72
|
+
while (current) {
|
|
73
|
+
if (isFunctionLikeNode(current))
|
|
74
|
+
return true;
|
|
75
|
+
if (ts.isSourceFile(current))
|
|
76
|
+
return false;
|
|
77
|
+
current = current.parent;
|
|
78
|
+
}
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
function hasEnclosingFactoryThrowsJSDoc(node, sourceFile) {
|
|
82
|
+
if (!isReturnedClosure(node) && !isFactoryBodyConstArrow(node))
|
|
83
|
+
return false;
|
|
84
|
+
let current = node.parent;
|
|
85
|
+
while (current) {
|
|
86
|
+
if ((ts.isFunctionDeclaration(current) ||
|
|
87
|
+
ts.isFunctionExpression(current) ||
|
|
88
|
+
ts.isMethodDeclaration(current)) &&
|
|
89
|
+
hasThrowsJSDoc(current, sourceFile))
|
|
90
|
+
return true;
|
|
91
|
+
current = current.parent;
|
|
92
|
+
}
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
function getFunctionBody(node) {
|
|
96
|
+
if (ts.isMethodDeclaration(node) || ts.isFunctionDeclaration(node)) {
|
|
97
|
+
return node.body ?? undefined;
|
|
98
|
+
}
|
|
99
|
+
return node.body;
|
|
100
|
+
}
|
|
101
|
+
function isInsideTopLevelTry(throwStmt, fnNode) {
|
|
102
|
+
const body = getFunctionBody(fnNode);
|
|
103
|
+
if (!body || !ts.isBlock(body))
|
|
104
|
+
return false;
|
|
105
|
+
let current = throwStmt.parent;
|
|
106
|
+
while (current && current !== fnNode) {
|
|
107
|
+
if (isFunctionLikeNode(current) && current !== fnNode)
|
|
108
|
+
return false;
|
|
109
|
+
if (ts.isTryStatement(current) && body.statements.includes(current)) {
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
current = current.parent;
|
|
113
|
+
}
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
function catchClauseContainsThrow(n) {
|
|
117
|
+
if (ts.isThrowStatement(n))
|
|
118
|
+
return true;
|
|
119
|
+
if (isFunctionLikeNode(n))
|
|
120
|
+
return false;
|
|
121
|
+
let found = false;
|
|
122
|
+
ts.forEachChild(n, (child) => {
|
|
123
|
+
if (catchClauseContainsThrow(child))
|
|
124
|
+
found = true;
|
|
125
|
+
});
|
|
126
|
+
return found;
|
|
127
|
+
}
|
|
128
|
+
function topLevelTryCatchRethrows(fnNode) {
|
|
129
|
+
const body = getFunctionBody(fnNode);
|
|
130
|
+
if (!body || !ts.isBlock(body))
|
|
131
|
+
return false;
|
|
132
|
+
for (const stmt of body.statements) {
|
|
133
|
+
if (!ts.isTryStatement(stmt))
|
|
134
|
+
continue;
|
|
135
|
+
if (stmt.catchClause && catchClauseContainsThrow(stmt.catchClause))
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
function neverPropagatesThrows(node) {
|
|
141
|
+
const throwStatements = findThrowStatements(node);
|
|
142
|
+
if (throwStatements.length === 0)
|
|
143
|
+
return false;
|
|
144
|
+
if (!throwStatements.every((stmt) => isInsideTopLevelTry(stmt, node)))
|
|
145
|
+
return false;
|
|
146
|
+
return !topLevelTryCatchRethrows(node);
|
|
147
|
+
}
|
|
148
|
+
const ANONYMOUS_FUNCTION_NAME = '<anonymous>';
|
|
149
|
+
function getNameFromFunctionDeclaration(node) {
|
|
150
|
+
return node.name?.text ?? ANONYMOUS_FUNCTION_NAME;
|
|
151
|
+
}
|
|
152
|
+
function getNameFromMethodDeclaration(node) {
|
|
153
|
+
return ts.isIdentifier(node.name) ? node.name.text : ANONYMOUS_FUNCTION_NAME;
|
|
154
|
+
}
|
|
155
|
+
function getNameFromArrowFunction(node) {
|
|
156
|
+
const parent = node.parent;
|
|
157
|
+
if (ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name)) {
|
|
158
|
+
return parent.name.text;
|
|
159
|
+
}
|
|
160
|
+
return ANONYMOUS_FUNCTION_NAME;
|
|
161
|
+
}
|
|
162
|
+
// @fitness-ignore-next-line duplicate-utility-functions -- Check-specific helper for FunctionLikeNode
|
|
163
|
+
function getFunctionName(node) {
|
|
164
|
+
if (ts.isFunctionDeclaration(node)) {
|
|
165
|
+
return getNameFromFunctionDeclaration(node);
|
|
166
|
+
}
|
|
167
|
+
if (ts.isMethodDeclaration(node)) {
|
|
168
|
+
return getNameFromMethodDeclaration(node);
|
|
169
|
+
}
|
|
170
|
+
return getNameFromArrowFunction(node);
|
|
171
|
+
}
|
|
172
|
+
function isAnonymousCallback(node) {
|
|
173
|
+
const parent = node.parent;
|
|
174
|
+
return ts.isCallExpression(parent) || ts.isCallExpression(parent.parent);
|
|
175
|
+
}
|
|
176
|
+
function extractThrownType(throwStmt, sourceFile) {
|
|
177
|
+
const text = throwStmt.expression.getText(sourceFile);
|
|
178
|
+
// @fitness-ignore-next-line sonarjs-backend -- Safe regex with fixed tokens for extracting error class name
|
|
179
|
+
const typeMatch = /new\s+(\w+)/.exec(text);
|
|
180
|
+
return typeMatch?.[1] ?? 'Error';
|
|
181
|
+
}
|
|
182
|
+
function getUniqueThrowTypes(throwStatements, sourceFile) {
|
|
183
|
+
if (!Array.isArray(throwStatements)) {
|
|
184
|
+
return [];
|
|
185
|
+
}
|
|
186
|
+
const thrownTypes = throwStatements.map((t) => extractThrownType(t, sourceFile));
|
|
187
|
+
return [...new Set(thrownTypes)];
|
|
188
|
+
}
|
|
189
|
+
function createMissingThrowsViolation(node, funcName, throwStatements, ctx) {
|
|
190
|
+
if (!Array.isArray(throwStatements)) {
|
|
191
|
+
throw new TypeError('throwStatements must be an array');
|
|
192
|
+
}
|
|
193
|
+
const { line, character } = ctx.sourceFile.getLineAndCharacterOfPosition(node.getStart());
|
|
194
|
+
const lineNum = line + 1;
|
|
195
|
+
const uniqueTypes = getUniqueThrowTypes(throwStatements, ctx.sourceFile);
|
|
196
|
+
return {
|
|
197
|
+
line: lineNum,
|
|
198
|
+
column: character + 1,
|
|
199
|
+
message: `Function '${funcName}' throws but lacks @throws JSDoc`,
|
|
200
|
+
severity: 'warning',
|
|
201
|
+
suggestion: `Add @throws JSDoc above the function: /** @throws {${uniqueTypes.join(' | ')}} Description of when this error is thrown */`,
|
|
202
|
+
match: funcName,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
function shouldAnalyzeFunction(node, funcName) {
|
|
206
|
+
if (funcName === '<anonymous>' && ts.isArrowFunction(node)) {
|
|
207
|
+
return !isAnonymousCallback(node);
|
|
208
|
+
}
|
|
209
|
+
return true;
|
|
210
|
+
}
|
|
211
|
+
function allThrowsSelfDocumenting(throwStatements, sourceFile, suffixes) {
|
|
212
|
+
if (!Array.isArray(throwStatements) || throwStatements.length === 0) {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
return throwStatements.every((stmt) => {
|
|
216
|
+
const errorType = extractThrownType(stmt, sourceFile);
|
|
217
|
+
return isSelfDocumentingError(errorType, suffixes);
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
const ERROR_FIELD_NAME_PATTERN = /^(error|err|cause|innerError|originalError)$/i;
|
|
221
|
+
const ERROR_VAR_NAME_PATTERN = /^(error|err|e|ex|exception)$/i;
|
|
222
|
+
function collectCaughtErrorNames(fnNode) {
|
|
223
|
+
const names = new Set();
|
|
224
|
+
const visit = (n) => {
|
|
225
|
+
if (isFunctionLikeNode(n) && n !== fnNode) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
if (ts.isCatchClause(n) && n.variableDeclaration) {
|
|
229
|
+
const decl = n.variableDeclaration;
|
|
230
|
+
if (ts.isIdentifier(decl.name)) {
|
|
231
|
+
names.add(decl.name.text);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
ts.forEachChild(n, visit);
|
|
235
|
+
};
|
|
236
|
+
visit(fnNode);
|
|
237
|
+
return names;
|
|
238
|
+
}
|
|
239
|
+
// eslint-disable-next-line sonarjs/cognitive-complexity -- rethrow heuristic AST shapes
|
|
240
|
+
function isRethrow(throwStmt, sourceFile, caughtNames) {
|
|
241
|
+
const expr = throwStmt.expression;
|
|
242
|
+
const text = expr.getText(sourceFile).trim();
|
|
243
|
+
if (ts.isNewExpression(expr))
|
|
244
|
+
return false;
|
|
245
|
+
if (ts.isIdentifier(expr)) {
|
|
246
|
+
if (caughtNames?.has(expr.text))
|
|
247
|
+
return true;
|
|
248
|
+
return ERROR_VAR_NAME_PATTERN.test(expr.text);
|
|
249
|
+
}
|
|
250
|
+
if (ts.isPropertyAccessExpression(expr) &&
|
|
251
|
+
expr.expression.kind === ts.SyntaxKind.ThisKeyword &&
|
|
252
|
+
ts.isIdentifier(expr.name) &&
|
|
253
|
+
ERROR_FIELD_NAME_PATTERN.test(expr.name.text)) {
|
|
254
|
+
return true;
|
|
255
|
+
}
|
|
256
|
+
if (ts.isCallExpression(expr) && ts.isPropertyAccessExpression(expr.expression)) {
|
|
257
|
+
const methodName = ts.isIdentifier(expr.expression.name) ? expr.expression.name.text : '';
|
|
258
|
+
if (methodName === 'unwrapErr' || methodName === 'unwrap') {
|
|
259
|
+
return true;
|
|
260
|
+
}
|
|
261
|
+
const root = expr.expression.expression;
|
|
262
|
+
if (ts.isIdentifier(root) && caughtNames?.has(root.text)) {
|
|
263
|
+
return true;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
if (ts.isCallExpression(expr) && expr.arguments.length === 1) {
|
|
267
|
+
const arg = expr.arguments[0];
|
|
268
|
+
if (arg && ts.isIdentifier(arg)) {
|
|
269
|
+
if (caughtNames?.has(arg.text))
|
|
270
|
+
return true;
|
|
271
|
+
if (!caughtNames && ERROR_VAR_NAME_PATTERN.test(arg.text))
|
|
272
|
+
return true;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
return !text.includes('new ') && ERROR_VAR_NAME_PATTERN.test(text);
|
|
276
|
+
}
|
|
277
|
+
function matchesInstanceofGuard(cond, thrown, sourceFile) {
|
|
278
|
+
if (!ts.isIdentifier(thrown))
|
|
279
|
+
return false;
|
|
280
|
+
if (!ts.isBinaryExpression(cond) || cond.operatorToken.kind !== ts.SyntaxKind.InstanceOfKeyword) {
|
|
281
|
+
return false;
|
|
282
|
+
}
|
|
283
|
+
return cond.left.getText(sourceFile) === thrown.text;
|
|
284
|
+
}
|
|
285
|
+
function isInstanceofGuardedRethrow(throwStmt, sourceFile) {
|
|
286
|
+
const parent = throwStmt.parent;
|
|
287
|
+
const thrown = throwStmt.expression;
|
|
288
|
+
if (ts.isIfStatement(parent)) {
|
|
289
|
+
return matchesInstanceofGuard(parent.expression, thrown, sourceFile);
|
|
290
|
+
}
|
|
291
|
+
if (!ts.isBlock(parent))
|
|
292
|
+
return false;
|
|
293
|
+
const siblings = parent.statements;
|
|
294
|
+
const idx = siblings.indexOf(throwStmt);
|
|
295
|
+
if (idx <= 0)
|
|
296
|
+
return false;
|
|
297
|
+
const prev = siblings[idx - 1];
|
|
298
|
+
if (!ts.isIfStatement(prev))
|
|
299
|
+
return false;
|
|
300
|
+
return matchesInstanceofGuard(prev.expression, thrown, sourceFile);
|
|
301
|
+
}
|
|
302
|
+
function analyzeFunctionNode(node, ctx) {
|
|
303
|
+
const funcName = getFunctionName(node);
|
|
304
|
+
if (!shouldAnalyzeFunction(node, funcName)) {
|
|
305
|
+
return null;
|
|
306
|
+
}
|
|
307
|
+
const throwStatements = findThrowStatements(node);
|
|
308
|
+
if (throwStatements.length === 0) {
|
|
309
|
+
return null;
|
|
310
|
+
}
|
|
311
|
+
if (hasThrowsJSDoc(node, ctx.sourceFile)) {
|
|
312
|
+
return null;
|
|
313
|
+
}
|
|
314
|
+
if (ts.isArrowFunction(node)) {
|
|
315
|
+
if (hasPropertyAssignmentThrowsJSDoc(node, ctx.sourceFile)) {
|
|
316
|
+
return null;
|
|
317
|
+
}
|
|
318
|
+
if (hasEnclosingFactoryThrowsJSDoc(node, ctx.sourceFile)) {
|
|
319
|
+
return null;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
if (neverPropagatesThrows(node)) {
|
|
323
|
+
return null;
|
|
324
|
+
}
|
|
325
|
+
if (allThrowsSelfDocumenting(throwStatements, ctx.sourceFile, ctx.selfDocumentingSuffixes)) {
|
|
326
|
+
return null;
|
|
327
|
+
}
|
|
328
|
+
const caughtNames = collectCaughtErrorNames(node);
|
|
329
|
+
if (throwStatements.every((stmt) => isRethrow(stmt, ctx.sourceFile, caughtNames) ||
|
|
330
|
+
isInstanceofGuardedRethrow(stmt, ctx.sourceFile))) {
|
|
331
|
+
return null;
|
|
332
|
+
}
|
|
333
|
+
return createMissingThrowsViolation(node, funcName, throwStatements, ctx);
|
|
334
|
+
}
|
|
335
|
+
/** Analyze a file for missing @throws documentation. */
|
|
336
|
+
export function analyzeFile(ctx) {
|
|
337
|
+
const violations = [];
|
|
338
|
+
const visit = (node) => {
|
|
339
|
+
if (ts.isFunctionDeclaration(node) ||
|
|
340
|
+
ts.isMethodDeclaration(node) ||
|
|
341
|
+
ts.isArrowFunction(node)) {
|
|
342
|
+
const violation = analyzeFunctionNode(node, ctx);
|
|
343
|
+
if (violation) {
|
|
344
|
+
violations.push(violation);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
ts.forEachChild(node, visit);
|
|
348
|
+
};
|
|
349
|
+
visit(ctx.sourceFile);
|
|
350
|
+
return violations;
|
|
351
|
+
}
|
|
352
|
+
//# sourceMappingURL=throws-documentation-analyze.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"throws-documentation-analyze.js","sourceRoot":"","sources":["../../../../src/checks/quality/patterns/throws-documentation-analyze.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F;;GAEG;AAGH,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAW7E,SAAS,kBAAkB,CAAC,CAAU;IACpC,OAAO,CACL,EAAE,CAAC,qBAAqB,CAAC,CAAC,CAAC;QAC3B,EAAE,CAAC,oBAAoB,CAAC,CAAC,CAAC;QAC1B,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC;QACrB,EAAE,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAC1B,CAAC;AACJ,CAAC;AAED,SAAS,mBAAmB,CAAC,IAAa;IACxC,MAAM,MAAM,GAAwB,EAAE,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d,CAAC;IAED,OAAO,4BAA4B,CAAC,IAAI,EAAE,QAAQ,EAAE,eAAe,EAAE,GAAG,CAAC,CAAC;AAC5E,CAAC;AAED,wDAAwD;AACxD,MAAM,UAAU,WAAW,CAAC,GAAwB;IAClD,MAAM,UAAU,GAAqB,EAAE,CAAC;IAExC,MAAM,KAAK,GAAG,CAAC,IAAa,EAAQ,EAAE;QACpC,IACE,EAAE,CAAC,qBAAqB,CAAC,IAAI,CAAC;YAC9B,EAAE,CAAC,mBAAmB,CAAC,IAAI,CAAC;YAC5B,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,EACxB,CAAC;YACD,MAAM,SAAS,GAAG,mBAAmB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;YACjD,IAAI,SAAS,EAAE,CAAC;gBACd,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAC7B,CAAC;QACH,CAAC;QACD,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC/B,CAAC,CAAC;IAEF,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACtB,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Self-documenting error allowlists for the throws-documentation check.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Recipe-config shape for throws-documentation. Project-specific typed-error
|
|
6
|
+
* suffixes belong in a recipe's `checks.config['throws-documentation']` block.
|
|
7
|
+
*/
|
|
8
|
+
export interface ThrowsDocConfig extends Record<string, unknown> {
|
|
9
|
+
/** Class-name suffixes that mark a thrown error as self-documenting. */
|
|
10
|
+
additionalSelfDocumentingSuffixes?: readonly string[];
|
|
11
|
+
}
|
|
12
|
+
export declare const SELF_DOCUMENTING_SUFFIXES: string[];
|
|
13
|
+
export declare function buildEffectiveSuffixes(): readonly string[];
|
|
14
|
+
export declare function isSelfDocumentingError(errorType: string, suffixes: readonly string[]): boolean;
|
|
15
|
+
//# sourceMappingURL=throws-documentation-constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"throws-documentation-constants.d.ts","sourceRoot":"","sources":["../../../../src/checks/quality/patterns/throws-documentation-constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;;GAGG;AACH,MAAM,WAAW,eAAgB,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC9D,wEAAwE;IACxE,iCAAiC,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACvD;AA8CD,eAAO,MAAM,yBAAyB,UAmCrC,CAAC;AAEF,wBAAgB,sBAAsB,IAAI,SAAS,MAAM,EAAE,CAG1D;AAED,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAK9F"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Self-documenting error allowlists for the throws-documentation check.
|
|
3
|
+
*/
|
|
4
|
+
import { getCheckConfig } from '@opensip-cli/fitness';
|
|
5
|
+
/** Typed error classes that are self-documenting without @throws JSDoc. */
|
|
6
|
+
const SELF_DOCUMENTING_ERROR_NAMES = [
|
|
7
|
+
'ValidationError',
|
|
8
|
+
'AuthorizationError',
|
|
9
|
+
'NotFoundError',
|
|
10
|
+
'ConflictError',
|
|
11
|
+
'DomainError',
|
|
12
|
+
'SystemError',
|
|
13
|
+
'ConfigurationError',
|
|
14
|
+
'InfrastructureError',
|
|
15
|
+
'ExternalServiceError',
|
|
16
|
+
'DatabaseError',
|
|
17
|
+
'CacheError',
|
|
18
|
+
'NetworkError',
|
|
19
|
+
'ApplicationError',
|
|
20
|
+
'OperationError',
|
|
21
|
+
'StateError',
|
|
22
|
+
'IntegrationError',
|
|
23
|
+
'BadRequestError',
|
|
24
|
+
'UnauthorizedError',
|
|
25
|
+
'ForbiddenError',
|
|
26
|
+
'MethodNotAllowedError',
|
|
27
|
+
'NotAcceptableError',
|
|
28
|
+
'RequestTimeoutError',
|
|
29
|
+
'GoneError',
|
|
30
|
+
'PayloadTooLargeError',
|
|
31
|
+
'UnsupportedMediaTypeError',
|
|
32
|
+
'UnprocessableEntityError',
|
|
33
|
+
'TooManyRequestsError',
|
|
34
|
+
'InternalServerError',
|
|
35
|
+
'NotImplementedError',
|
|
36
|
+
'BadGatewayError',
|
|
37
|
+
'ServiceUnavailableError',
|
|
38
|
+
'GatewayTimeoutError',
|
|
39
|
+
'InputValidationError',
|
|
40
|
+
'BusinessRuleError',
|
|
41
|
+
'AuthenticationError',
|
|
42
|
+
'PermissionError',
|
|
43
|
+
'ResourceNotFoundError',
|
|
44
|
+
'DuplicateResourceError',
|
|
45
|
+
'DataIntegrityError',
|
|
46
|
+
'ToolError',
|
|
47
|
+
];
|
|
48
|
+
export const SELF_DOCUMENTING_SUFFIXES = [
|
|
49
|
+
'ValidationError',
|
|
50
|
+
'NotFoundError',
|
|
51
|
+
'AuthorizationError',
|
|
52
|
+
'SystemError',
|
|
53
|
+
'DomainError',
|
|
54
|
+
'ConfigurationError',
|
|
55
|
+
'SecurityError',
|
|
56
|
+
'TimeoutError',
|
|
57
|
+
'LockError',
|
|
58
|
+
'LimitError',
|
|
59
|
+
'InfrastructureError',
|
|
60
|
+
'ApplicationError',
|
|
61
|
+
'OperationError',
|
|
62
|
+
'ErrorBuilder',
|
|
63
|
+
'NetworkError',
|
|
64
|
+
'ExecutionError',
|
|
65
|
+
'LoadError',
|
|
66
|
+
'VerifyError',
|
|
67
|
+
'ApiError',
|
|
68
|
+
'ParseError',
|
|
69
|
+
'EncodingError',
|
|
70
|
+
'DecodingError',
|
|
71
|
+
'StateError',
|
|
72
|
+
'SyncError',
|
|
73
|
+
'CaptureError',
|
|
74
|
+
'IntegrationError',
|
|
75
|
+
'PermissionError',
|
|
76
|
+
'AccessError',
|
|
77
|
+
'AuthenticationError',
|
|
78
|
+
'ResourceNotFoundError',
|
|
79
|
+
'DuplicateResourceError',
|
|
80
|
+
'DataIntegrityError',
|
|
81
|
+
'BusinessRuleError',
|
|
82
|
+
'InputValidationError',
|
|
83
|
+
];
|
|
84
|
+
export function buildEffectiveSuffixes() {
|
|
85
|
+
const cfg = getCheckConfig('throws-documentation');
|
|
86
|
+
return [...SELF_DOCUMENTING_SUFFIXES, ...(cfg.additionalSelfDocumentingSuffixes ?? [])];
|
|
87
|
+
}
|
|
88
|
+
export function isSelfDocumentingError(errorType, suffixes) {
|
|
89
|
+
if (SELF_DOCUMENTING_ERROR_NAMES.includes(errorType)) {
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
return suffixes.some((suffix) => errorType.endsWith(suffix));
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=throws-documentation-constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"throws-documentation-constants.js","sourceRoot":"","sources":["../../../../src/checks/quality/patterns/throws-documentation-constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAWtD,2EAA2E;AAC3E,MAAM,4BAA4B,GAAG;IACnC,iBAAiB;IACjB,oBAAoB;IACpB,eAAe;IACf,eAAe;IACf,aAAa;IACb,aAAa;IACb,oBAAoB;IACpB,qBAAqB;IACrB,sBAAsB;IACtB,eAAe;IACf,YAAY;IACZ,cAAc;IACd,kBAAkB;IAClB,gBAAgB;IAChB,YAAY;IACZ,kBAAkB;IAClB,iBAAiB;IACjB,mBAAmB;IACnB,gBAAgB;IAChB,uBAAuB;IACvB,oBAAoB;IACpB,qBAAqB;IACrB,WAAW;IACX,sBAAsB;IACtB,2BAA2B;IAC3B,0BAA0B;IAC1B,sBAAsB;IACtB,qBAAqB;IACrB,qBAAqB;IACrB,iBAAiB;IACjB,yBAAyB;IACzB,qBAAqB;IACrB,sBAAsB;IACtB,mBAAmB;IACnB,qBAAqB;IACrB,iBAAiB;IACjB,uBAAuB;IACvB,wBAAwB;IACxB,oBAAoB;IACpB,WAAW;CACH,CAAC;AAEX,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,iBAAiB;IACjB,eAAe;IACf,oBAAoB;IACpB,aAAa;IACb,aAAa;IACb,oBAAoB;IACpB,eAAe;IACf,cAAc;IACd,WAAW;IACX,YAAY;IACZ,qBAAqB;IACrB,kBAAkB;IAClB,gBAAgB;IAChB,cAAc;IACd,cAAc;IACd,gBAAgB;IAChB,WAAW;IACX,aAAa;IACb,UAAU;IACV,YAAY;IACZ,eAAe;IACf,eAAe;IACf,YAAY;IACZ,WAAW;IACX,cAAc;IACd,kBAAkB;IAClB,iBAAiB;IACjB,aAAa;IACb,qBAAqB;IACrB,uBAAuB;IACvB,wBAAwB;IACxB,oBAAoB;IACpB,mBAAmB;IACnB,sBAAsB;CACvB,CAAC;AAEF,MAAM,UAAU,sBAAsB;IACpC,MAAM,GAAG,GAAG,cAAc,CAAkB,sBAAsB,CAAC,CAAC;IACpE,OAAO,CAAC,GAAG,yBAAyB,EAAE,GAAG,CAAC,GAAG,CAAC,iCAAiC,IAAI,EAAE,CAAC,CAAC,CAAC;AAC1F,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,SAAiB,EAAE,QAA2B;IACnF,IAAK,4BAAkD,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QAC5E,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -2,22 +2,12 @@
|
|
|
2
2
|
* @fileoverview Missing @throws JSDoc Detection Check
|
|
3
3
|
*
|
|
4
4
|
* Detects functions that contain throw statements but lack @throws JSDoc documentation.
|
|
5
|
-
*
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Recipe-config shape for throws-documentation. Project-specific typed-error
|
|
9
|
-
* suffixes (e.g. opensip's `CompositionError`, `CanonicalizationError`)
|
|
10
|
-
* belong in a recipe's `checks.config['throws-documentation']` block, not
|
|
11
|
-
* in built-in defaults.
|
|
12
5
|
*/
|
|
13
|
-
export interface ThrowsDocConfig extends Record<string, unknown> {
|
|
14
|
-
/** Class-name suffixes that mark a thrown error as self-documenting. */
|
|
15
|
-
additionalSelfDocumentingSuffixes?: readonly string[];
|
|
16
|
-
}
|
|
17
6
|
/**
|
|
18
7
|
* Check: quality/throws-documentation
|
|
19
8
|
*
|
|
20
9
|
* Detects functions with throw statements but no @throws JSDoc.
|
|
21
10
|
*/
|
|
22
11
|
export declare const throwsDocumentation: import("@opensip-cli/fitness").Check;
|
|
12
|
+
export { type ThrowsDocConfig } from './throws-documentation-constants.js';
|
|
23
13
|
//# sourceMappingURL=throws-documentation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"throws-documentation.d.ts","sourceRoot":"","sources":["../../../../src/checks/quality/patterns/throws-documentation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"throws-documentation.d.ts","sourceRoot":"","sources":["../../../../src/checks/quality/patterns/throws-documentation.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAQH;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,sCAoC9B,CAAC;AAEH,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,qCAAqC,CAAC"}
|