@nielspeter/eess-ts 0.5.1 → 0.6.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.
- package/README.md +1 -1
- package/dist/builders/class-rule-builder.d.ts +6 -3
- package/dist/builders/class-rule-builder.d.ts.map +1 -1
- package/dist/builders/class-rule-builder.js +6 -3
- package/dist/builders/class-rule-builder.js.map +1 -1
- package/dist/builders/function-rule-builder.d.ts +29 -7
- package/dist/builders/function-rule-builder.d.ts.map +1 -1
- package/dist/builders/function-rule-builder.js +34 -8
- package/dist/builders/function-rule-builder.js.map +1 -1
- package/dist/conditions/body-analysis-function.d.ts.map +1 -1
- package/dist/conditions/body-analysis-function.js +19 -1
- package/dist/conditions/body-analysis-function.js.map +1 -1
- package/dist/conditions/body-analysis.d.ts +5 -2
- package/dist/conditions/body-analysis.d.ts.map +1 -1
- package/dist/conditions/body-analysis.js +9 -6
- package/dist/conditions/body-analysis.js.map +1 -1
- package/dist/conditions/call.d.ts +4 -2
- package/dist/conditions/call.d.ts.map +1 -1
- package/dist/conditions/call.js +11 -8
- package/dist/conditions/call.js.map +1 -1
- package/dist/conditions/catch-analysis.d.ts +7 -1
- package/dist/conditions/catch-analysis.d.ts.map +1 -1
- package/dist/conditions/catch-analysis.js +26 -27
- package/dist/conditions/catch-analysis.js.map +1 -1
- package/dist/conditions/class.d.ts +5 -3
- package/dist/conditions/class.d.ts.map +1 -1
- package/dist/conditions/class.js +9 -6
- package/dist/conditions/class.js.map +1 -1
- package/dist/conditions/function.d.ts +4 -4
- package/dist/conditions/function.js +4 -4
- package/dist/core/execute-rule.js +1 -1
- package/dist/graphql/resolver-rule-builder.d.ts.map +1 -1
- package/dist/graphql/resolver-rule-builder.js +16 -2
- package/dist/graphql/resolver-rule-builder.js.map +1 -1
- package/dist/helpers/body-traversal.d.ts +63 -9
- package/dist/helpers/body-traversal.d.ts.map +1 -1
- package/dist/helpers/body-traversal.js +179 -30
- package/dist/helpers/body-traversal.js.map +1 -1
- package/dist/helpers/heritage.d.ts +25 -0
- package/dist/helpers/heritage.d.ts.map +1 -0
- package/dist/helpers/heritage.js +41 -0
- package/dist/helpers/heritage.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/models/arch-function.d.ts +42 -12
- package/dist/models/arch-function.d.ts.map +1 -1
- package/dist/models/arch-function.js +104 -18
- package/dist/models/arch-function.js.map +1 -1
- package/dist/predicates/class.d.ts +9 -9
- package/dist/predicates/class.d.ts.map +1 -1
- package/dist/predicates/class.js +14 -13
- package/dist/predicates/class.js.map +1 -1
- package/dist/predicates/function.d.ts +16 -4
- package/dist/predicates/function.d.ts.map +1 -1
- package/dist/predicates/function.js +56 -3
- package/dist/predicates/function.js.map +1 -1
- package/dist/predicates/type.d.ts +2 -1
- package/dist/predicates/type.d.ts.map +1 -1
- package/dist/predicates/type.js +6 -2
- package/dist/predicates/type.js.map +1 -1
- package/dist/presets/agent-guardrails.js +5 -5
- package/dist/presets/agent-guardrails.js.map +1 -1
- package/dist/rules/code-quality.d.ts +12 -1
- package/dist/rules/code-quality.d.ts.map +1 -1
- package/dist/rules/code-quality.js +106 -12
- package/dist/rules/code-quality.js.map +1 -1
- package/dist/rules/errors.d.ts +4 -2
- package/dist/rules/errors.d.ts.map +1 -1
- package/dist/rules/errors.js +18 -16
- package/dist/rules/errors.js.map +1 -1
- package/dist/rules/hygiene.d.ts +3 -1
- package/dist/rules/hygiene.d.ts.map +1 -1
- package/dist/rules/hygiene.js +3 -1
- package/dist/rules/hygiene.js.map +1 -1
- package/dist/rules/metrics.d.ts +6 -4
- package/dist/rules/metrics.d.ts.map +1 -1
- package/dist/rules/metrics.js +40 -20
- package/dist/rules/metrics.js.map +1 -1
- package/dist/rules/security.d.ts +13 -5
- package/dist/rules/security.d.ts.map +1 -1
- package/dist/rules/security.js +144 -19
- package/dist/rules/security.js.map +1 -1
- package/dist/rules/typescript.d.ts +2 -2
- package/dist/rules/typescript.js +2 -2
- package/dist/smells/duplicate-bodies.js +2 -2
- package/dist/smells/duplicate-bodies.js.map +1 -1
- package/dist/smells/sibling-files.js +2 -2
- package/dist/smells/sibling-files.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Node } from 'ts-morph';
|
|
2
|
+
import type { CatchClause } from 'ts-morph';
|
|
2
3
|
/**
|
|
3
4
|
* Result of scanning a single catch clause.
|
|
4
5
|
*/
|
|
@@ -9,7 +10,7 @@ interface SilentCatchResult {
|
|
|
9
10
|
message: string;
|
|
10
11
|
}
|
|
11
12
|
/**
|
|
12
|
-
*
|
|
13
|
+
* Why a catch clause is silent, or `undefined` when it references the caught error.
|
|
13
14
|
*
|
|
14
15
|
* A catch clause is "silent" if:
|
|
15
16
|
* 1. It has no binding at all (`catch { ... }`) — no error to reference
|
|
@@ -27,6 +28,11 @@ interface SilentCatchResult {
|
|
|
27
28
|
* — the inner `err` usage satisfies the outer check.
|
|
28
29
|
* Both are rare in practice and arguably code smells themselves.
|
|
29
30
|
*/
|
|
31
|
+
export declare function silentCatchMessage(catchClause: CatchClause): string | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Find catch clauses in the body that don't reference the caught error — see
|
|
34
|
+
* `silentCatchMessage` for what counts as silent.
|
|
35
|
+
*/
|
|
30
36
|
export declare function findSilentCatches(body: Node): SilentCatchResult[];
|
|
31
37
|
export {};
|
|
32
38
|
//# sourceMappingURL=catch-analysis.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catch-analysis.d.ts","sourceRoot":"","sources":["../../src/conditions/catch-analysis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAc,MAAM,UAAU,CAAA;AAE3C;;GAEG;AACH,UAAU,iBAAiB;IACzB,oEAAoE;IACpE,IAAI,EAAE,IAAI,CAAA;IACV,6DAA6D;IAC7D,OAAO,EAAE,MAAM,CAAA;CAChB;AA8BD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,GAAG,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"catch-analysis.d.ts","sourceRoot":"","sources":["../../src/conditions/catch-analysis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAc,MAAM,UAAU,CAAA;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAE3C;;GAEG;AACH,UAAU,iBAAiB;IACzB,oEAAoE;IACpE,IAAI,EAAE,IAAI,CAAA;IACV,6DAA6D;IAC7D,OAAO,EAAE,MAAM,CAAA;CAChB;AA8BD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,GAAG,SAAS,CAkB/E;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,GAAG,iBAAiB,EAAE,CAOjE"}
|
|
@@ -25,7 +25,7 @@ function getBindingNames(nameNode) {
|
|
|
25
25
|
return new Set();
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
28
|
+
* Why a catch clause is silent, or `undefined` when it references the caught error.
|
|
29
29
|
*
|
|
30
30
|
* A catch clause is "silent" if:
|
|
31
31
|
* 1. It has no binding at all (`catch { ... }`) — no error to reference
|
|
@@ -43,35 +43,34 @@ function getBindingNames(nameNode) {
|
|
|
43
43
|
* — the inner `err` usage satisfies the outer check.
|
|
44
44
|
* Both are rare in practice and arguably code smells themselves.
|
|
45
45
|
*/
|
|
46
|
+
export function silentCatchMessage(catchClause) {
|
|
47
|
+
const varDecl = catchClause.getVariableDeclaration();
|
|
48
|
+
// catch { ... } — no binding at all, always a violation
|
|
49
|
+
if (!varDecl)
|
|
50
|
+
return 'catch block has no error binding — error is silently discarded';
|
|
51
|
+
// No binding names extracted (e.g., unusual pattern) — skip to avoid false positive
|
|
52
|
+
const bindingNames = getBindingNames(varDecl.getNameNode());
|
|
53
|
+
if (bindingNames.size === 0)
|
|
54
|
+
return undefined;
|
|
55
|
+
// Walk the catch block for Identifier nodes matching any binding name
|
|
56
|
+
const hasReference = catchClause
|
|
57
|
+
.getBlock()
|
|
58
|
+
.getDescendantsOfKind(SyntaxKind.Identifier)
|
|
59
|
+
.some((id) => bindingNames.has(id.getText()));
|
|
60
|
+
if (hasReference)
|
|
61
|
+
return undefined;
|
|
62
|
+
return `catch block binds '${varDecl.getName()}' but never references it — error is silently discarded`;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Find catch clauses in the body that don't reference the caught error — see
|
|
66
|
+
* `silentCatchMessage` for what counts as silent.
|
|
67
|
+
*/
|
|
46
68
|
export function findSilentCatches(body) {
|
|
47
69
|
const results = [];
|
|
48
70
|
for (const catchClause of body.getDescendantsOfKind(SyntaxKind.CatchClause)) {
|
|
49
|
-
const
|
|
50
|
-
if (
|
|
51
|
-
|
|
52
|
-
results.push({
|
|
53
|
-
node: catchClause,
|
|
54
|
-
message: 'catch block has no error binding — error is silently discarded',
|
|
55
|
-
});
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
// Collect the binding names to search for
|
|
59
|
-
const bindingNames = getBindingNames(varDecl.getNameNode());
|
|
60
|
-
// No binding names extracted (e.g., unusual pattern) — skip to avoid false positive
|
|
61
|
-
if (bindingNames.size === 0)
|
|
62
|
-
continue;
|
|
63
|
-
// Walk the catch block for Identifier nodes matching any binding name
|
|
64
|
-
const block = catchClause.getBlock();
|
|
65
|
-
const hasReference = block
|
|
66
|
-
.getDescendantsOfKind(SyntaxKind.Identifier)
|
|
67
|
-
.some((id) => bindingNames.has(id.getText()));
|
|
68
|
-
if (!hasReference) {
|
|
69
|
-
const varName = varDecl.getName();
|
|
70
|
-
results.push({
|
|
71
|
-
node: catchClause,
|
|
72
|
-
message: `catch block binds '${varName}' but never references it — error is silently discarded`,
|
|
73
|
-
});
|
|
74
|
-
}
|
|
71
|
+
const message = silentCatchMessage(catchClause);
|
|
72
|
+
if (message !== undefined)
|
|
73
|
+
results.push({ node: catchClause, message });
|
|
75
74
|
}
|
|
76
75
|
return results;
|
|
77
76
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catch-analysis.js","sourceRoot":"","sources":["../../src/conditions/catch-analysis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"catch-analysis.js","sourceRoot":"","sources":["../../src/conditions/catch-analysis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAa3C;;;;;GAKG;AACH,SAAS,eAAe,CAAC,QAAc;IACrC,IAAI,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,CAAC;QAChC,OAAO,IAAI,GAAG,CAAC,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,CAAA;IACtC,CAAC;IAED,IAAI,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,EAAE,CAAC;QAClF,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAA;QAC/B,KAAK,MAAM,OAAO,IAAI,QAAQ,CAAC,WAAW,EAAE,EAAE,CAAC;YAC7C,IAAI,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,EAAE,CAAC;gBACnC,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,EAAE,CAAA;gBACzC,IAAI,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE,CAAC;oBACnC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC,CAAA;gBAClC,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC;IAED,yEAAyE;IACzE,OAAO,I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TypeMatcher } from '../helpers/type-matchers.js';
|
|
4
4
|
/**
|
|
5
|
-
* Assert that classes extend the named base class
|
|
5
|
+
* Assert that classes directly extend the named base class — written as its name, or through
|
|
6
|
+
* an aliased import, a namespace member or a mixin call.
|
|
6
7
|
*/
|
|
7
8
|
export declare function shouldExtend(className: string): Condition<ClassDeclaration>;
|
|
8
9
|
/**
|
|
9
|
-
* Assert that classes implement the named interface
|
|
10
|
+
* Assert that classes implement the named interface in their own `implements` clause — as
|
|
11
|
+
* written, or through an aliased import.
|
|
10
12
|
*/
|
|
11
13
|
export declare function shouldImplement(interfaceName: string): Condition<ClassDeclaration>;
|
|
12
14
|
/**
|
|
@@ -26,7 +28,7 @@ export declare function shouldNotHaveMethodMatching(regex: RegExp): Condition<Cl
|
|
|
26
28
|
*
|
|
27
29
|
* **Scope note:** This scans constructors, methods, AND set accessors.
|
|
28
30
|
* The function-level counterpart (`functions(p).should().acceptParameterOfType(...)`)
|
|
29
|
-
*
|
|
31
|
+
* reads a set accessor as its own function, `Class.set x` (bug 0315).
|
|
30
32
|
*/
|
|
31
33
|
export declare function acceptParameterOfType(matcher: TypeMatcher): Condition<ClassDeclaration>;
|
|
32
34
|
export declare function notAcceptParameterOfType(matcher: TypeMatcher): Condition<ClassDeclaration>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class.d.ts","sourceRoot":"","sources":["../../src/conditions/class.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAwB,MAAM,UAAU,CAAA;AACtE,OAAO,KAAK,EAAE,SAAS,EAAoB,MAAM,kBAAkB,CAAA;AAInE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"class.d.ts","sourceRoot":"","sources":["../../src/conditions/class.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAwB,MAAM,UAAU,CAAA;AACtE,OAAO,KAAK,EAAE,SAAS,EAAoB,MAAM,kBAAkB,CAAA;AAInE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAG9D;;;GAGG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC,gBAAgB,CAAC,CAM3E;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC,gBAAgB,CAAC,CAMlF;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC,gBAAgB,CAAC,CAM/E;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC,gBAAgB,CAAC,CAYtF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,WAAW,GAAG,SAAS,CAAC,gBAAgB,CAAC,CAyBvF;AAkDD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,WAAW,GAAG,SAAS,CAAC,gBAAgB,CAAC,CAW1F"}
|
package/dist/conditions/class.js
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { elementCondition } from './helpers.js';
|
|
2
2
|
import { createViolation, getElementName } from '../core/violation.js';
|
|
3
|
+
import { extendsByName, implementsByName } from '../helpers/heritage.js';
|
|
3
4
|
/**
|
|
4
|
-
* Assert that classes extend the named base class
|
|
5
|
+
* Assert that classes directly extend the named base class — written as its name, or through
|
|
6
|
+
* an aliased import, a namespace member or a mixin call.
|
|
5
7
|
*/
|
|
6
8
|
export function shouldExtend(className) {
|
|
7
|
-
return elementCondition(`extend "${className}"`, (cls) => cls
|
|
9
|
+
return elementCondition(`extend "${className}"`, (cls) => extendsByName(cls, className), (cls) => `${getElementName(cls)} does not extend "${className}"`);
|
|
8
10
|
}
|
|
9
11
|
/**
|
|
10
|
-
* Assert that classes implement the named interface
|
|
12
|
+
* Assert that classes implement the named interface in their own `implements` clause — as
|
|
13
|
+
* written, or through an aliased import.
|
|
11
14
|
*/
|
|
12
15
|
export function shouldImplement(interfaceName) {
|
|
13
|
-
return elementCondition(`implement "${interfaceName}"`, (cls) => cls
|
|
16
|
+
return elementCondition(`implement "${interfaceName}"`, (cls) => implementsByName(cls, interfaceName), (cls) => `${getElementName(cls)} does not implement "${interfaceName}"`);
|
|
14
17
|
}
|
|
15
18
|
/**
|
|
16
19
|
* Assert that classes have a method with the given name.
|
|
@@ -39,7 +42,7 @@ export function shouldNotHaveMethodMatching(regex) {
|
|
|
39
42
|
*
|
|
40
43
|
* **Scope note:** This scans constructors, methods, AND set accessors.
|
|
41
44
|
* The function-level counterpart (`functions(p).should().acceptParameterOfType(...)`)
|
|
42
|
-
*
|
|
45
|
+
* reads a set accessor as its own function, `Class.set x` (bug 0315).
|
|
43
46
|
*/
|
|
44
47
|
export function acceptParameterOfType(matcher) {
|
|
45
48
|
return {
|
|
@@ -70,7 +73,7 @@ export function acceptParameterOfType(matcher) {
|
|
|
70
73
|
*
|
|
71
74
|
* **Scope note:** This scans constructors, methods, AND set accessors.
|
|
72
75
|
* The function-level counterpart (`functions(p).should().notAcceptParameterOfType(...)`)
|
|
73
|
-
*
|
|
76
|
+
* reads a set accessor as its own function, `Class.set x` (bug 0315).
|
|
74
77
|
*/
|
|
75
78
|
/**
|
|
76
79
|
* Scan parameters of class members (constructors, methods, set accessors) for
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class.js","sourceRoot":"","sources":["../../src/conditions/class.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"class.js","sourceRoot":"","sources":["../../src/conditions/class.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,eAAe,EAAE,c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C,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,CAAA;gBAC1C,UAAU,CAAC,IAAI,CACb,eAAe,CACb,GAAG,EACH,GAAG,SAAS,IAAI,UAAU,eAAe,SAAS,eAAe,QAAQ,GAAG,EAC5E,OAAO,CACR,CACF,CAAA;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAA;AACnB,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,OAAoB;IAC3D,OAAO;QACL,WAAW,EAAE,uCAAuC;QACpD,QAAQ,CAAC,QAA4B,EAAE,OAAyB;YAC9D,MAAM,UAAU,GAAoB,EAAE,CAAA;YACtC,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;gBAC3B,UAAU,CAAC,IAAI,CAAC,GAAG,qBAAqB,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;YAClE,CAAC;YACD,OAAO,UAAU,CAAA;QACnB,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -34,8 +34,8 @@ export declare function haveNameMatching(pattern: RegExp): Condition<ArchFunctio
|
|
|
34
34
|
* Reports one violation per function that has no matching parameter.
|
|
35
35
|
*
|
|
36
36
|
* **Scope note:** This operates on the function's own parameter list only.
|
|
37
|
-
*
|
|
38
|
-
*
|
|
37
|
+
* A set accessor is a function of its own, `Class.set x`, since bug 0315; the class-level
|
|
38
|
+
* counterpart scans the whole class at once.
|
|
39
39
|
*/
|
|
40
40
|
export declare function acceptParameterOfType(matcher: TypeMatcher): Condition<ArchFunction>;
|
|
41
41
|
/**
|
|
@@ -46,8 +46,8 @@ export declare function acceptParameterOfType(matcher: TypeMatcher): Condition<A
|
|
|
46
46
|
* with actionable messages including the parameter name and type.
|
|
47
47
|
*
|
|
48
48
|
* **Scope note:** This operates on the function's own parameter list only.
|
|
49
|
-
*
|
|
50
|
-
*
|
|
49
|
+
* A set accessor is a function of its own, `Class.set x`, since bug 0315; the class-level
|
|
50
|
+
* counterpart scans the whole class at once.
|
|
51
51
|
*/
|
|
52
52
|
export declare function notAcceptParameterOfType(matcher: TypeMatcher): Condition<ArchFunction>;
|
|
53
53
|
/**
|
|
@@ -89,8 +89,8 @@ export function haveNameMatching(pattern) {
|
|
|
89
89
|
* Reports one violation per function that has no matching parameter.
|
|
90
90
|
*
|
|
91
91
|
* **Scope note:** This operates on the function's own parameter list only.
|
|
92
|
-
*
|
|
93
|
-
*
|
|
92
|
+
* A set accessor is a function of its own, `Class.set x`, since bug 0315; the class-level
|
|
93
|
+
* counterpart scans the whole class at once.
|
|
94
94
|
*/
|
|
95
95
|
export function acceptParameterOfType(matcher) {
|
|
96
96
|
return functionCondition('accept parameter of matching type', (fn) => fn.getParameters().some((p) => matcher(p.getType())), (fn) => `${fn.getName() ?? '<anonymous>'} has no parameter with matching type`);
|
|
@@ -103,8 +103,8 @@ export function acceptParameterOfType(matcher) {
|
|
|
103
103
|
* with actionable messages including the parameter name and type.
|
|
104
104
|
*
|
|
105
105
|
* **Scope note:** This operates on the function's own parameter list only.
|
|
106
|
-
*
|
|
107
|
-
*
|
|
106
|
+
* A set accessor is a function of its own, `Class.set x`, since bug 0315; the class-level
|
|
107
|
+
* counterpart scans the whole class at once.
|
|
108
108
|
*/
|
|
109
109
|
export function notAcceptParameterOfType(matcher) {
|
|
110
110
|
return {
|
|
@@ -181,7 +181,7 @@ export function applyFilters(violations, ctx) {
|
|
|
181
181
|
// pattern that silences NOTHING (fail-closed — the finding still fires, CI is
|
|
182
182
|
// still red), while this warns about a pattern that silences MULTIPLE real
|
|
183
183
|
// findings and every future one on the same edges (fail-open — a green
|
|
184
|
-
// `check()`, one stderr line). ADR-
|
|
184
|
+
// `check()`, one stderr line). ADR-009 states the primary consumer does not
|
|
185
185
|
// read warnings. Kept advisory here, matching plan 0104's own review
|
|
186
186
|
// resolution — but the asymmetry is real and worth re-litigating if this
|
|
187
187
|
// loophole is measured firing in practice, not settled by the precedent
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolver-rule-builder.d.ts","sourceRoot":"","sources":["../../src/graphql/resolver-rule-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAC1C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAGhD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAO9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;
|
|
1
|
+
{"version":3,"file":"resolver-rule-builder.d.ts","sourceRoot":"","sources":["../../src/graphql/resolver-rule-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAC1C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAGhD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAO9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAY9D;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,YAAY,CAAC,CAYvF;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,mBAAoB,SAAQ,kBAAkB,CAAC,YAAY,CAAC;IAiBrE,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;IACtB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;IAlB3B;;;;;;;;;;;;;;OAcG;gBAEgB,WAAW,EAAE,UAAU,EAAE,EACzB,IAAI,CAAC,EAAE,MAAM,YAAA,EACb,OAAO,CAAC,EAAE,WAAW,YAAA;IAKxC,6EAA6E;IAC7E,UAAU,IAAI,WAAW,GAAG,SAAS;IAIrC;;;;;;;;OAQG;IACM,KAAK,IAAI,SAAS,QAAQ,EAAE;IAarC;;OAEG;IACH,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAQrD;;OAEG;IACH,OAAO,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI;IAMzC;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI;IAM5C;;OAEG;IACH,YAAY,CAAC,GAAG,EAAE,iBAAiB,EAAE,IAAI,EAAE,iBAAiB,GAAG,IAAI;IAQnE;;;;;;;OAOG;cACgB,gBAAgB,IAAI,MAAM;cAI1B,kBAAkB,IAAI,MAAM;cAI5B,iBAAiB,IAAI,MAAM;cAI3B,WAAW,IAAI,YAAY,EAAE;CAoBjD"}
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { stampGlobs } from '@nielspeter/eess/internal';
|
|
2
2
|
import { globAnyOf } from '@nielspeter/eess';
|
|
3
|
-
import { collectFunctions } from '../models/arch-function.js';
|
|
3
|
+
import { collectFunctions, functionKindOf } from '../models/arch-function.js';
|
|
4
4
|
import { functionContain, functionNotContain, functionUseInsteadOf, } from '../conditions/body-analysis-function.js';
|
|
5
5
|
import { GraphqlRuleBuilder } from './graphql-rule-builder.js';
|
|
6
|
+
/**
|
|
7
|
+
* The kinds of collected function `resolvers()` does not treat as a resolver. A getter written as a field
|
|
8
|
+
* resolver, `@Field() get fullName()`, is therefore not read.
|
|
9
|
+
*/
|
|
10
|
+
const NOT_RESOLVERS = new Set([
|
|
11
|
+
'constructor',
|
|
12
|
+
'getter',
|
|
13
|
+
'setter',
|
|
14
|
+
]);
|
|
6
15
|
/**
|
|
7
16
|
* Predicate: filter to resolver functions for fields returning types matching the pattern.
|
|
8
17
|
*
|
|
@@ -148,7 +157,12 @@ export class ResolverRuleBuilder extends GraphqlRuleBuilder {
|
|
|
148
157
|
// sit beside the resolvers and none of the resolvers themselves — measured
|
|
149
158
|
// on a real schema as 60 subjects, 0 of them resolvers. Every rule written
|
|
150
159
|
// against it then passes on the wrong subjects (ADR-008).
|
|
151
|
-
|
|
160
|
+
//
|
|
161
|
+
// A constructor or an accessor is not treated as a resolver, so a getter field resolver is not read.
|
|
162
|
+
// Since bug 0315 the collection returns a class's constructor and accessors beside its methods, and a
|
|
163
|
+
// class-based resolver's injected constructor would otherwise fail every `contain(...)` rule written
|
|
164
|
+
// against the resolvers.
|
|
165
|
+
return this.sourceFiles.flatMap((sf) => collectFunctions(sf, { includeObjectLiteralFunctions: true }).filter((fn) => !NOT_RESOLVERS.has(functionKindOf(fn))));
|
|
152
166
|
}
|
|
153
167
|
}
|
|
154
168
|
//# sourceMappingURL=resolver-rule-builder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolver-rule-builder.js","sourceRoot":"","sources":["../../src/graphql/resolver-rule-builder.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAG5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":"resolver-rule-builder.js","sourceRoot":"","sources":["../../src/graphql/resolver-rule-builder.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAG5C,OAAO,EAAE,gBAAgB,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IAEkB,kBAAkB;QACnC,OAAO,WAAW,CAAA;IACpB,CAAC;IAEkB,iBAAiB;QAClC,OAAO,oDAAoD,CAAA;IAC7D,CAAC;IAEkB,WAAW;QAC5B,6EAA6E;QAC7E,0EAA0E;QAC1E,wDAAwD;QACxD,0EAA0E;QAC1E,0EAA0E;QAC1E,2EAA2E;QAC3E,2EAA2E;QAC3E,0DAA0D;QAC1D,EAAE;QACF,qGAAqG;QACrG,sGAAsG;QACtG,qGAAqG;QACrG,yBAAyB;QACzB,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CACrC,gBAAgB,CAAC,EAAE,EAAE,EAAE,6BAA6B,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,CAClE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,CAC/C,CACF,CAAA;IACH,CAAC;CACF"}
|
|
@@ -46,20 +46,74 @@ interface Match {
|
|
|
46
46
|
*/
|
|
47
47
|
export declare function reportedLine(node: Node, triviaPos: number | undefined): number;
|
|
48
48
|
/**
|
|
49
|
-
*
|
|
49
|
+
* How much of a class a body search reads (bug 0307).
|
|
50
50
|
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
51
|
+
* - `'member-code'` — the code the class's members run: method, constructor and accessor bodies,
|
|
52
|
+
* parameter defaults — each default and computed key inside a destructured parameter included
|
|
53
|
+
* (bug 0309) — property initializers and static blocks.
|
|
54
|
+
* - `'all-code'` — that, and the code the class runs outside its members when it is defined: every
|
|
55
|
+
* decorator expression (on the class, its members, accessors and parameters), computed member
|
|
56
|
+
* names and the `extends` expression.
|
|
57
|
+
*
|
|
58
|
+
* A search for what a class must NOT contain reads all of it: there, reading more fails closed. A
|
|
59
|
+
* search for what it MUST contain reads member code only: there, reading less fails closed, and a decorator, a
|
|
60
|
+
* computed name or the `extends` expression is wiring that must not satisfy a rule like
|
|
61
|
+
* `classMustCall` — a DI token passed to a decorator included. The line is drawn by position: a
|
|
62
|
+
* call in member code still satisfies it, a DI lookup in a field initializer included.
|
|
63
|
+
*
|
|
64
|
+
* A computed key inside a destructured parameter is member code, unlike a computed member name: the
|
|
65
|
+
* key runs at each call, as a default does, and the member name runs once, when the class is
|
|
66
|
+
* defined. So a call in the key satisfies a must-contain rule, and a call in the member name does not.
|
|
67
|
+
*
|
|
68
|
+
* A rule that forbids something may still read member code only, when the other positions hold
|
|
69
|
+
* nothing it should report: `noMagicNumbers` does, because a number in a decorator argument such as
|
|
70
|
+
* `@Max(150)` is named by the decorator that takes it (bug 0306).
|
|
71
|
+
*/
|
|
72
|
+
type ClassBodyReach = 'member-code' | 'all-code';
|
|
73
|
+
/**
|
|
74
|
+
* Search the code a class runs (bugs 0300, 0307), as far as `reach` says.
|
|
75
|
+
*
|
|
76
|
+
* In four passes, for baselines. A match's identity is numbered within its enclosing declaration
|
|
77
|
+
* (`match-identity.ts`), and a declaration is known by its name, so a getter and its setter, or a
|
|
78
|
+
* static and an instance member of one name, share one. What the walk read before bug 0300 comes
|
|
79
|
+
* first for every member, then what 0300 added, then what 0307 added, then what 0309 added, so a
|
|
80
|
+
* finding a baseline accepted keeps its ordinal and a new one is numbered after it however the
|
|
81
|
+
* members interleave:
|
|
82
|
+
*
|
|
83
|
+
* 1. every method, constructor and accessor body;
|
|
84
|
+
* 2. every parameter default, property initializer (which covers an arrow-function property) and
|
|
85
|
+
* static block;
|
|
86
|
+
* 3. for `'all-code'`: every parameter, member and property decorator, computed member name, class
|
|
87
|
+
* decorator and the `extends` expression;
|
|
88
|
+
* 4. under either reach, the code every destructured parameter runs at each call, at any depth
|
|
89
|
+
* (`bindingPatternMatches`).
|
|
90
|
+
*
|
|
91
|
+
* Overload signatures have no body, defaults or decorators, so walking every constructor is the
|
|
92
|
+
* same as walking the implementation. `implements` is type-only and docstrings are not code, so
|
|
93
|
+
* neither is read, and a `comment()` rule reads code, not documentation.
|
|
94
|
+
*/
|
|
95
|
+
export declare function searchClassBody(cls: ClassDeclaration, matcher: ExpressionMatcher, reach: ClassBodyReach): MatchResult;
|
|
96
|
+
/**
|
|
97
|
+
* Matches in what a call condition searches — an argument, or a callback's body — including the
|
|
98
|
+
* node itself unless it is a block (bug 0323).
|
|
99
|
+
*
|
|
100
|
+
* An argument can BE the match — `use(legacy(1))` — and so can a concise callback's body, which
|
|
101
|
+
* `getFunctionBody` returns as the expression itself: `use(() => legacy(1))`. With
|
|
102
|
+
* `findMatchesInNode` alone neither was tested, under `call()` as under `expression()`. A block is
|
|
103
|
+
* searched below its root, as `searchFunctionBody` searches a function's own: tested itself, a
|
|
104
|
+
* block would match a broad pattern against the whole body.
|
|
54
105
|
*/
|
|
55
|
-
export declare function
|
|
106
|
+
export declare function findMatchesInCode(node: Node, matcher: ExpressionMatcher): Match[];
|
|
56
107
|
/**
|
|
57
|
-
*
|
|
108
|
+
* `findMatchesInCode` over several roots, numbered so a baseline keeps its identities (bug 0323):
|
|
109
|
+
* every match below a root first, in order, then the roots that are matches themselves.
|
|
58
110
|
*
|
|
59
|
-
*
|
|
60
|
-
* and
|
|
111
|
+
* 0.5.1 never tested a root, so each root match is new. Numbered in place, one would take the
|
|
112
|
+
* ordinal of a match a baseline already accepted, and the new finding would be the one hidden —
|
|
113
|
+
* as `searchClassBody` numbers the code bug 0300 made it read after the code it read before. A
|
|
114
|
+
* trivia match was found on a root before too, so it keeps its place.
|
|
61
115
|
*/
|
|
62
|
-
export declare function
|
|
116
|
+
export declare function findMatchesInEach(roots: readonly Node[], matcher: ExpressionMatcher): Match[];
|
|
63
117
|
/**
|
|
64
118
|
* Search a function body for matches.
|
|
65
119
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"body-traversal.d.ts","sourceRoot":"","sources":["../../src/helpers/body-traversal.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,IAAI,EACT,KAAK,gBAAgB,
|
|
1
|
+
{"version":3,"file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