eff-u-code 2.0.0 → 2.1.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 +30 -4
- package/dist/analyzer/concurrent-analyzer.d.ts.map +1 -1
- package/dist/analyzer/concurrent-analyzer.js +4 -3
- package/dist/analyzer/concurrent-analyzer.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/config/index.d.ts.map +1 -1
- package/dist/config/index.js +2 -0
- package/dist/config/index.js.map +1 -1
- package/dist/i18n/locales/en.json +30 -1
- package/dist/i18n/locales/ru.json +30 -1
- package/dist/i18n/locales/zh.json +32 -3
- package/dist/mcp/server.js +2 -1
- 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 +19 -27
- 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 +19 -34
- 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 +19 -25
- 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/tree-sitter-parser.d.ts.map +1 -1
- package/dist/parser/tree-sitter-parser.js +128 -0
- 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/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
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
"report_metrics_details": "评分指标详情",
|
|
20
20
|
"report_worst_files": "最屎代码排行榜",
|
|
21
21
|
"report_conclusion": "诊断结论",
|
|
22
|
-
"report_file_score": "
|
|
22
|
+
"report_file_score": "糟糕指数: {score}",
|
|
23
23
|
"report_more_issues": "...还有 {count} 个问题实在太屎,列不完了",
|
|
24
24
|
"report_score_calc": "评分计算",
|
|
25
25
|
"report_no_issues": "恭喜!没有特别多问题的文件!",
|
|
26
|
-
"overallScore": "
|
|
26
|
+
"overallScore": "糟糕指数",
|
|
27
27
|
"worstFiles": "最屎代码排行榜",
|
|
28
28
|
"metricsSummary": "指标摘要",
|
|
29
29
|
"file": "文件",
|
|
@@ -316,5 +316,34 @@
|
|
|
316
316
|
"mcp_config_updated": "MCP Server 配置已更新至 {path}",
|
|
317
317
|
"mcp_unknown_target": "未知目标:{target}。支持:claude, cursor",
|
|
318
318
|
"mcp_install_example_claude": "配置到 Claude Code",
|
|
319
|
-
"mcp_install_example_cursor": "配置到 Cursor"
|
|
319
|
+
"mcp_install_example_cursor": "配置到 Cursor",
|
|
320
|
+
"cmd_uninstall_description": "从本地系统移除 fuck-u-code",
|
|
321
|
+
"uninstall_example": "清理所有本地文件",
|
|
322
|
+
"uninstall_warning": "⚠️ 这将从您的系统中移除 fuck-u-code",
|
|
323
|
+
"uninstall_items": "以下内容将被删除:",
|
|
324
|
+
"uninstall_item_config": "全局配置文件 (~/.fuckucoderc.json)",
|
|
325
|
+
"uninstall_item_mcp": "MCP 服务器配置 (Claude Code, Cursor)",
|
|
326
|
+
"uninstall_item_npm": "全局 npm 包 (eff-u-code)",
|
|
327
|
+
"uninstall_confirm": "确定要继续吗?",
|
|
328
|
+
"uninstall_cancelled": "已取消卸载",
|
|
329
|
+
"uninstall_processing": "正在移除 fuck-u-code...",
|
|
330
|
+
"uninstall_removed_config": "已删除全局配置文件",
|
|
331
|
+
"uninstall_no_config": "未找到全局配置文件",
|
|
332
|
+
"uninstall_removed_claude": "已从 Claude Code 移除 MCP 配置",
|
|
333
|
+
"uninstall_no_claude": "Claude Code 中无 MCP 配置",
|
|
334
|
+
"uninstall_removed_cursor": "已从 Cursor 移除 MCP 配置",
|
|
335
|
+
"uninstall_no_cursor": "Cursor 中无 MCP 配置",
|
|
336
|
+
"uninstall_removed_npm": "已卸载全局 npm 包",
|
|
337
|
+
"uninstall_no_npm": "未找到全局 npm 包",
|
|
338
|
+
"uninstall_complete": "✓ 卸载完成。再见!",
|
|
339
|
+
"cmd_update_description": "更新 eff-u-code 到最新版本",
|
|
340
|
+
"cmd_update_example": "更新到最新版本",
|
|
341
|
+
"update_checking": "正在检查更新...",
|
|
342
|
+
"update_current_version": "当前版本",
|
|
343
|
+
"update_latest_version": "最新版本",
|
|
344
|
+
"update_already_latest": "已经是最新版本",
|
|
345
|
+
"update_updating": "正在更新 eff-u-code...",
|
|
346
|
+
"update_success": "更新成功!",
|
|
347
|
+
"update_updated_to": "已更新到版本",
|
|
348
|
+
"update_failed": "更新失败"
|
|
320
349
|
}
|
package/dist/mcp/server.js
CHANGED
|
@@ -15,9 +15,10 @@ import { createAIManager } from '../ai/index.js';
|
|
|
15
15
|
import { MarkdownOutput } from '../cli/output/markdown.js';
|
|
16
16
|
import { JsonOutput } from '../cli/output/json.js';
|
|
17
17
|
import { setLocale } from '../i18n/index.js';
|
|
18
|
+
import { VERSION } from '../version.js';
|
|
18
19
|
const server = new McpServer({
|
|
19
20
|
name: 'fuck-u-code',
|
|
20
|
-
version:
|
|
21
|
+
version: VERSION,
|
|
21
22
|
});
|
|
22
23
|
/**
|
|
23
24
|
* Build a RuntimeConfig from MCP tool parameters.
|
package/dist/mcp/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,oBAAoB,C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AAM,GAAG,MAAM,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAChD,WAAW,CAAC,IAAI,CACd,MAAM,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,QAAQ,gBAAgB,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,aAAa,MAAM,EAAE,CACnF,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,GAAG,uBAAuB,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC;IACtE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;AACxD,CAAC,CACF,CAAC;AAEF,KAAK,UAAU,IAAI;IACjB,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IAC9B,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAC;IACpD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -7,19 +7,17 @@
|
|
|
7
7
|
* - Breaks in linear flow (continue, break, goto)
|
|
8
8
|
* - Recursion
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* - 9-15: Moderate cognitive load
|
|
13
|
-
* - 16-25: High cognitive load
|
|
14
|
-
* - 25+: Very high cognitive load
|
|
10
|
+
* Language-specific thresholds based on official linter defaults.
|
|
11
|
+
* See src/metrics/thresholds/language-thresholds.ts for sources.
|
|
15
12
|
*/
|
|
16
13
|
import type { Metric, MetricResult, MetricCategory } from '../types.js';
|
|
17
|
-
import type { ParseResult } from '../../parser/types.js';
|
|
14
|
+
import type { ParseResult, Language } from '../../parser/types.js';
|
|
18
15
|
export declare class CognitiveComplexityMetric implements Metric {
|
|
19
16
|
readonly name = "cognitive_complexity";
|
|
20
17
|
readonly category: MetricCategory;
|
|
21
18
|
readonly weight: number;
|
|
22
|
-
|
|
19
|
+
private readonly language;
|
|
20
|
+
constructor(weight: number, language: Language);
|
|
23
21
|
calculate(parseResult: ParseResult): MetricResult;
|
|
24
22
|
}
|
|
25
23
|
//# sourceMappingURL=cognitive.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cognitive.d.ts","sourceRoot":"","sources":["../../../src/metrics/complexity/cognitive.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"cognitive.d.ts","sourceRoot":"","sources":["../../../src/metrics/complexity/cognitive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;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,yBAA0B,YAAW,MAAM;IACtD,QAAQ,CAAC,IAAI,0BAA0B;IACvC,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAgB;IACjD,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;CA4ElD"}
|
|
@@ -7,28 +7,23 @@
|
|
|
7
7
|
* - Breaks in linear flow (continue, break, goto)
|
|
8
8
|
* - Recursion
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* - 9-15: Moderate cognitive load
|
|
13
|
-
* - 16-25: High cognitive load
|
|
14
|
-
* - 25+: Very high cognitive load
|
|
10
|
+
* Language-specific thresholds based on official linter defaults.
|
|
11
|
+
* See src/metrics/thresholds/language-thresholds.ts for sources.
|
|
15
12
|
*/
|
|
16
13
|
import { t } from '../../i18n/index.js';
|
|
17
|
-
|
|
18
|
-
EXCELLENT: 8,
|
|
19
|
-
GOOD: 15,
|
|
20
|
-
ACCEPTABLE: 25,
|
|
21
|
-
POOR: 40,
|
|
22
|
-
};
|
|
14
|
+
import { getThresholds } from '../thresholds/language-thresholds.js';
|
|
23
15
|
export class CognitiveComplexityMetric {
|
|
24
16
|
name = 'cognitive_complexity';
|
|
25
17
|
category = 'complexity';
|
|
26
18
|
weight;
|
|
27
|
-
|
|
19
|
+
language;
|
|
20
|
+
constructor(weight, language) {
|
|
28
21
|
this.weight = weight;
|
|
22
|
+
this.language = language;
|
|
29
23
|
}
|
|
30
24
|
calculate(parseResult) {
|
|
31
25
|
const { functions, filePath } = parseResult;
|
|
26
|
+
const thresholds = getThresholds(this.language, 'cognitiveComplexity');
|
|
32
27
|
if (functions.length === 0) {
|
|
33
28
|
return {
|
|
34
29
|
name: this.name,
|
|
@@ -39,8 +34,6 @@ export class CognitiveComplexityMetric {
|
|
|
39
34
|
details: t('detail_no_functions'),
|
|
40
35
|
};
|
|
41
36
|
}
|
|
42
|
-
// Calculate cognitive complexity for each function
|
|
43
|
-
// Cognitive = base complexity + nesting penalty (nesting depth * 2)
|
|
44
37
|
let totalCognitive = 0;
|
|
45
38
|
let maxCognitive = 0;
|
|
46
39
|
const locations = [];
|
|
@@ -50,7 +43,7 @@ export class CognitiveComplexityMetric {
|
|
|
50
43
|
if (cognitive > maxCognitive) {
|
|
51
44
|
maxCognitive = cognitive;
|
|
52
45
|
}
|
|
53
|
-
if (cognitive >
|
|
46
|
+
if (cognitive > thresholds.good) {
|
|
54
47
|
locations.push({
|
|
55
48
|
filePath,
|
|
56
49
|
line: func.startLine,
|
|
@@ -60,36 +53,35 @@ export class CognitiveComplexityMetric {
|
|
|
60
53
|
}
|
|
61
54
|
}
|
|
62
55
|
const avgCognitive = totalCognitive / functions.length;
|
|
63
|
-
// Non-linear scoring curve
|
|
64
56
|
let normalizedScore;
|
|
65
|
-
if (avgCognitive <=
|
|
57
|
+
if (avgCognitive <= thresholds.excellent) {
|
|
66
58
|
normalizedScore = 100;
|
|
67
59
|
}
|
|
68
|
-
else if (avgCognitive <=
|
|
60
|
+
else if (avgCognitive <= thresholds.good) {
|
|
69
61
|
normalizedScore =
|
|
70
62
|
100 -
|
|
71
|
-
((avgCognitive -
|
|
63
|
+
((avgCognitive - thresholds.excellent) / (thresholds.good - thresholds.excellent)) * 20;
|
|
72
64
|
}
|
|
73
|
-
else if (avgCognitive <=
|
|
65
|
+
else if (avgCognitive <= thresholds.acceptable) {
|
|
74
66
|
normalizedScore =
|
|
75
|
-
80 - ((avgCognitive -
|
|
67
|
+
80 - ((avgCognitive - thresholds.good) / (thresholds.acceptable - thresholds.good)) * 35;
|
|
76
68
|
}
|
|
77
|
-
else if (avgCognitive <=
|
|
69
|
+
else if (avgCognitive <= thresholds.poor) {
|
|
78
70
|
normalizedScore =
|
|
79
71
|
45 -
|
|
80
|
-
((avgCognitive -
|
|
72
|
+
((avgCognitive - thresholds.acceptable) / (thresholds.poor - thresholds.acceptable)) * 30;
|
|
81
73
|
}
|
|
82
74
|
else {
|
|
83
|
-
normalizedScore = Math.max(0, 15 * Math.exp(-(avgCognitive -
|
|
75
|
+
normalizedScore = Math.max(0, 15 * Math.exp(-(avgCognitive - thresholds.poor) / 15));
|
|
84
76
|
}
|
|
85
77
|
let severity;
|
|
86
|
-
if (maxCognitive <=
|
|
78
|
+
if (maxCognitive <= thresholds.good) {
|
|
87
79
|
severity = 'info';
|
|
88
80
|
}
|
|
89
|
-
else if (maxCognitive <=
|
|
81
|
+
else if (maxCognitive <= thresholds.acceptable) {
|
|
90
82
|
severity = 'warning';
|
|
91
83
|
}
|
|
92
|
-
else if (maxCognitive <=
|
|
84
|
+
else if (maxCognitive <= thresholds.poor) {
|
|
93
85
|
severity = 'error';
|
|
94
86
|
}
|
|
95
87
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cognitive.js","sourceRoot":"","sources":["../../../src/metrics/complexity/cognitive.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"cognitive.js","sourceRoot":"","sources":["../../../src/metrics/complexity/cognitive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,EAAE,CAAC,EAAE,MAAM,qBAAqB,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAErE,MAAM,OAAO,yBAAyB;IAC3B,IAAI,GAAG,sBAAsB,CAAC;IAC9B,QAAQ,GAAmB,YAAY,CAAC;IACxC,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;QAC5C,MAAM,UAAU,GAAG,aAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,qBAAqB,CAAC,CAAC;QAEvE,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC3B,OAAO;gBACL,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,KAAK,EAAE,CAAC;gBACR,eAAe,EAAE,GAAG;gBACpB,QAAQ,EAAE,MAAM;gBAChB,OAAO,EAAE,CAAC,CAAC,qBAAqB,CAAC;aAClC,CAAC;QACJ,CAAC;QAED,IAAI,cAAc,GAAG,CAAC,CAAC;QACvB,IAAI,YAAY,GAAG,CAAC,CAAC;QACrB,MAAM,SAAS,GAAqB,EAAE,CAAC;QAEvC,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE,CAAC;YAC7B,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,GAAG,IA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*
|
|
6
|
-
* - 11-20: Moderate complexity, consider refactoring
|
|
7
|
-
* - 21-50: High complexity, should be refactored
|
|
8
|
-
* - 50+: Very high complexity, must 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
|
* Formula: CC = 1 + (if) + (loops) + (case) + (catch) + (&&/||) + (ternary)
|
|
11
8
|
*/
|
|
12
9
|
import type { Metric, MetricResult, MetricCategory } from '../types.js';
|
|
13
|
-
import type { ParseResult } from '../../parser/types.js';
|
|
10
|
+
import type { ParseResult, Language } from '../../parser/types.js';
|
|
14
11
|
export declare class CyclomaticComplexityMetric implements Metric {
|
|
15
12
|
readonly name = "cyclomatic_complexity";
|
|
16
13
|
readonly category: MetricCategory;
|
|
17
14
|
readonly weight: number;
|
|
18
|
-
|
|
15
|
+
private readonly language;
|
|
16
|
+
constructor(weight: number, language: Language);
|
|
19
17
|
calculate(parseResult: ParseResult): MetricResult;
|
|
20
18
|
}
|
|
21
19
|
//# sourceMappingURL=cyclomatic.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cyclomatic.d.ts","sourceRoot":"","sources":["../../../src/metrics/complexity/cyclomatic.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"cyclomatic.d.ts","sourceRoot":"","sources":["../../../src/metrics/complexity/cyclomatic.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;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,0BAA2B,YAAW,MAAM;IACvD,QAAQ,CAAC,IAAI,2BAA2B;IACxC,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAgB;IACjD,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;CA2ElD"}
|
|
@@ -1,31 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Cyclomatic complexity metric
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* - 11-20: Moderate complexity, consider refactoring
|
|
7
|
-
* - 21-50: High complexity, should be refactored
|
|
8
|
-
* - 50+: Very high complexity, must 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
|
* Formula: CC = 1 + (if) + (loops) + (case) + (catch) + (&&/||) + (ternary)
|
|
11
8
|
*/
|
|
12
9
|
import { t } from '../../i18n/index.js';
|
|
13
|
-
|
|
14
|
-
const THRESHOLDS = {
|
|
15
|
-
EXCELLENT: 5,
|
|
16
|
-
GOOD: 10,
|
|
17
|
-
ACCEPTABLE: 20,
|
|
18
|
-
POOR: 30,
|
|
19
|
-
};
|
|
10
|
+
import { getThresholds } from '../thresholds/language-thresholds.js';
|
|
20
11
|
export class CyclomaticComplexityMetric {
|
|
21
12
|
name = 'cyclomatic_complexity';
|
|
22
13
|
category = 'complexity';
|
|
23
14
|
weight;
|
|
24
|
-
|
|
15
|
+
language;
|
|
16
|
+
constructor(weight, language) {
|
|
25
17
|
this.weight = weight;
|
|
18
|
+
this.language = language;
|
|
26
19
|
}
|
|
27
20
|
calculate(parseResult) {
|
|
28
21
|
const { functions, filePath } = parseResult;
|
|
22
|
+
const thresholds = getThresholds(this.language, 'cyclomaticComplexity');
|
|
29
23
|
if (functions.length === 0) {
|
|
30
24
|
return {
|
|
31
25
|
name: this.name,
|
|
@@ -36,7 +30,6 @@ export class CyclomaticComplexityMetric {
|
|
|
36
30
|
details: t('detail_no_functions'),
|
|
37
31
|
};
|
|
38
32
|
}
|
|
39
|
-
// Calculate complexity statistics
|
|
40
33
|
let totalComplexity = 0;
|
|
41
34
|
let maxComplexity = 0;
|
|
42
35
|
const locations = [];
|
|
@@ -45,8 +38,7 @@ export class CyclomaticComplexityMetric {
|
|
|
45
38
|
if (func.complexity > maxComplexity) {
|
|
46
39
|
maxComplexity = func.complexity;
|
|
47
40
|
}
|
|
48
|
-
|
|
49
|
-
if (func.complexity > THRESHOLDS.GOOD) {
|
|
41
|
+
if (func.complexity > thresholds.good) {
|
|
50
42
|
locations.push({
|
|
51
43
|
filePath,
|
|
52
44
|
line: func.startLine,
|
|
@@ -56,42 +48,35 @@ export class CyclomaticComplexityMetric {
|
|
|
56
48
|
}
|
|
57
49
|
}
|
|
58
50
|
const avgComplexity = totalComplexity / functions.length;
|
|
59
|
-
// Calculate normalized score using non-linear curve
|
|
60
|
-
// Score decreases more rapidly as complexity increases
|
|
61
51
|
let normalizedScore;
|
|
62
|
-
if (avgComplexity <=
|
|
52
|
+
if (avgComplexity <= thresholds.excellent) {
|
|
63
53
|
normalizedScore = 100;
|
|
64
54
|
}
|
|
65
|
-
else if (avgComplexity <=
|
|
66
|
-
// Linear decrease from 100 to 80
|
|
55
|
+
else if (avgComplexity <= thresholds.good) {
|
|
67
56
|
normalizedScore =
|
|
68
57
|
100 -
|
|
69
|
-
((avgComplexity -
|
|
58
|
+
((avgComplexity - thresholds.excellent) / (thresholds.good - thresholds.excellent)) * 20;
|
|
70
59
|
}
|
|
71
|
-
else if (avgComplexity <=
|
|
72
|
-
// Steeper decrease from 80 to 50
|
|
60
|
+
else if (avgComplexity <= thresholds.acceptable) {
|
|
73
61
|
normalizedScore =
|
|
74
|
-
80 - ((avgComplexity -
|
|
62
|
+
80 - ((avgComplexity - thresholds.good) / (thresholds.acceptable - thresholds.good)) * 30;
|
|
75
63
|
}
|
|
76
|
-
else if (avgComplexity <=
|
|
77
|
-
// Even steeper decrease from 50 to 20
|
|
64
|
+
else if (avgComplexity <= thresholds.poor) {
|
|
78
65
|
normalizedScore =
|
|
79
66
|
50 -
|
|
80
|
-
((avgComplexity -
|
|
67
|
+
((avgComplexity - thresholds.acceptable) / (thresholds.poor - thresholds.acceptable)) * 30;
|
|
81
68
|
}
|
|
82
69
|
else {
|
|
83
|
-
|
|
84
|
-
normalizedScore = Math.max(0, 20 * Math.exp(-(avgComplexity - THRESHOLDS.POOR) / 20));
|
|
70
|
+
normalizedScore = Math.max(0, 20 * Math.exp(-(avgComplexity - thresholds.poor) / 20));
|
|
85
71
|
}
|
|
86
|
-
// Determine severity based on max complexity (worst case matters)
|
|
87
72
|
let severity;
|
|
88
|
-
if (maxComplexity <=
|
|
73
|
+
if (maxComplexity <= thresholds.good) {
|
|
89
74
|
severity = 'info';
|
|
90
75
|
}
|
|
91
|
-
else if (maxComplexity <=
|
|
76
|
+
else if (maxComplexity <= thresholds.acceptable) {
|
|
92
77
|
severity = 'warning';
|
|
93
78
|
}
|
|
94
|
-
else if (maxComplexity <=
|
|
79
|
+
else if (maxComplexity <= thresholds.poor) {
|
|
95
80
|
severity = 'error';
|
|
96
81
|
}
|
|
97
82
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cyclomatic.js","sourceRoot":"","sources":["../../../src/metrics/complexity/cyclomatic.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"cyclomatic.js","sourceRoot":"","sources":["../../../src/metrics/complexity/cyclomatic.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAAE,CAAC,EAAE,MAAM,qBAAqB,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAErE,MAAM,OAAO,0BAA0B;IAC5B,IAAI,GAAG,uBAAuB,CAAC;IAC/B,QAAQ,GAAmB,YAAY,CAAC;IACxC,MAAM,CAAS;IACP,QAAQ,CAAW;IAEpC,YAAY,MAAc,EAAE,QAAkB;QAC5C,IAAI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AAI,UAAU,CAAC,IAAI,EAAE,CAAC;YAC5C,QAAQ,GAAG,OAAO,CAAC;QACrB,CAAC;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,aAAa;YACpB,eAAe,EAAE,IAAI,CAAC,KAAK,CAAC,eAAe,GAAG,EAAE,CAAC,GAAG,EAAE;YACtD,QAAQ;YACR,OAAO,EAAE,CAAC,CAAC,gBAAgB,EAAE,EAAE,GAAG,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC;YAC3F,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
|
* Nesting depth metric
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* - 4-5: Good, acceptable
|
|
7
|
-
* - 6-7: Moderate, consider refactoring
|
|
8
|
-
* - 8+: Poor, must 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 NestingDepthMetric implements Metric {
|
|
13
10
|
readonly name = "nesting_depth";
|
|
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=nesting-depth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nesting-depth.d.ts","sourceRoot":"","sources":["../../../src/metrics/complexity/nesting-depth.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"nesting-depth.d.ts","sourceRoot":"","sources":["../../../src/metrics/complexity/nesting-depth.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,kBAAmB,YAAW,MAAM;IAC/C,QAAQ,CAAC,IAAI,mBAAmB;IAChC,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAgB;IACjD,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
|
* Nesting depth metric
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* - 4-5: Good, acceptable
|
|
7
|
-
* - 6-7: Moderate, consider refactoring
|
|
8
|
-
* - 8+: Poor, must 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 NestingDepthMetric {
|
|
18
10
|
name = 'nesting_depth';
|
|
19
11
|
category = 'complexity';
|
|
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, 'nestingDepth');
|
|
26
21
|
if (functions.length === 0) {
|
|
27
22
|
return {
|
|
28
23
|
name: this.name,
|
|
@@ -41,7 +36,7 @@ export class NestingDepthMetric {
|
|
|
41
36
|
if (func.nestingDepth > maxDepth) {
|
|
42
37
|
maxDepth = func.nestingDepth;
|
|
43
38
|
}
|
|
44
|
-
if (func.nestingDepth >
|
|
39
|
+
if (func.nestingDepth > thresholds.excellent) {
|
|
45
40
|
locations.push({
|
|
46
41
|
filePath,
|
|
47
42
|
line: func.startLine,
|
|
@@ -52,32 +47,32 @@ export class NestingDepthMetric {
|
|
|
52
47
|
}
|
|
53
48
|
const avgDepth = totalDepth / functions.length;
|
|
54
49
|
let normalizedScore;
|
|
55
|
-
if (maxDepth <=
|
|
50
|
+
if (maxDepth <= thresholds.excellent) {
|
|
56
51
|
normalizedScore = 100;
|
|
57
52
|
}
|
|
58
|
-
else if (maxDepth <=
|
|
53
|
+
else if (maxDepth <= thresholds.good) {
|
|
59
54
|
normalizedScore =
|
|
60
|
-
100 - ((maxDepth -
|
|
55
|
+
100 - ((maxDepth - thresholds.excellent) / (thresholds.good - thresholds.excellent)) * 20;
|
|
61
56
|
}
|
|
62
|
-
else if (maxDepth <=
|
|
57
|
+
else if (maxDepth <= thresholds.acceptable) {
|
|
63
58
|
normalizedScore =
|
|
64
|
-
80 - ((maxDepth -
|
|
59
|
+
80 - ((maxDepth - thresholds.good) / (thresholds.acceptable - thresholds.good)) * 35;
|
|
65
60
|
}
|
|
66
|
-
else if (maxDepth <=
|
|
61
|
+
else if (maxDepth <= thresholds.poor) {
|
|
67
62
|
normalizedScore =
|
|
68
|
-
45 - ((maxDepth -
|
|
63
|
+
45 - ((maxDepth - thresholds.acceptable) / (thresholds.poor - thresholds.acceptable)) * 30;
|
|
69
64
|
}
|
|
70
65
|
else {
|
|
71
|
-
normalizedScore = Math.max(0, 15 * Math.exp(-(maxDepth -
|
|
66
|
+
normalizedScore = Math.max(0, 15 * Math.exp(-(maxDepth - thresholds.poor) / 3));
|
|
72
67
|
}
|
|
73
68
|
let severity;
|
|
74
|
-
if (maxDepth <=
|
|
69
|
+
if (maxDepth <= thresholds.excellent) {
|
|
75
70
|
severity = 'info';
|
|
76
71
|
}
|
|
77
|
-
else if (maxDepth <=
|
|
72
|
+
else if (maxDepth <= thresholds.good) {
|
|
78
73
|
severity = 'warning';
|
|
79
74
|
}
|
|
80
|
-
else if (maxDepth <=
|
|
75
|
+
else if (maxDepth <= thresholds.acceptable) {
|
|
81
76
|
severity = 'error';
|
|
82
77
|
}
|
|
83
78
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nesting-depth.js","sourceRoot":"","sources":["../../../src/metrics/complexity/nesting-depth.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"nesting-depth.js","sourceRoot":"","sources":["../../../src/metrics/complexity/nesting-depth.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,CAAC,EAAE,MAAM,qBAAqB,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAErE,MAAM,OAAO,kBAAkB;IACpB,IAAI,GAAG,eAAe,CAAC;IACvB,QAAQ,GAAmB,YAAY,CAAC;IACxC,MAAM,CAAS;IACP,QAAQ,CAAW;IAEpC,YAAY,MAAc,EAAE,QAAkB;QAC5C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,I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AU,EAAE,CAAC;YAC7C,QAAQ,GAAG,OAAO,CAAC;QACrB,CAAC;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,QAAQ;YACf,eAAe,EAAE,IAAI,CAAC,KAAK,CAAC,eAAe,GAAG,EAAE,CAAC,GAAG,EAAE;YACtD,QAAQ;YACR,OAAO,EAAE,CAAC,CAAC,gBAAgB,EAAE,EAAE,GAAG,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YACjF,SAAS,EAAE,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;SACxD,CAAC;IACJ,CAAC;CACF"}
|
package/dist/metrics/index.d.ts
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { Metric } from './types.js';
|
|
5
5
|
import type { RuntimeConfig } from '../config/schema.js';
|
|
6
|
+
import type { Language } from '../parser/types.js';
|
|
6
7
|
/**
|
|
7
|
-
* Create all metrics with configured weights
|
|
8
|
+
* Create all metrics with configured weights and language-specific thresholds
|
|
8
9
|
*
|
|
9
10
|
* Weight distribution based on industry standards (SonarQube, CodeClimate, NASA, Microsoft):
|
|
10
11
|
* - Complexity: 32% (3 metrics, each gets 32%/3 = 10.67%)
|
|
@@ -16,6 +17,6 @@ import type { RuntimeConfig } from '../config/schema.js';
|
|
|
16
17
|
* - Naming: 5% (1 metric)
|
|
17
18
|
* Total: 100%
|
|
18
19
|
*/
|
|
19
|
-
export declare function createMetrics(config: RuntimeConfig): Metric[];
|
|
20
|
+
export declare function createMetrics(config: RuntimeConfig, language: Language): Metric[];
|
|
20
21
|
export type { Metric, MetricResult, MetricCategory, Severity } from './types.js';
|
|
21
22
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/metrics/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAaH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/metrics/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAaH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,GAAG,MAAM,EAAE,CAwBjF;AAED,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/metrics/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import { CodeDuplicationMetric } from './duplication/code-duplication.js';
|
|
|
13
13
|
import { ErrorHandlingMetric } from './error/error-handling.js';
|
|
14
14
|
import { StructureAnalysisMetric } from './structure/structure-analysis.js';
|
|
15
15
|
/**
|
|
16
|
-
* Create all metrics with configured weights
|
|
16
|
+
* Create all metrics with configured weights and language-specific thresholds
|
|
17
17
|
*
|
|
18
18
|
* Weight distribution based on industry standards (SonarQube, CodeClimate, NASA, Microsoft):
|
|
19
19
|
* - Complexity: 32% (3 metrics, each gets 32%/3 = 10.67%)
|
|
@@ -25,7 +25,7 @@ import { StructureAnalysisMetric } from './structure/structure-analysis.js';
|
|
|
25
25
|
* - Naming: 5% (1 metric)
|
|
26
26
|
* Total: 100%
|
|
27
27
|
*/
|
|
28
|
-
export function createMetrics(config) {
|
|
28
|
+
export function createMetrics(config, language) {
|
|
29
29
|
const weights = config.metrics.weights;
|
|
30
30
|
const complexityWeight = weights.complexity;
|
|
31
31
|
const complexityMetricsCount = 3;
|
|
@@ -34,12 +34,12 @@ export function createMetrics(config) {
|
|
|
34
34
|
const sizeMetricsCount = 3;
|
|
35
35
|
const sizePerMetric = sizeWeight / sizeMetricsCount;
|
|
36
36
|
return [
|
|
37
|
-
new CyclomaticComplexityMetric(complexityPerMetric),
|
|
38
|
-
new CognitiveComplexityMetric(complexityPerMetric),
|
|
39
|
-
new NestingDepthMetric(complexityPerMetric),
|
|
40
|
-
new FunctionLengthMetric(sizePerMetric),
|
|
41
|
-
new FileLengthMetric(sizePerMetric),
|
|
42
|
-
new ParameterCountMetric(sizePerMetric),
|
|
37
|
+
new CyclomaticComplexityMetric(complexityPerMetric, language),
|
|
38
|
+
new CognitiveComplexityMetric(complexityPerMetric, language),
|
|
39
|
+
new NestingDepthMetric(complexityPerMetric, language),
|
|
40
|
+
new FunctionLengthMetric(sizePerMetric, language),
|
|
41
|
+
new FileLengthMetric(sizePerMetric, language),
|
|
42
|
+
new ParameterCountMetric(sizePerMetric, language),
|
|
43
43
|
new CodeDuplicationMetric(weights.duplication),
|
|
44
44
|
new StructureAnalysisMetric(weights.structure),
|
|
45
45
|
new ErrorHandlingMetric(weights.error),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/metrics/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,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;IACjC,MAAM,mBAAmB,GAAG,gBAAgB,GAAG,sBAAsB,CAAC;IAEtE,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAChC,MAAM,gBAAgB,GAAG,CAAC,CAAC;IAC3B,MAAM,aAAa,GAAG,UAAU,GAAG,gBAAgB,CAAC;IAEpD,OAAO;QACL,IAAI,0BAA0B,CAAC,mBAAmB,EAAE,QAAQ,CAAC;QAC7D,IAAI,yBAAyB,CAAC,mBAAmB,EAAE,QAAQ,CAAC;QAC5D,IAAI,kBAAkB,CAAC,mBAAmB,EAAE,QAAQ,CAAC;QACrD,IAAI,oBAAoB,CAAC,aAAa,EAAE,QAAQ,CAAC;QACjD,IAAI,gBAAgB,CAAC,aAAa,EAAE,QAAQ,CAAC;QAC7C,IAAI,oBAAoB,CAAC,aAAa,EAAE,QAAQ,CAAC;QACjD,IAAI,qBAAqB,CAAC,OAAO,CAAC,WAAW,CAAC;QAC9C,IAAI,uBAAuB,CAAC,OAAO,CAAC,SAAS,CAAC;QAC9C,IAAI,mBAAmB,CAAC,OAAO,CAAC,KAAK,CAAC;QACtC,IAAI,kBAAkB,CAAC,OAAO,CAAC,aAAa,CAAC;QAC7C,IAAI,sBAAsB,CAAC,OAAO,CAAC,MAAM,CAAC;KAC3C,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convention.d.ts","sourceRoot":"","sources":["../../../src/metrics/naming/convention.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,cAAc,EAA4B,MAAM,aAAa,CAAC;AAClG,OAAO,KAAK,EAAE,WAAW,EAAY,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"convention.d.ts","sourceRoot":"","sources":["../../../src/metrics/naming/convention.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,cAAc,EAA4B,MAAM,aAAa,CAAC;AAClG,OAAO,KAAK,EAAE,WAAW,EAAY,MAAM,uBAAuB,CAAC;AA8BnE,qBAAa,sBAAuB,YAAW,MAAM;IACnD,QAAQ,CAAC,IAAI,uBAAuB;IACpC,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAY;IAC7C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,MAAM,EAAE,MAAM;IAI1B,SAAS,CAAC,WAAW,EAAE,WAAW,GAAG,YAAY;CA+ElD"}
|