eff-u-code 2.0.1 → 2.2.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 +27 -1
- package/bin/fuck-u-code.js +49 -1
- package/dist/analyzer/concurrent-analyzer.d.ts.map +1 -1
- package/dist/analyzer/concurrent-analyzer.js +20 -8
- package/dist/analyzer/concurrent-analyzer.js.map +1 -1
- package/dist/analyzer/index.d.ts +0 -3
- package/dist/analyzer/index.d.ts.map +1 -1
- package/dist/analyzer/index.js +9 -7
- package/dist/analyzer/index.js.map +1 -1
- package/dist/cli/commands/analyze.js +1 -0
- package/dist/cli/commands/analyze.js.map +1 -1
- package/dist/cli/commands/uninstall.d.ts +11 -0
- package/dist/cli/commands/uninstall.d.ts.map +1 -0
- package/dist/cli/commands/uninstall.js +195 -0
- package/dist/cli/commands/uninstall.js.map +1 -0
- package/dist/cli/commands/update.d.ts +6 -0
- package/dist/cli/commands/update.d.ts.map +1 -0
- package/dist/cli/commands/update.js +53 -0
- package/dist/cli/commands/update.js.map +1 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +7 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/output/json.d.ts.map +1 -1
- package/dist/cli/output/json.js +64 -0
- package/dist/cli/output/json.js.map +1 -1
- package/dist/config/schema.js +2 -2
- package/dist/i18n/locales/en.json +73 -1
- package/dist/i18n/locales/ru.json +73 -1
- package/dist/i18n/locales/zh.json +75 -3
- package/dist/mcp/server.js +4 -3
- package/dist/mcp/server.js.map +1 -1
- package/dist/metrics/complexity/cognitive.d.ts +5 -7
- package/dist/metrics/complexity/cognitive.d.ts.map +1 -1
- package/dist/metrics/complexity/cognitive.js +47 -32
- package/dist/metrics/complexity/cognitive.js.map +1 -1
- package/dist/metrics/complexity/cyclomatic.d.ts +5 -7
- package/dist/metrics/complexity/cyclomatic.d.ts.map +1 -1
- package/dist/metrics/complexity/cyclomatic.js +47 -40
- package/dist/metrics/complexity/cyclomatic.js.map +1 -1
- package/dist/metrics/complexity/nesting-depth.d.ts +5 -7
- package/dist/metrics/complexity/nesting-depth.d.ts.map +1 -1
- package/dist/metrics/complexity/nesting-depth.js +19 -24
- package/dist/metrics/complexity/nesting-depth.js.map +1 -1
- package/dist/metrics/index.d.ts +3 -2
- package/dist/metrics/index.d.ts.map +1 -1
- package/dist/metrics/index.js +8 -8
- package/dist/metrics/index.js.map +1 -1
- package/dist/metrics/naming/convention.d.ts.map +1 -1
- package/dist/metrics/naming/convention.js +4 -0
- package/dist/metrics/naming/convention.js.map +1 -1
- package/dist/metrics/size/file-length.d.ts +5 -7
- package/dist/metrics/size/file-length.d.ts.map +1 -1
- package/dist/metrics/size/file-length.js +18 -23
- package/dist/metrics/size/file-length.js.map +1 -1
- package/dist/metrics/size/function-length.d.ts +5 -8
- package/dist/metrics/size/function-length.d.ts.map +1 -1
- package/dist/metrics/size/function-length.js +45 -30
- package/dist/metrics/size/function-length.js.map +1 -1
- package/dist/metrics/size/parameter-count.d.ts +5 -7
- package/dist/metrics/size/parameter-count.d.ts.map +1 -1
- package/dist/metrics/size/parameter-count.js +19 -24
- package/dist/metrics/size/parameter-count.js.map +1 -1
- package/dist/metrics/thresholds/language-thresholds.d.ts +30 -0
- package/dist/metrics/thresholds/language-thresholds.d.ts.map +1 -0
- package/dist/metrics/thresholds/language-thresholds.js +247 -0
- package/dist/metrics/thresholds/language-thresholds.js.map +1 -0
- package/dist/parser/index.d.ts +1 -5
- package/dist/parser/index.d.ts.map +1 -1
- package/dist/parser/index.js +38 -22
- package/dist/parser/index.js.map +1 -1
- package/dist/parser/tree-sitter-parser.d.ts +3 -0
- package/dist/parser/tree-sitter-parser.d.ts.map +1 -1
- package/dist/parser/tree-sitter-parser.js +170 -26
- package/dist/parser/tree-sitter-parser.js.map +1 -1
- package/dist/parser/types.d.ts +1 -1
- package/dist/parser/types.d.ts.map +1 -1
- package/dist/parser/types.js +10 -0
- package/dist/parser/types.js.map +1 -1
- package/dist/scoring/index.d.ts +0 -3
- package/dist/scoring/index.d.ts.map +1 -1
- package/dist/scoring/index.js +0 -3
- package/dist/scoring/index.js.map +1 -1
- package/dist/version.d.ts +6 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +6 -0
- package/dist/version.js.map +1 -0
- package/package.json +1 -1
|
@@ -1,29 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Function length metric
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* - 51-150 lines: Good, typical business logic
|
|
7
|
-
* - 151-300 lines: Acceptable, complex but manageable
|
|
8
|
-
* - 301-500 lines: Poor, consider refactoring
|
|
9
|
-
* - 500+ lines: Critical, needs refactoring
|
|
4
|
+
* Language-specific thresholds based on official linter defaults.
|
|
5
|
+
* See src/metrics/thresholds/language-thresholds.ts for sources.
|
|
10
6
|
*/
|
|
11
7
|
import { t } from '../../i18n/index.js';
|
|
12
|
-
|
|
13
|
-
EXCELLENT: 50,
|
|
14
|
-
GOOD: 150,
|
|
15
|
-
ACCEPTABLE: 300,
|
|
16
|
-
POOR: 500,
|
|
17
|
-
};
|
|
8
|
+
import { getThresholds } from '../thresholds/language-thresholds.js';
|
|
18
9
|
export class FunctionLengthMetric {
|
|
19
10
|
name = 'function_length';
|
|
20
11
|
category = 'size';
|
|
21
12
|
weight;
|
|
22
|
-
|
|
13
|
+
language;
|
|
14
|
+
constructor(weight, language) {
|
|
23
15
|
this.weight = weight;
|
|
16
|
+
this.language = language;
|
|
24
17
|
}
|
|
25
18
|
calculate(parseResult) {
|
|
26
19
|
const { functions, filePath } = parseResult;
|
|
20
|
+
const thresholds = getThresholds(this.language, 'functionLength');
|
|
27
21
|
if (functions.length === 0) {
|
|
28
22
|
return {
|
|
29
23
|
name: this.name,
|
|
@@ -42,7 +36,7 @@ export class FunctionLengthMetric {
|
|
|
42
36
|
if (func.lineCount > maxLength) {
|
|
43
37
|
maxLength = func.lineCount;
|
|
44
38
|
}
|
|
45
|
-
if (func.lineCount >
|
|
39
|
+
if (func.lineCount > thresholds.good) {
|
|
46
40
|
locations.push({
|
|
47
41
|
filePath,
|
|
48
42
|
line: func.startLine,
|
|
@@ -52,33 +46,54 @@ export class FunctionLengthMetric {
|
|
|
52
46
|
}
|
|
53
47
|
}
|
|
54
48
|
const avgLength = totalLength / functions.length;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
49
|
+
// Industry standard (SonarQube): weighted scoring considering both average and worst-case
|
|
50
|
+
let avgScore;
|
|
51
|
+
if (avgLength <= thresholds.excellent) {
|
|
52
|
+
avgScore = 100;
|
|
58
53
|
}
|
|
59
|
-
else if (avgLength <=
|
|
60
|
-
|
|
61
|
-
100 - ((avgLength -
|
|
54
|
+
else if (avgLength <= thresholds.good) {
|
|
55
|
+
avgScore =
|
|
56
|
+
100 - ((avgLength - thresholds.excellent) / (thresholds.good - thresholds.excellent)) * 15;
|
|
62
57
|
}
|
|
63
|
-
else if (avgLength <=
|
|
64
|
-
|
|
65
|
-
85 - ((avgLength -
|
|
58
|
+
else if (avgLength <= thresholds.acceptable) {
|
|
59
|
+
avgScore =
|
|
60
|
+
85 - ((avgLength - thresholds.good) / (thresholds.acceptable - thresholds.good)) * 35;
|
|
66
61
|
}
|
|
67
|
-
else if (avgLength <=
|
|
68
|
-
|
|
69
|
-
50 - ((avgLength -
|
|
62
|
+
else if (avgLength <= thresholds.poor) {
|
|
63
|
+
avgScore =
|
|
64
|
+
50 - ((avgLength - thresholds.acceptable) / (thresholds.poor - thresholds.acceptable)) * 35;
|
|
70
65
|
}
|
|
71
66
|
else {
|
|
72
|
-
|
|
67
|
+
avgScore = Math.max(0, 15 * Math.exp(-(avgLength - thresholds.poor) / 50));
|
|
73
68
|
}
|
|
69
|
+
let maxScore;
|
|
70
|
+
if (maxLength <= thresholds.excellent) {
|
|
71
|
+
maxScore = 100;
|
|
72
|
+
}
|
|
73
|
+
else if (maxLength <= thresholds.good) {
|
|
74
|
+
maxScore =
|
|
75
|
+
100 - ((maxLength - thresholds.excellent) / (thresholds.good - thresholds.excellent)) * 15;
|
|
76
|
+
}
|
|
77
|
+
else if (maxLength <= thresholds.acceptable) {
|
|
78
|
+
maxScore =
|
|
79
|
+
85 - ((maxLength - thresholds.good) / (thresholds.acceptable - thresholds.good)) * 35;
|
|
80
|
+
}
|
|
81
|
+
else if (maxLength <= thresholds.poor) {
|
|
82
|
+
maxScore =
|
|
83
|
+
50 - ((maxLength - thresholds.acceptable) / (thresholds.poor - thresholds.acceptable)) * 35;
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
maxScore = Math.max(0, 15 * Math.exp(-(maxLength - thresholds.poor) / 50));
|
|
87
|
+
}
|
|
88
|
+
const normalizedScore = avgScore * 0.5 + maxScore * 0.5;
|
|
74
89
|
let severity;
|
|
75
|
-
if (maxLength <=
|
|
90
|
+
if (maxLength <= thresholds.good) {
|
|
76
91
|
severity = 'info';
|
|
77
92
|
}
|
|
78
|
-
else if (maxLength <=
|
|
93
|
+
else if (maxLength <= thresholds.acceptable) {
|
|
79
94
|
severity = 'warning';
|
|
80
95
|
}
|
|
81
|
-
else if (maxLength <=
|
|
96
|
+
else if (maxLength <= thresholds.poor) {
|
|
82
97
|
severity = 'error';
|
|
83
98
|
}
|
|
84
99
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function-length.js","sourceRoot":"","sources":["../../../src/metrics/size/function-length.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"function-length.js","sourceRoot":"","sources":["../../../src/metrics/size/function-length.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,CAAC,EAAE,MAAM,qBAAqB,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAErE,MAAM,OAAO,oBAAoB;IACtB,IAAI,GAAG,iBAAiB,CAAC;IACzB,QAAQ,GAAmB,MAAM,CAAC;IAClC,MAAM,CAAS;IACP,QAAQ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AAC;aAAM,CAAC;YACN,QAAQ,GAAG,UAAU,CAAC;QACxB,CAAC;QAED,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,KAAK,EAAE,SAAS;YAChB,eAAe,EAAE,IAAI,CAAC,KAAK,CAAC,eAAe,GAAG,EAAE,CAAC,GAAG,EAAE;YACtD,QAAQ;YACR,OAAO,EAAE,CAAC,CAAC,4BAA4B,EAAE;gBACvC,GAAG,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;gBACzB,GAAG,EAAE,MAAM,CAAC,SAAS,CAAC;aACvB,CAAC;YACF,SAAS,EAAE,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;SACxD,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Parameter count metric
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* - 4-5: Good, acceptable
|
|
7
|
-
* - 6-7: Moderate, consider using object parameter
|
|
8
|
-
* - 8+: Poor, should be refactored
|
|
4
|
+
* Language-specific thresholds based on official linter defaults.
|
|
5
|
+
* See src/metrics/thresholds/language-thresholds.ts for sources.
|
|
9
6
|
*/
|
|
10
7
|
import type { Metric, MetricResult, MetricCategory } from '../types.js';
|
|
11
|
-
import type { ParseResult } from '../../parser/types.js';
|
|
8
|
+
import type { ParseResult, Language } from '../../parser/types.js';
|
|
12
9
|
export declare class ParameterCountMetric implements Metric {
|
|
13
10
|
readonly name = "parameter_count";
|
|
14
11
|
readonly category: MetricCategory;
|
|
15
12
|
readonly weight: number;
|
|
16
|
-
|
|
13
|
+
private readonly language;
|
|
14
|
+
constructor(weight: number, language: Language);
|
|
17
15
|
calculate(parseResult: ParseResult): MetricResult;
|
|
18
16
|
}
|
|
19
17
|
//# sourceMappingURL=parameter-count.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parameter-count.d.ts","sourceRoot":"","sources":["../../../src/metrics/size/parameter-count.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"parameter-count.d.ts","sourceRoot":"","sources":["../../../src/metrics/size/parameter-count.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,cAAc,EAA4B,MAAM,aAAa,CAAC;AAClG,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAInE,qBAAa,oBAAqB,YAAW,MAAM;IACjD,QAAQ,CAAC,IAAI,qBAAqB;IAClC,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAU;IAC3C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAW;gBAExB,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ;IAK9C,SAAS,CAAC,WAAW,EAAE,WAAW,GAAG,YAAY;CAyElD"}
|
|
@@ -1,28 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Parameter count metric
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* - 4-5: Good, acceptable
|
|
7
|
-
* - 6-7: Moderate, consider using object parameter
|
|
8
|
-
* - 8+: Poor, should be refactored
|
|
4
|
+
* Language-specific thresholds based on official linter defaults.
|
|
5
|
+
* See src/metrics/thresholds/language-thresholds.ts for sources.
|
|
9
6
|
*/
|
|
10
7
|
import { t } from '../../i18n/index.js';
|
|
11
|
-
|
|
12
|
-
EXCELLENT: 3,
|
|
13
|
-
GOOD: 5,
|
|
14
|
-
ACCEPTABLE: 7,
|
|
15
|
-
POOR: 10,
|
|
16
|
-
};
|
|
8
|
+
import { getThresholds } from '../thresholds/language-thresholds.js';
|
|
17
9
|
export class ParameterCountMetric {
|
|
18
10
|
name = 'parameter_count';
|
|
19
11
|
category = 'size';
|
|
20
12
|
weight;
|
|
21
|
-
|
|
13
|
+
language;
|
|
14
|
+
constructor(weight, language) {
|
|
22
15
|
this.weight = weight;
|
|
16
|
+
this.language = language;
|
|
23
17
|
}
|
|
24
18
|
calculate(parseResult) {
|
|
25
19
|
const { functions, filePath } = parseResult;
|
|
20
|
+
const thresholds = getThresholds(this.language, 'parameterCount');
|
|
26
21
|
if (functions.length === 0) {
|
|
27
22
|
return {
|
|
28
23
|
name: this.name,
|
|
@@ -41,7 +36,7 @@ export class ParameterCountMetric {
|
|
|
41
36
|
if (func.parameterCount > maxParams) {
|
|
42
37
|
maxParams = func.parameterCount;
|
|
43
38
|
}
|
|
44
|
-
if (func.parameterCount >
|
|
39
|
+
if (func.parameterCount > thresholds.good) {
|
|
45
40
|
locations.push({
|
|
46
41
|
filePath,
|
|
47
42
|
line: func.startLine,
|
|
@@ -52,32 +47,32 @@ export class ParameterCountMetric {
|
|
|
52
47
|
}
|
|
53
48
|
const avgParams = totalParams / functions.length;
|
|
54
49
|
let normalizedScore;
|
|
55
|
-
if (maxParams <=
|
|
50
|
+
if (maxParams <= thresholds.excellent) {
|
|
56
51
|
normalizedScore = 100;
|
|
57
52
|
}
|
|
58
|
-
else if (maxParams <=
|
|
53
|
+
else if (maxParams <= thresholds.good) {
|
|
59
54
|
normalizedScore =
|
|
60
|
-
100 - ((maxParams -
|
|
55
|
+
100 - ((maxParams - thresholds.excellent) / (thresholds.good - thresholds.excellent)) * 15;
|
|
61
56
|
}
|
|
62
|
-
else if (maxParams <=
|
|
57
|
+
else if (maxParams <= thresholds.acceptable) {
|
|
63
58
|
normalizedScore =
|
|
64
|
-
85 - ((maxParams -
|
|
59
|
+
85 - ((maxParams - thresholds.good) / (thresholds.acceptable - thresholds.good)) * 35;
|
|
65
60
|
}
|
|
66
|
-
else if (maxParams <=
|
|
61
|
+
else if (maxParams <= thresholds.poor) {
|
|
67
62
|
normalizedScore =
|
|
68
|
-
50 - ((maxParams -
|
|
63
|
+
50 - ((maxParams - thresholds.acceptable) / (thresholds.poor - thresholds.acceptable)) * 35;
|
|
69
64
|
}
|
|
70
65
|
else {
|
|
71
|
-
normalizedScore = Math.max(0, 15 * Math.exp(-(maxParams -
|
|
66
|
+
normalizedScore = Math.max(0, 15 * Math.exp(-(maxParams - thresholds.poor) / 3));
|
|
72
67
|
}
|
|
73
68
|
let severity;
|
|
74
|
-
if (maxParams <=
|
|
69
|
+
if (maxParams <= thresholds.excellent) {
|
|
75
70
|
severity = 'info';
|
|
76
71
|
}
|
|
77
|
-
else if (maxParams <=
|
|
72
|
+
else if (maxParams <= thresholds.good) {
|
|
78
73
|
severity = 'warning';
|
|
79
74
|
}
|
|
80
|
-
else if (maxParams <=
|
|
75
|
+
else if (maxParams <= thresholds.acceptable) {
|
|
81
76
|
severity = 'error';
|
|
82
77
|
}
|
|
83
78
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parameter-count.js","sourceRoot":"","sources":["../../../src/metrics/size/parameter-count.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"parameter-count.js","sourceRoot":"","sources":["../../../src/metrics/size/parameter-count.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,CAAC,EAAE,MAAM,qBAAqB,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAErE,MAAM,OAAO,oBAAoB;IACtB,IAAI,GAAG,iBAAiB,CAAC;IACzB,QAAQ,GAAmB,MAAM,CAAC;IAClC,MAAM,CAAS;IACP,QAAQ,CAAW;IAEpC,YAAY,MAAc,EAAE,QAAkB;QAC5C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,SAAS,CAAC,WAAwB;QAChC,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,WAAW,CAAC;QA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I;YACf,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,KAAK,EAAE,SAAS;YAChB,eAAe,EAAE,IAAI,CAAC,KAAK,CAAC,eAAe,GAAG,EAAE,CAAC,GAAG,EAAE;YACtD,QAAQ;YACR,OAAO,EAAE,CAAC,CAAC,gBAAgB,EAAE,EAAE,GAAG,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;YACnF,SAAS,EAAE,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;SACxD,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Language-specific code quality thresholds
|
|
3
|
+
*
|
|
4
|
+
* All thresholds are based on official linter defaults and industry standards.
|
|
5
|
+
* Sources are documented for each language.
|
|
6
|
+
*/
|
|
7
|
+
import type { Language } from '../../parser/types.js';
|
|
8
|
+
export interface ThresholdConfig {
|
|
9
|
+
excellent: number;
|
|
10
|
+
good: number;
|
|
11
|
+
acceptable: number;
|
|
12
|
+
poor: number;
|
|
13
|
+
}
|
|
14
|
+
export interface LanguageThresholds {
|
|
15
|
+
cyclomaticComplexity: ThresholdConfig;
|
|
16
|
+
cognitiveComplexity: ThresholdConfig;
|
|
17
|
+
functionLength: ThresholdConfig;
|
|
18
|
+
fileLength: ThresholdConfig;
|
|
19
|
+
parameterCount: ThresholdConfig;
|
|
20
|
+
nestingDepth: ThresholdConfig;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Language-specific thresholds map
|
|
24
|
+
*/
|
|
25
|
+
export declare const LANGUAGE_THRESHOLDS: Record<Exclude<Language, 'unknown'>, LanguageThresholds>;
|
|
26
|
+
/**
|
|
27
|
+
* Get thresholds for a specific language and metric
|
|
28
|
+
*/
|
|
29
|
+
export declare function getThresholds(language: Language, metric: keyof LanguageThresholds): ThresholdConfig;
|
|
30
|
+
//# sourceMappingURL=language-thresholds.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"language-thresholds.d.ts","sourceRoot":"","sources":["../../../src/metrics/thresholds/language-thresholds.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEtD,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,kBAAkB;IACjC,oBAAoB,EAAE,eAAe,CAAC;IACtC,mBAAmB,EAAE,eAAe,CAAC;IACrC,cAAc,EAAE,eAAe,CAAC;IAChC,UAAU,EAAE,eAAe,CAAC;IAC5B,cAAc,EAAE,eAAe,CAAC;IAChC,YAAY,EAAE,eAAe,CAAC;CAC/B;AAkOD;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,SAAS,CAAC,EAAE,kBAAkB,CAexF,CAAC;AAEF;;GAEG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,kBAAkB,GAC/B,eAAe,CAMjB"}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Language-specific code quality thresholds
|
|
3
|
+
*
|
|
4
|
+
* All thresholds are based on official linter defaults and industry standards.
|
|
5
|
+
* Sources are documented for each language.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Go language thresholds
|
|
9
|
+
* Sources:
|
|
10
|
+
* - gocyclo: default threshold 10 (https://github.com/fzipp/gocyclo)
|
|
11
|
+
* - gocognit: default threshold 15 (https://github.com/uudashr/gocognit)
|
|
12
|
+
* - Effective Go: recommends short functions (https://go.dev/doc/effective_go)
|
|
13
|
+
* - staticcheck: no specific line limits, focuses on complexity
|
|
14
|
+
*/
|
|
15
|
+
const GO_THRESHOLDS = {
|
|
16
|
+
cyclomaticComplexity: { excellent: 5, good: 10, acceptable: 15, poor: 20 },
|
|
17
|
+
cognitiveComplexity: { excellent: 7, good: 15, acceptable: 25, poor: 35 },
|
|
18
|
+
functionLength: { excellent: 50, good: 100, acceptable: 200, poor: 300 },
|
|
19
|
+
fileLength: { excellent: 300, good: 500, acceptable: 1000, poor: 1500 },
|
|
20
|
+
parameterCount: { excellent: 3, good: 5, acceptable: 7, poor: 10 },
|
|
21
|
+
nestingDepth: { excellent: 3, good: 4, acceptable: 5, poor: 7 },
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* JavaScript/TypeScript thresholds
|
|
25
|
+
* Sources:
|
|
26
|
+
* - ESLint complexity rule: default 20 (https://eslint.org/docs/latest/rules/complexity)
|
|
27
|
+
* - ESLint max-params: commonly set to 3-4
|
|
28
|
+
* - ESLint max-depth: commonly set to 4
|
|
29
|
+
* - ESLint max-lines-per-function: no default, 50-100 common
|
|
30
|
+
* - @typescript-eslint follows same conventions
|
|
31
|
+
*/
|
|
32
|
+
const JAVASCRIPT_THRESHOLDS = {
|
|
33
|
+
cyclomaticComplexity: { excellent: 5, good: 10, acceptable: 20, poor: 30 },
|
|
34
|
+
cognitiveComplexity: { excellent: 8, good: 15, acceptable: 25, poor: 40 },
|
|
35
|
+
functionLength: { excellent: 50, good: 100, acceptable: 200, poor: 300 },
|
|
36
|
+
fileLength: { excellent: 250, good: 400, acceptable: 800, poor: 1200 },
|
|
37
|
+
parameterCount: { excellent: 3, good: 4, acceptable: 6, poor: 8 },
|
|
38
|
+
nestingDepth: { excellent: 3, good: 4, acceptable: 5, poor: 7 },
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Python thresholds
|
|
42
|
+
* Sources:
|
|
43
|
+
* - Pylint max-complexity: default 10 (https://pylint.readthedocs.io/)
|
|
44
|
+
* - Pylint max-args: default 5
|
|
45
|
+
* - Pylint max-nested-blocks: default 5
|
|
46
|
+
* - Pylint max-statements: default 50
|
|
47
|
+
* - Pylint max-module-lines: default 1000
|
|
48
|
+
* - McCabe complexity: threshold 10 (original paper recommendation)
|
|
49
|
+
*/
|
|
50
|
+
const PYTHON_THRESHOLDS = {
|
|
51
|
+
cyclomaticComplexity: { excellent: 5, good: 10, acceptable: 15, poor: 20 },
|
|
52
|
+
cognitiveComplexity: { excellent: 7, good: 12, acceptable: 20, poor: 30 },
|
|
53
|
+
functionLength: { excellent: 30, good: 50, acceptable: 100, poor: 150 },
|
|
54
|
+
fileLength: { excellent: 300, good: 500, acceptable: 1000, poor: 1500 },
|
|
55
|
+
parameterCount: { excellent: 3, good: 5, acceptable: 7, poor: 10 },
|
|
56
|
+
nestingDepth: { excellent: 3, good: 5, acceptable: 7, poor: 10 },
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Java thresholds
|
|
60
|
+
* Sources:
|
|
61
|
+
* - SonarQube Java: complexity threshold 10 (https://rules.sonarsource.com/java/)
|
|
62
|
+
* - Google Java Style: no hard limits, recommends short methods
|
|
63
|
+
* - Checkstyle MethodLength: default 150 lines
|
|
64
|
+
* - Checkstyle ParameterNumber: default 7
|
|
65
|
+
* - PMD CyclomaticComplexity: default 10
|
|
66
|
+
*/
|
|
67
|
+
const JAVA_THRESHOLDS = {
|
|
68
|
+
cyclomaticComplexity: { excellent: 5, good: 10, acceptable: 15, poor: 20 },
|
|
69
|
+
cognitiveComplexity: { excellent: 8, good: 15, acceptable: 25, poor: 35 },
|
|
70
|
+
functionLength: { excellent: 50, good: 100, acceptable: 150, poor: 250 },
|
|
71
|
+
fileLength: { excellent: 300, good: 500, acceptable: 1000, poor: 1500 },
|
|
72
|
+
parameterCount: { excellent: 3, good: 5, acceptable: 7, poor: 10 },
|
|
73
|
+
nestingDepth: { excellent: 3, good: 4, acceptable: 5, poor: 7 },
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* C thresholds
|
|
77
|
+
* Sources:
|
|
78
|
+
* - Linux Kernel Coding Style: max 3 levels of indentation
|
|
79
|
+
* - Linux Kernel: functions should fit on 1-2 screens (24-48 lines)
|
|
80
|
+
* - cppcheck: no default complexity threshold
|
|
81
|
+
* - SonarQube C: complexity threshold 10
|
|
82
|
+
*/
|
|
83
|
+
const C_THRESHOLDS = {
|
|
84
|
+
cyclomaticComplexity: { excellent: 5, good: 10, acceptable: 15, poor: 20 },
|
|
85
|
+
cognitiveComplexity: { excellent: 7, good: 12, acceptable: 20, poor: 30 },
|
|
86
|
+
functionLength: { excellent: 40, good: 80, acceptable: 150, poor: 250 },
|
|
87
|
+
fileLength: { excellent: 300, good: 500, acceptable: 1000, poor: 1500 },
|
|
88
|
+
parameterCount: { excellent: 3, good: 5, acceptable: 7, poor: 10 },
|
|
89
|
+
nestingDepth: { excellent: 3, good: 4, acceptable: 5, poor: 7 },
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* C++ thresholds
|
|
93
|
+
* Sources:
|
|
94
|
+
* - Google C++ Style Guide: no hard limits on function length
|
|
95
|
+
* - LLVM Coding Standards: prefer small focused functions
|
|
96
|
+
* - clang-tidy readability-function-cognitive-complexity: default 25
|
|
97
|
+
* - SonarQube C++: complexity threshold 10
|
|
98
|
+
*/
|
|
99
|
+
const CPP_THRESHOLDS = {
|
|
100
|
+
cyclomaticComplexity: { excellent: 5, good: 10, acceptable: 15, poor: 20 },
|
|
101
|
+
cognitiveComplexity: { excellent: 8, good: 15, acceptable: 25, poor: 35 },
|
|
102
|
+
functionLength: { excellent: 50, good: 100, acceptable: 200, poor: 300 },
|
|
103
|
+
fileLength: { excellent: 300, good: 500, acceptable: 1000, poor: 1500 },
|
|
104
|
+
parameterCount: { excellent: 3, good: 5, acceptable: 7, poor: 10 },
|
|
105
|
+
nestingDepth: { excellent: 3, good: 4, acceptable: 5, poor: 7 },
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Rust thresholds
|
|
109
|
+
* Sources:
|
|
110
|
+
* - Clippy cognitive_complexity: default 25 (https://rust-lang.github.io/rust-clippy/)
|
|
111
|
+
* - Clippy too_many_arguments: default 7
|
|
112
|
+
* - Clippy too_many_lines: default 100
|
|
113
|
+
* - Rust API Guidelines: prefer small focused functions
|
|
114
|
+
*/
|
|
115
|
+
const RUST_THRESHOLDS = {
|
|
116
|
+
cyclomaticComplexity: { excellent: 5, good: 10, acceptable: 15, poor: 20 },
|
|
117
|
+
cognitiveComplexity: { excellent: 8, good: 15, acceptable: 25, poor: 35 },
|
|
118
|
+
functionLength: { excellent: 50, good: 100, acceptable: 200, poor: 300 },
|
|
119
|
+
fileLength: { excellent: 300, good: 500, acceptable: 1000, poor: 1500 },
|
|
120
|
+
parameterCount: { excellent: 3, good: 5, acceptable: 7, poor: 10 },
|
|
121
|
+
nestingDepth: { excellent: 3, good: 4, acceptable: 5, poor: 7 },
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* C# thresholds
|
|
125
|
+
* Sources:
|
|
126
|
+
* - SonarQube C#: complexity threshold 10 (https://rules.sonarsource.com/csharp/)
|
|
127
|
+
* - Microsoft C# conventions: no hard limits specified
|
|
128
|
+
* - StyleCop SA1407: arithmetic expressions should declare precedence
|
|
129
|
+
* - Roslyn analyzers: follow similar patterns to Java
|
|
130
|
+
*/
|
|
131
|
+
const CSHARP_THRESHOLDS = {
|
|
132
|
+
cyclomaticComplexity: { excellent: 5, good: 10, acceptable: 15, poor: 20 },
|
|
133
|
+
cognitiveComplexity: { excellent: 8, good: 15, acceptable: 25, poor: 35 },
|
|
134
|
+
functionLength: { excellent: 50, good: 100, acceptable: 200, poor: 300 },
|
|
135
|
+
fileLength: { excellent: 300, good: 500, acceptable: 1000, poor: 1500 },
|
|
136
|
+
parameterCount: { excellent: 3, good: 5, acceptable: 7, poor: 10 },
|
|
137
|
+
nestingDepth: { excellent: 3, good: 4, acceptable: 5, poor: 7 },
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* Lua thresholds
|
|
141
|
+
* Sources:
|
|
142
|
+
* - luacheck: no default complexity threshold (https://luacheck.readthedocs.io/)
|
|
143
|
+
* - luacheck max_line_length: default 120
|
|
144
|
+
* - luacheck max_code_line_length: default 120
|
|
145
|
+
* - Using SonarQube defaults as fallback (no official Lua linter with complexity metrics)
|
|
146
|
+
*/
|
|
147
|
+
const LUA_THRESHOLDS = {
|
|
148
|
+
cyclomaticComplexity: { excellent: 5, good: 10, acceptable: 15, poor: 20 },
|
|
149
|
+
cognitiveComplexity: { excellent: 8, good: 15, acceptable: 25, poor: 35 },
|
|
150
|
+
functionLength: { excellent: 50, good: 100, acceptable: 200, poor: 300 },
|
|
151
|
+
fileLength: { excellent: 300, good: 500, acceptable: 1000, poor: 1500 },
|
|
152
|
+
parameterCount: { excellent: 3, good: 5, acceptable: 7, poor: 10 },
|
|
153
|
+
nestingDepth: { excellent: 3, good: 4, acceptable: 5, poor: 7 },
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* PHP thresholds
|
|
157
|
+
* Sources:
|
|
158
|
+
* - PHP_CodeSniffer: complexity threshold 10
|
|
159
|
+
* - PHPMD (PHP Mess Detector): cyclomatic complexity 10, NPath complexity 200
|
|
160
|
+
* - PSR-12: no specific complexity limits
|
|
161
|
+
* - SonarQube PHP: complexity threshold 10
|
|
162
|
+
*/
|
|
163
|
+
const PHP_THRESHOLDS = {
|
|
164
|
+
cyclomaticComplexity: { excellent: 5, good: 10, acceptable: 15, poor: 20 },
|
|
165
|
+
cognitiveComplexity: { excellent: 8, good: 15, acceptable: 25, poor: 35 },
|
|
166
|
+
functionLength: { excellent: 50, good: 100, acceptable: 200, poor: 300 },
|
|
167
|
+
fileLength: { excellent: 300, good: 500, acceptable: 1000, poor: 1500 },
|
|
168
|
+
parameterCount: { excellent: 3, good: 5, acceptable: 7, poor: 10 },
|
|
169
|
+
nestingDepth: { excellent: 3, good: 5, acceptable: 7, poor: 10 },
|
|
170
|
+
};
|
|
171
|
+
/**
|
|
172
|
+
* Ruby thresholds
|
|
173
|
+
* Sources:
|
|
174
|
+
* - RuboCop Metrics/CyclomaticComplexity: default 7
|
|
175
|
+
* - RuboCop Metrics/PerceivedComplexity: default 8
|
|
176
|
+
* - RuboCop Metrics/MethodLength: default 10 lines
|
|
177
|
+
* - Ruby Style Guide: prefer short methods
|
|
178
|
+
*/
|
|
179
|
+
const RUBY_THRESHOLDS = {
|
|
180
|
+
cyclomaticComplexity: { excellent: 4, good: 7, acceptable: 12, poor: 18 },
|
|
181
|
+
cognitiveComplexity: { excellent: 5, good: 8, acceptable: 15, poor: 25 },
|
|
182
|
+
functionLength: { excellent: 20, good: 50, acceptable: 100, poor: 200 },
|
|
183
|
+
fileLength: { excellent: 250, good: 400, acceptable: 800, poor: 1200 },
|
|
184
|
+
parameterCount: { excellent: 3, good: 4, acceptable: 6, poor: 8 },
|
|
185
|
+
nestingDepth: { excellent: 3, good: 4, acceptable: 5, poor: 7 },
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* Swift thresholds
|
|
189
|
+
* Sources:
|
|
190
|
+
* - SwiftLint cyclomatic_complexity: warning 10, error 20
|
|
191
|
+
* - SwiftLint function_body_length: warning 40, error 100
|
|
192
|
+
* - SwiftLint type_body_length: warning 200, error 350
|
|
193
|
+
* - Apple Swift API Design Guidelines: prefer clarity
|
|
194
|
+
*/
|
|
195
|
+
const SWIFT_THRESHOLDS = {
|
|
196
|
+
cyclomaticComplexity: { excellent: 5, good: 10, acceptable: 20, poor: 30 },
|
|
197
|
+
cognitiveComplexity: { excellent: 7, good: 12, acceptable: 20, poor: 30 },
|
|
198
|
+
functionLength: { excellent: 30, good: 40, acceptable: 100, poor: 150 },
|
|
199
|
+
fileLength: { excellent: 200, good: 350, acceptable: 600, poor: 1000 },
|
|
200
|
+
parameterCount: { excellent: 3, good: 5, acceptable: 7, poor: 10 },
|
|
201
|
+
nestingDepth: { excellent: 3, good: 4, acceptable: 5, poor: 7 },
|
|
202
|
+
};
|
|
203
|
+
/**
|
|
204
|
+
* Shell thresholds
|
|
205
|
+
* Sources:
|
|
206
|
+
* - ShellCheck: no complexity metrics
|
|
207
|
+
* - Google Shell Style Guide: functions should be short
|
|
208
|
+
* - Using conservative thresholds due to shell script complexity
|
|
209
|
+
*/
|
|
210
|
+
const SHELL_THRESHOLDS = {
|
|
211
|
+
cyclomaticComplexity: { excellent: 5, good: 10, acceptable: 15, poor: 20 },
|
|
212
|
+
cognitiveComplexity: { excellent: 7, good: 12, acceptable: 20, poor: 30 },
|
|
213
|
+
functionLength: { excellent: 30, good: 50, acceptable: 100, poor: 150 },
|
|
214
|
+
fileLength: { excellent: 200, good: 300, acceptable: 600, poor: 1000 },
|
|
215
|
+
parameterCount: { excellent: 3, good: 5, acceptable: 7, poor: 10 },
|
|
216
|
+
nestingDepth: { excellent: 3, good: 4, acceptable: 5, poor: 7 },
|
|
217
|
+
};
|
|
218
|
+
/**
|
|
219
|
+
* Language-specific thresholds map
|
|
220
|
+
*/
|
|
221
|
+
export const LANGUAGE_THRESHOLDS = {
|
|
222
|
+
go: GO_THRESHOLDS,
|
|
223
|
+
javascript: JAVASCRIPT_THRESHOLDS,
|
|
224
|
+
typescript: JAVASCRIPT_THRESHOLDS, // TypeScript follows JavaScript conventions
|
|
225
|
+
python: PYTHON_THRESHOLDS,
|
|
226
|
+
java: JAVA_THRESHOLDS,
|
|
227
|
+
c: C_THRESHOLDS,
|
|
228
|
+
cpp: CPP_THRESHOLDS,
|
|
229
|
+
rust: RUST_THRESHOLDS,
|
|
230
|
+
csharp: CSHARP_THRESHOLDS,
|
|
231
|
+
lua: LUA_THRESHOLDS,
|
|
232
|
+
php: PHP_THRESHOLDS,
|
|
233
|
+
ruby: RUBY_THRESHOLDS,
|
|
234
|
+
swift: SWIFT_THRESHOLDS,
|
|
235
|
+
shell: SHELL_THRESHOLDS,
|
|
236
|
+
};
|
|
237
|
+
/**
|
|
238
|
+
* Get thresholds for a specific language and metric
|
|
239
|
+
*/
|
|
240
|
+
export function getThresholds(language, metric) {
|
|
241
|
+
if (language === 'unknown') {
|
|
242
|
+
// Fallback to JavaScript thresholds for unknown languages
|
|
243
|
+
return JAVASCRIPT_THRESHOLDS[metric];
|
|
244
|
+
}
|
|
245
|
+
return LANGUAGE_THRESHOLDS[language][metric];
|
|
246
|
+
}
|
|
247
|
+
//# sourceMappingURL=language-thresholds.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"language-thresholds.js","sourceRoot":"","sources":["../../../src/metrics/thresholds/language-thresholds.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAoBH;;;;;;;GAOG;AACH,MAAM,aAAa,GAAuB;IACxC,oBAAoB,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;IAC1E,mBAAmB,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;IACzE,cAAc,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE;IACxE,UAAU,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE;IACvE,cAAc,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;IAClE,YAAY,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE;CAChE,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,q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AC3B,QAAkB,EAClB,MAAgC;IAEhC,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,0DAA0D;QAC1D,OAAO,qBAAqB,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,mBAAmB,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC;AAC/C,CAAC"}
|
package/dist/parser/index.d.ts
CHANGED
|
@@ -2,11 +2,7 @@
|
|
|
2
2
|
* Parser factory
|
|
3
3
|
*/
|
|
4
4
|
import { type Parser, type Language } from './types.js';
|
|
5
|
-
|
|
6
|
-
* Create a parser for the specified language.
|
|
7
|
-
* Attempts tree-sitter AST parsing first, falls back to regex-based parsing on failure.
|
|
8
|
-
*/
|
|
9
|
-
export declare function createParser(language: Language): Parser;
|
|
5
|
+
export declare function createParser(language: Language): Promise<Parser>;
|
|
10
6
|
/**
|
|
11
7
|
* Get all supported languages
|
|
12
8
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parser/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,EAA0B,KAAK,MAAM,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parser/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,EAA0B,KAAK,MAAM,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAQhF,wBAAgB,YAAY,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CA8ChE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,QAAQ,EAAE,CAElD;AAED;;GAEG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,CAIlD;AAED,OAAO,EAAE,sBAAsB,EAAE,KAAK,MAAM,EAAE,KAAK,WAAW,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC"}
|