@nielspeter/eess-ts 0.5.1 → 0.7.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 +2 -2
- package/dist/builders/class-rule-builder.d.ts +6 -10
- package/dist/builders/class-rule-builder.d.ts.map +1 -1
- package/dist/builders/class-rule-builder.js +33 -4
- 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-module.d.ts.map +1 -1
- package/dist/conditions/body-analysis-module.js +37 -4
- package/dist/conditions/body-analysis-module.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 +8 -5
- package/dist/conditions/call.d.ts.map +1 -1
- package/dist/conditions/call.js +46 -20
- 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/core/object-literal-functions.d.ts +4 -1
- package/dist/core/object-literal-functions.d.ts.map +1 -1
- package/dist/core/object-literal-functions.js +27 -5
- package/dist/core/object-literal-functions.js.map +1 -1
- package/dist/core/through-wrappers.d.ts +24 -0
- package/dist/core/through-wrappers.d.ts.map +1 -0
- package/dist/core/through-wrappers.js +36 -0
- package/dist/core/through-wrappers.js.map +1 -0
- package/dist/core/vacuity-diagnosis.d.ts.map +1 -1
- package/dist/core/vacuity-diagnosis.js +11 -3
- package/dist/core/vacuity-diagnosis.js.map +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 +74 -20
- package/dist/helpers/body-traversal.d.ts.map +1 -1
- package/dist/helpers/body-traversal.js +273 -48
- package/dist/helpers/body-traversal.js.map +1 -1
- package/dist/helpers/callback-extractor.d.ts +6 -1
- package/dist/helpers/callback-extractor.d.ts.map +1 -1
- package/dist/helpers/callback-extractor.js +45 -10
- package/dist/helpers/callback-extractor.js.map +1 -1
- package/dist/helpers/global-binding.d.ts +11 -0
- package/dist/helpers/global-binding.d.ts.map +1 -0
- package/dist/helpers/global-binding.js +232 -0
- package/dist/helpers/global-binding.js.map +1 -0
- 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 +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/models/arch-function.d.ts +44 -14
- package/dist/models/arch-function.d.ts.map +1 -1
- package/dist/models/arch-function.js +226 -43
- 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/presets/recommended.d.ts +14 -6
- package/dist/presets/recommended.d.ts.map +1 -1
- package/dist/presets/recommended.js +30 -11
- package/dist/presets/recommended.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 +44 -23
- 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 +19 -5
- package/dist/rules/security.d.ts.map +1 -1
- package/dist/rules/security.js +198 -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
package/dist/rules/errors.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { Node } from 'ts-morph';
|
|
2
|
-
import { createViolation } from '../core/violation.js';
|
|
1
|
+
import { Node, SyntaxKind } from 'ts-morph';
|
|
2
|
+
import { createViolation, enclosingScopeName } from '../core/violation.js';
|
|
3
|
+
import { identifyMatches } from '../conditions/match-identity.js';
|
|
3
4
|
import { newExpr } from '../helpers/matchers.js';
|
|
5
|
+
import { codeOfParameters, searchClassBody } from '../helpers/body-traversal.js';
|
|
4
6
|
import { classNotContain } from '../conditions/body-analysis.js';
|
|
5
7
|
import { functionNotContain } from '../conditions/body-analysis-function.js';
|
|
6
|
-
import { findSilentCatches } from '../conditions/catch-analysis.js';
|
|
8
|
+
import { findSilentCatches, silentCatchMessage } from '../conditions/catch-analysis.js';
|
|
7
9
|
/**
|
|
8
10
|
* No throwing generic Error — use typed domain errors instead.
|
|
9
11
|
*
|
|
@@ -30,9 +32,17 @@ export function functionNoTypeErrors() {
|
|
|
30
32
|
return functionNotContain(newExpr('TypeError'));
|
|
31
33
|
}
|
|
32
34
|
// ─── Silent catch detection ──────────────────────────────────────
|
|
35
|
+
/** Every catch clause; `noSilentCatch` decides which of them are silent. */
|
|
36
|
+
const catchClause = {
|
|
37
|
+
description: 'catch clause',
|
|
38
|
+
syntaxKinds: [SyntaxKind.CatchClause],
|
|
39
|
+
matches: (node) => Node.isCatchClause(node),
|
|
40
|
+
};
|
|
33
41
|
/**
|
|
34
|
-
* Catch blocks
|
|
35
|
-
*
|
|
42
|
+
* Catch blocks anywhere a class runs code must reference the caught error variable: member
|
|
43
|
+
* bodies, parameter defaults, property initializers (an arrow-function event handler included),
|
|
44
|
+
* static blocks, decorators, computed names and `extends` (bug 0306). It forbids something, so
|
|
45
|
+
* it reads all of it, as `notContain()` on the class builder does.
|
|
36
46
|
*
|
|
37
47
|
* Detects catch blocks that silently discard errors — no logging,
|
|
38
48
|
* no rethrowing, no passing to another function. A common source of
|
|
@@ -44,19 +54,12 @@ export function noSilentCatch() {
|
|
|
44
54
|
evaluate(elements, context) {
|
|
45
55
|
const violations = [];
|
|
46
56
|
for (const cls of elements) {
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
...cls.getConstructors(),
|
|
50
|
-
...cls.getGetAccessors(),
|
|
51
|
-
...cls.getSetAccessors(),
|
|
52
|
-
];
|
|
53
|
-
for (const member of members) {
|
|
54
|
-
const body = member.getBody();
|
|
55
|
-
if (!body)
|
|
57
|
+
for (const node of searchClassBody(cls, catchClause, 'all-code').matchingNodes) {
|
|
58
|
+
if (!Node.isCatchClause(node))
|
|
56
59
|
continue;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
const message = silentCatchMessage(node);
|
|
61
|
+
if (message !== undefined)
|
|
62
|
+
violations.push(createViolation(node, message, context));
|
|
60
63
|
}
|
|
61
64
|
}
|
|
62
65
|
return violations;
|
|
@@ -70,10 +73,14 @@ export function functionNoSilentCatch() {
|
|
|
70
73
|
const violations = [];
|
|
71
74
|
for (const fn of elements) {
|
|
72
75
|
const body = fn.getBody();
|
|
73
|
-
if (!body
|
|
76
|
+
if (!body)
|
|
74
77
|
continue;
|
|
75
|
-
|
|
76
|
-
|
|
78
|
+
// The body whatever its kind — a concise arrow's too — then what the parameters run at each
|
|
79
|
+
// call (bug 0314). A catch clause is never the root of either, so walking below it is enough.
|
|
80
|
+
for (const code of [body, ...codeOfParameters(fn.getParameters())]) {
|
|
81
|
+
for (const result of findSilentCatches(code)) {
|
|
82
|
+
violations.push(createViolation(result.node, result.message, context));
|
|
83
|
+
}
|
|
77
84
|
}
|
|
78
85
|
}
|
|
79
86
|
return violations;
|
|
@@ -86,9 +93,23 @@ export function moduleNoSilentCatch() {
|
|
|
86
93
|
evaluate(elements, context) {
|
|
87
94
|
const violations = [];
|
|
88
95
|
for (const sf of elements) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
96
|
+
const found = [...findSilentCatches(sf)];
|
|
97
|
+
// Named and identified as the other module conditions do (bug 0333). `createViolation`
|
|
98
|
+
// alone gave every module-scope catch `element = 'CatchClause'` — a KIND name, not a
|
|
99
|
+
// subject — and no producer identity, so a baseline keyed on `element::message` collapsed
|
|
100
|
+
// every top-level silent catch in a project into ONE bucket separated by a positional
|
|
101
|
+
// suffix. Measured on an adopter project by the customer review of this fix: accepting one
|
|
102
|
+
// catch accepted a different catch in a different file, and a delete-plus-add went green.
|
|
103
|
+
// A catch inside a function was never affected — its element is the function's name — which
|
|
104
|
+
// is why this surfaced only when the floor started reading module scope.
|
|
105
|
+
const identities = identifyMatches('module-body', sf.getFilePath(), found.map((result) => result.node), 'silent catch');
|
|
106
|
+
found.forEach((result, index) => {
|
|
107
|
+
violations.push({
|
|
108
|
+
...createViolation(result.node, result.message, context),
|
|
109
|
+
element: enclosingScopeName(result.node) ?? sf.getBaseName(),
|
|
110
|
+
identity: identities[index],
|
|
111
|
+
});
|
|
112
|
+
});
|
|
92
113
|
}
|
|
93
114
|
return violations;
|
|
94
115
|
},
|
package/dist/rules/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/rules/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/rules/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAI3C,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA;AAEjE,OAAO,EAAE,OAAO,EAA0B,MAAM,wBAAwB,CAAA;AACxE,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAA;AAC5E,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAA;AAEvF;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAA;AAC1C,CAAC;AAED;;GAEG;AACH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,CACf,CAAA;gBACD,KAAK,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;oBAC9B,UAAU,CAAC,IAAI,CAAC;wBACd,GAAG,eAAe,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC;wBACxD,OAAO,EAAE,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE;wBAC5D,QAAQ,EAAE,UAAU,CAAC,KAAK,CAAC;qBAC5B,CAAC,CAAA;gBACJ,CAAC,CAAC,CAAA;YACJ,CAAC;YACD,OAAO,UAAU,CAAA;QACnB,CAAC;KACF,CAAA;AACH,CAAC"}
|
package/dist/rules/hygiene.d.ts
CHANGED
|
@@ -42,7 +42,9 @@ export declare function noUnusedExports(): Condition<SourceFile>;
|
|
|
42
42
|
export declare function noStubComments(pattern?: RegExp): Condition<ArchFunction>;
|
|
43
43
|
/**
|
|
44
44
|
* Functions must not have empty bodies.
|
|
45
|
-
* An empty function compiles and passes type checks but does nothing.
|
|
45
|
+
* An empty function compiles and passes type checks but does nothing. An empty constructor whose every
|
|
46
|
+
* parameter is a parameter property, or a private or protected one that takes nothing, does something,
|
|
47
|
+
* and is not reported (bug 0315).
|
|
46
48
|
*
|
|
47
49
|
* @example
|
|
48
50
|
* functions(p)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hygiene.d.ts","sourceRoot":"","sources":["../../src/rules/hygiene.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,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAQ9D;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,IAAI,SAAS,CAAC,UAAU,CAAC,CAErD;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,IAAI,SAAS,CAAC,UAAU,CAAC,CAEvD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,OAAO,GAAE,MAAsB,GAAG,SAAS,CAAC,YAAY,CAAC,CAEvF;AAED
|
|
1
|
+
{"version":3,"file":"hygiene.d.ts","sourceRoot":"","sources":["../../src/rules/hygiene.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,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAQ9D;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,IAAI,SAAS,CAAC,UAAU,CAAC,CAErD;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,IAAI,SAAS,CAAC,UAAU,CAAC,CAEvD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,OAAO,GAAE,MAAsB,GAAG,SAAS,CAAC,YAAY,CAAC,CAEvF;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,IAAI,SAAS,CAAC,YAAY,CAAC,CAEvD"}
|
package/dist/rules/hygiene.js
CHANGED
|
@@ -48,7 +48,9 @@ export function noStubComments(pattern = STUB_PATTERNS) {
|
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
50
|
* Functions must not have empty bodies.
|
|
51
|
-
* An empty function compiles and passes type checks but does nothing.
|
|
51
|
+
* An empty function compiles and passes type checks but does nothing. An empty constructor whose every
|
|
52
|
+
* parameter is a parameter property, or a private or protected one that takes nothing, does something,
|
|
53
|
+
* and is not reported (bug 0315).
|
|
52
54
|
*
|
|
53
55
|
* @example
|
|
54
56
|
* functions(p)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hygiene.js","sourceRoot":"","sources":["../../src/rules/hygiene.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,E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,8 +1,8 @@
|
|
|
1
1
|
import type { ClassDeclaration } from 'ts-morph';
|
|
2
2
|
import type { Condition } from '@nielspeter/eess';
|
|
3
3
|
/**
|
|
4
|
-
* No
|
|
5
|
-
* cyclomatic complexity.
|
|
4
|
+
* No callable member of the class — a method, constructor or accessor, or a property whose
|
|
5
|
+
* value is a function — may exceed the given cyclomatic complexity (bug 0306).
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
8
|
* ```ts
|
|
@@ -25,7 +25,8 @@ export declare function maxCyclomaticComplexity(threshold: number): Condition<Cl
|
|
|
25
25
|
*/
|
|
26
26
|
export declare function maxClassLines(threshold: number): Condition<ClassDeclaration>;
|
|
27
27
|
/**
|
|
28
|
-
* No method
|
|
28
|
+
* No callable member of the class — a method, constructor or accessor, or a property whose
|
|
29
|
+
* value is a function — may exceed the given number of lines (bug 0306).
|
|
29
30
|
*
|
|
30
31
|
* @example
|
|
31
32
|
* ```ts
|
|
@@ -49,7 +50,8 @@ export declare function maxMethodLines(threshold: number): Condition<ClassDeclar
|
|
|
49
50
|
*/
|
|
50
51
|
export declare function maxMethods(threshold: number): Condition<ClassDeclaration>;
|
|
51
52
|
/**
|
|
52
|
-
* No
|
|
53
|
+
* No callable member of the class — a method, constructor or accessor, or a property whose
|
|
54
|
+
* value is a function — may have more than the given number of parameters (bug 0306).
|
|
53
55
|
*
|
|
54
56
|
* @example
|
|
55
57
|
* ```ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../src/rules/metrics.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../src/rules/metrics.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAChD,OAAO,KAAK,EAAE,SAAS,EAAoB,MAAM,kBAAkB,CAAA;AAkHnE;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC,gBAAgB,CAAC,CAQtF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC,gBAAgB,CAAC,CA2B5E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC,gBAAgB,CAAC,CAU7E;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC,gBAAgB,CAAC,CAwBzE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC,gBAAgB,CAAC,CAQ5E;AAGD,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,uBAAuB,CAAA"}
|
package/dist/rules/metrics.js
CHANGED
|
@@ -1,20 +1,38 @@
|
|
|
1
|
+
import { Node } from 'ts-morph';
|
|
1
2
|
import { cyclomaticComplexity, linesOfCode } from '../helpers/complexity.js';
|
|
2
3
|
import { metricViolation } from '../core/metric-violation.js';
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
import { functionValueOf } from '../models/arch-function.js';
|
|
5
|
+
function callableMembers(cls) {
|
|
6
|
+
const clsName = cls.getName() ?? '<anonymous>';
|
|
7
|
+
const members = [];
|
|
8
|
+
for (const member of [
|
|
5
9
|
...cls.getMethods(),
|
|
6
10
|
...cls.getConstructors(),
|
|
7
11
|
...cls.getGetAccessors(),
|
|
8
12
|
...cls.getSetAccessors(),
|
|
9
|
-
]
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
]) {
|
|
14
|
+
members.push({
|
|
15
|
+
node: member,
|
|
16
|
+
name: Node.isConstructorDeclaration(member)
|
|
17
|
+
? `${clsName}.constructor`
|
|
18
|
+
: `${clsName}.${member.getName()}`,
|
|
19
|
+
body: member.getBody(),
|
|
20
|
+
parameterCount: member.getParameters().length,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
// After the declared members, so a finding the old walk reported keeps its place.
|
|
24
|
+
for (const property of cls.getProperties()) {
|
|
25
|
+
const value = functionValueOf(property.getInitializer());
|
|
26
|
+
if (value === undefined)
|
|
27
|
+
continue;
|
|
28
|
+
members.push({
|
|
29
|
+
node: property,
|
|
30
|
+
name: `${clsName}.${property.getName()}`,
|
|
31
|
+
body: value.getBody(),
|
|
32
|
+
parameterCount: value.getParameters().length,
|
|
33
|
+
});
|
|
16
34
|
}
|
|
17
|
-
return
|
|
35
|
+
return members;
|
|
18
36
|
}
|
|
19
37
|
/**
|
|
20
38
|
* A ceiling on one measurement of every callable member of every class.
|
|
@@ -37,12 +55,12 @@ function memberCeiling(threshold, spec) {
|
|
|
37
55
|
evaluate(elements, context) {
|
|
38
56
|
const violations = [];
|
|
39
57
|
for (const cls of elements) {
|
|
40
|
-
for (const member of
|
|
58
|
+
for (const member of callableMembers(cls)) {
|
|
41
59
|
const value = spec.measure(member);
|
|
42
60
|
if (value <= threshold)
|
|
43
61
|
continue;
|
|
44
|
-
const name =
|
|
45
|
-
violations.push(metricViolation(member, {
|
|
62
|
+
const name = member.name;
|
|
63
|
+
violations.push(metricViolation(member.node, {
|
|
46
64
|
metric: spec.metric,
|
|
47
65
|
...(spec.unit === undefined ? {} : { unit: spec.unit }),
|
|
48
66
|
// Written long-hand deliberately: `measured,` is a
|
|
@@ -62,8 +80,8 @@ function memberCeiling(threshold, spec) {
|
|
|
62
80
|
};
|
|
63
81
|
}
|
|
64
82
|
/**
|
|
65
|
-
* No
|
|
66
|
-
* cyclomatic complexity.
|
|
83
|
+
* No callable member of the class — a method, constructor or accessor, or a property whose
|
|
84
|
+
* value is a function — may exceed the given cyclomatic complexity (bug 0306).
|
|
67
85
|
*
|
|
68
86
|
* @example
|
|
69
87
|
* ```ts
|
|
@@ -76,7 +94,7 @@ export function maxCyclomaticComplexity(threshold) {
|
|
|
76
94
|
return memberCeiling(threshold, {
|
|
77
95
|
description: `have no method with cyclomatic complexity > ${String(threshold)}`,
|
|
78
96
|
metric: 'complexity',
|
|
79
|
-
measure: (member) => cyclomaticComplexity(member.
|
|
97
|
+
measure: (member) => cyclomaticComplexity(member.body),
|
|
80
98
|
message: (name, cc) => `${name} has cyclomatic complexity ${String(cc)} (max: ${String(threshold)}) — split into smaller methods`,
|
|
81
99
|
});
|
|
82
100
|
}
|
|
@@ -114,7 +132,8 @@ export function maxClassLines(threshold) {
|
|
|
114
132
|
};
|
|
115
133
|
}
|
|
116
134
|
/**
|
|
117
|
-
* No method
|
|
135
|
+
* No callable member of the class — a method, constructor or accessor, or a property whose
|
|
136
|
+
* value is a function — may exceed the given number of lines (bug 0306).
|
|
118
137
|
*
|
|
119
138
|
* @example
|
|
120
139
|
* ```ts
|
|
@@ -130,7 +149,7 @@ export function maxMethodLines(threshold) {
|
|
|
130
149
|
// `code-lines` since bug 0170 — the metric kept its name when it stopped
|
|
131
150
|
// counting comments, and the baseline must not compare across that.
|
|
132
151
|
unit: 'code-lines',
|
|
133
|
-
measure: (member) => linesOfCode(member),
|
|
152
|
+
measure: (member) => linesOfCode(member.node),
|
|
134
153
|
message: (name, loc) => `${name} has ${String(loc)} code lines (max: ${String(threshold)})`,
|
|
135
154
|
});
|
|
136
155
|
}
|
|
@@ -166,7 +185,8 @@ export function maxMethods(threshold) {
|
|
|
166
185
|
};
|
|
167
186
|
}
|
|
168
187
|
/**
|
|
169
|
-
* No
|
|
188
|
+
* No callable member of the class — a method, constructor or accessor, or a property whose
|
|
189
|
+
* value is a function — may have more than the given number of parameters (bug 0306).
|
|
170
190
|
*
|
|
171
191
|
* @example
|
|
172
192
|
* ```ts
|
|
@@ -181,7 +201,7 @@ export function maxParameters(threshold) {
|
|
|
181
201
|
return memberCeiling(threshold, {
|
|
182
202
|
description: `have no method with more than ${String(threshold)} parameters`,
|
|
183
203
|
metric: 'parameters',
|
|
184
|
-
measure: (member) => member.
|
|
204
|
+
measure: (member) => member.parameterCount,
|
|
185
205
|
message: (name, params) => `${name} has ${String(params)} parameters (max: ${String(threshold)}) — use an options object`,
|
|
186
206
|
});
|
|
187
207
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../src/rules/metrics.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../src/rules/metrics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAI/B,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAkB5D,SAAS,eAAe,CAAC,GAAqB;IAC5C,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,EAAE,IAAI,aAAa,CAAA;IAC9C,MAAM,OAAO,GAAqB,EAAE,CAAA;IACpC,KAAK,MAAM,MAAM,IAAI;QACnB,GAAG,GAAG,CAAC,UAAU,EAAE;QACnB,GAAG,GAAG,CAAC,eAAe,EAAE;QACxB,GAAG,GAAG,CAAC,eAAe,EAAE;QACxB,GAAG,GAAG,CAAC,eAAe,EAAE;KACzB,EAAE,CAAC;QACF,OAAO,CAAC,IAAI,CAAC;YACX,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC;gBACzC,CAAC,CAAC,GAAG,OAAO,cAAc;gBAC1B,CAAC,CAAC,GAAG,OAAO,IAAI,MAAM,CAAC,OAAO,EAAE,EAAE;YACpC,IAAI,EAAE,MAAM,CAAC,OAAO,EAAE;YACtB,cAAc,EAAE,MAAM,CAAC,aAAa,EAAE,CAAC,MAAM;SAC9C,CAAC,CAAA;I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,OAAO,EAAE,GAAG,GAAG,CAAC,OAAO,EAAE,IAAI,aAAa,QAAQ,MAAM,CAAC,KAAK,CAAC,kBAAkB,MAAM,CAAC,SAAS,CAAC,6CAA6C;qBAChJ,EACD,OAAO,CACR,CACF,CAAA;gBACH,CAAC;YACH,CAAC;YACD,OAAO,UAAU,CAAA;QACnB,CAAC;KACF,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,aAAa,CAAC,SAAiB;IAC7C,OAAO,aAAa,CAAC,SAAS,EAAE;QAC9B,WAAW,EAAE,iCAAiC,MAAM,CAAC,SAAS,CAAC,aAAa;QAC5E,MAAM,EAAE,YAAY;QACpB,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,cAAc;QAC1C,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CACxB,GAAG,IAAI,QAAQ,MAAM,CAAC,MAAM,CAAC,qBAAqB,MAAM,CAAC,SAAS,CAAC,2BAA2B;KACjG,CAAC,CAAA;AACJ,CAAC;AAED,oEAAoE;AACpE,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,uBAAuB,CAAA"}
|
package/dist/rules/security.d.ts
CHANGED
|
@@ -2,21 +2,27 @@ import type { ClassDeclaration, SourceFile } from 'ts-morph';
|
|
|
2
2
|
import type { Condition } from '@nielspeter/eess';
|
|
3
3
|
import type { ArchFunction } from '../models/arch-function.js';
|
|
4
4
|
/**
|
|
5
|
-
* No eval() calls in class
|
|
5
|
+
* No eval() calls in any code a class runs — `eval(…)`, through a global object
|
|
6
|
+
* (`globalThis`, `window`, `self`, `global`), a string-keyed bracket, or the indirect
|
|
7
|
+
* `(0, eval)(…)`. An `eval` bound to a local name first is not seen (bug 0305).
|
|
6
8
|
*
|
|
7
9
|
* @example
|
|
8
10
|
* classes(p).should().satisfy(noEval()).check()
|
|
9
11
|
*/
|
|
10
12
|
export declare function noEval(): Condition<ClassDeclaration>;
|
|
11
13
|
/**
|
|
12
|
-
* No
|
|
14
|
+
* No Function constructor (equivalent to eval) — called with or without `new`, and
|
|
15
|
+
* through a global object.
|
|
13
16
|
*
|
|
14
17
|
* @example
|
|
15
18
|
* classes(p).should().satisfy(noFunctionConstructor()).check()
|
|
16
19
|
*/
|
|
17
20
|
export declare function noFunctionConstructor(): Condition<ClassDeclaration>;
|
|
18
21
|
/**
|
|
19
|
-
* No
|
|
22
|
+
* No process.env read in any code a class runs, as `notContain()` on the class
|
|
23
|
+
* builder defines it, spelled `process.env`, `process['env']`, or through a
|
|
24
|
+
* global object. An `env` destructured from `process` or imported from `node:process` is
|
|
25
|
+
* not seen (bug 0305); `import.meta.env` is not Node's environment and is not reported.
|
|
20
26
|
*
|
|
21
27
|
* Use dependency injection for configuration instead.
|
|
22
28
|
*
|
|
@@ -28,7 +34,8 @@ export declare function noFunctionConstructor(): Condition<ClassDeclaration>;
|
|
|
28
34
|
*/
|
|
29
35
|
export declare function noProcessEnv(): Condition<ClassDeclaration>;
|
|
30
36
|
/**
|
|
31
|
-
* No console.log calls in class
|
|
37
|
+
* No console.log calls in any code a class runs — including `console['log']` and through a
|
|
38
|
+
* global object.
|
|
32
39
|
*
|
|
33
40
|
* Use a logger abstraction instead.
|
|
34
41
|
*
|
|
@@ -39,7 +46,8 @@ export declare function noProcessEnv(): Condition<ClassDeclaration>;
|
|
|
39
46
|
*/
|
|
40
47
|
export declare function noConsoleLog(): Condition<ClassDeclaration>;
|
|
41
48
|
/**
|
|
42
|
-
* No direct console access (any method: log, warn, error, debug, info)
|
|
49
|
+
* No direct console access (any method: log, warn, error, debug, info), including
|
|
50
|
+
* bracketed and global-object spellings.
|
|
43
51
|
* Stricter than noConsoleLog — catches all console methods.
|
|
44
52
|
*/
|
|
45
53
|
export declare function noConsole(): Condition<ClassDeclaration>;
|
|
@@ -54,6 +62,12 @@ export declare function functionNoConsoleLog(): Condition<ArchFunction>;
|
|
|
54
62
|
export declare function functionNoConsole(): Condition<ArchFunction>;
|
|
55
63
|
export declare function functionNoJsonParse(): Condition<ArchFunction>;
|
|
56
64
|
export declare function moduleNoEval(): Condition<SourceFile>;
|
|
65
|
+
/**
|
|
66
|
+
* No Function constructor anywhere in a file — the module counterpart of
|
|
67
|
+
* {@link noFunctionConstructor}, added for bug 0333 so the `recommended` floor can read a rule over
|
|
68
|
+
* the broadest subject it has a variant for.
|
|
69
|
+
*/
|
|
70
|
+
export declare function moduleNoFunctionConstructor(): Condition<SourceFile>;
|
|
57
71
|
export declare function moduleNoProcessEnv(): Condition<SourceFile>;
|
|
58
72
|
export declare function moduleNoConsoleLog(): Condition<SourceFile>;
|
|
59
73
|
//# sourceMappingURL=security.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../../src/rules/security.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../../src/rules/security.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AA4K9D;;;;;;;GAOG;AACH,wBAAgB,MAAM,IAAI,SAAS,CAAC,gBAAgB,CAAC,CAEpD;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,IAAI,SAAS,CAAC,gBAAgB,CAAC,CAEnE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,IAAI,SAAS,CAAC,gBAAgB,CAAC,CAE1D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,IAAI,SAAS,CAAC,gBAAgB,CAAC,CAE1D;AAED;;;;GAIG;AACH,wBAAgB,SAAS,IAAI,SAAS,CAAC,gBAAgB,CAAC,CAEvD;AAED;;GAEG;AACH,wBAAgB,WAA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