vibecodingmachine-core 2026.2.26-1739 → 2026.3.9-850
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/package.json +1 -1
- package/src/agents/AgentCheckDiscoveryService.js +180 -0
- package/src/agents/AgentCheckService.js +18 -261
- package/src/agents/AgentCheckStatisticsService.js +195 -0
- package/src/agents/EnvironmentConfigurationManager.js +31 -380
- package/src/agents/InstallationType.js +19 -6
- package/src/agents/SimpleAgentCheckService.js +472 -0
- package/src/agents/config-managers/ConfigUtils.js +72 -0
- package/src/agents/config-managers/DefaultConfig.js +58 -0
- package/src/agents/config-managers/EnvVarLoader.js +66 -0
- package/src/agents/config-managers/FileConfigLoader.js +124 -0
- package/src/agents/config-managers/TypeConverters.js +61 -0
- package/src/agents/config-managers/VariableMappings.js +92 -0
- package/src/agents/discovery/AgentDiscoveryService-refactored.js +272 -0
- package/src/agents/discovery/AgentDiscoveryService.js +29 -403
- package/src/agents/discovery/agent-validator.js +262 -0
- package/src/agents/discovery/discovery-results.js +176 -0
- package/src/agents/discovery/discovery-scanner.js +268 -0
- package/src/agents/discovery/discovery-utils.js +161 -0
- package/src/agents/discovery/executable-analyzer.js +290 -0
- package/src/agents/discovery/history-manager.js +310 -0
- package/src/agents/verification/ResultAnalyzer-refactored.js +341 -0
- package/src/agents/verification/ResultAnalyzer.js +30 -431
- package/src/agents/verification/analysis-utils.js +310 -0
- package/src/agents/verification/batch-analyzer.js +440 -0
- package/src/agents/verification/pattern-recognizer.js +369 -0
- package/src/agents/verification/report-generator.js +320 -0
- package/src/agents/verification/test-analyzer.js +290 -0
- package/src/agents/windows/InstallerFactory.js +4 -0
- package/src/agents/windows/VSCodeExtensionInstaller.js +404 -0
- package/src/analysis/analysis-engine.js +314 -0
- package/src/analysis/ast-analyzer.js +342 -0
- package/src/analysis/boundary-detector-refactored.js +378 -0
- package/src/analysis/boundary-detector.js +200 -603
- package/src/analysis/boundary-scanner.js +609 -0
- package/src/analysis/boundary-types.js +118 -0
- package/src/analysis/boundary-utils.js +293 -0
- package/src/analysis/deadline-priority-calculator.js +18 -0
- package/src/analysis/detection-methods.js +347 -0
- package/src/analysis/importance-priority-calculator.js +18 -0
- package/src/analysis/priority/factor-calculators.js +204 -0
- package/src/analysis/priority/factor-helpers.js +71 -0
- package/src/analysis/priority/priority-constants.js +73 -0
- package/src/analysis/priority/priority-factor-calculators.js +301 -0
- package/src/analysis/priority/reasons-generator.js +44 -0
- package/src/analysis/priority-calculator.js +15 -580
- package/src/analysis/strategy-generator.js +16 -66
- package/src/analysis/type-priority-calculator.js +18 -0
- package/src/analysis/urgency-priority-calculator.js +18 -0
- package/src/auto-mode/AutoModeBusinessLogic.js +2 -40
- package/src/commands/disable-requirement.js +60 -0
- package/src/commands/disable-spec.js +60 -0
- package/src/commands/enable-requirement.js +60 -0
- package/src/commands/enable-spec.js +60 -0
- package/src/commands/registry.js +1 -6
- package/src/commands/requirements.js +8 -2
- package/src/ide-integration/applescript-manager.cjs +9 -24
- package/src/ide-integration/cdp-handlers/chat-reader.js +44 -0
- package/src/ide-integration/cdp-handlers/connection-handler.js +88 -0
- package/src/ide-integration/cdp-handlers/continuation-handler.js +314 -0
- package/src/ide-integration/cdp-handlers/message-submitter.js +75 -0
- package/src/ide-integration/cdp-handlers/text-sender.js +138 -0
- package/src/ide-integration/cdp-manager.js +28 -573
- package/src/ide-integration/claude-code-cli-manager.cjs +48 -12
- package/src/ide-integration/ide-openers/claude-opener.js +171 -0
- package/src/ide-integration/ide-openers/cursor-opener.js +53 -0
- package/src/ide-integration/ide-openers/other-ides-opener.js +230 -0
- package/src/ide-integration/ide-openers/vscode-opener.js +147 -0
- package/src/ide-integration/macos-ide-manager.js +20 -582
- package/src/ide-integration/macos-quota-checker.js +164 -0
- package/src/ide-integration/macos-text-sender.js +19 -38
- package/src/ide-integration/provider-manager.cjs +52 -7
- package/src/index.cjs +6 -0
- package/src/index.js +10 -0
- package/src/llm/direct-llm-manager.cjs +501 -0
- package/src/localization/translations/en-part1.js +363 -0
- package/src/localization/translations/en-part2.js +320 -0
- package/src/localization/translations/en.js +4 -687
- package/src/localization/translations/es-part1.js +363 -0
- package/src/localization/translations/es-part2.js +320 -0
- package/src/localization/translations/es.js +4 -688
- package/src/models/file-analysis-collection.js +139 -0
- package/src/models/file-analysis-metrics.js +50 -0
- package/src/models/file-analysis.js +15 -262
- package/src/models/plan-manager.js +410 -0
- package/src/models/refactoring-models.js +380 -0
- package/src/models/refactoring-plan-refactored.js +81 -0
- package/src/models/refactoring-plan.js +2 -663
- package/src/monitoring/alert-system.js +4 -45
- package/src/monitoring/continuous-scan-notifications.js +37 -191
- package/src/monitoring/notification-handlers/base-handler.js +58 -0
- package/src/monitoring/notification-handlers/error-handler.js +36 -0
- package/src/monitoring/notification-handlers/index.js +21 -0
- package/src/monitoring/notification-handlers/new-violation-handler.js +91 -0
- package/src/monitoring/notification-handlers/progress-handler.js +48 -0
- package/src/monitoring/notification-handlers/resolved-violation-handler.js +54 -0
- package/src/monitoring/notification-handlers/threshold-handler.js +36 -0
- package/src/provider-registry.js +8 -0
- package/src/refactoring/boundary/boundary-detector-refactored.js +58 -0
- package/src/refactoring/boundary/boundary-detector.js +26 -596
- package/src/refactoring/boundary/detectors/boundary-analyzers.js +281 -0
- package/src/refactoring/boundary/detectors/boundary-core.js +167 -0
- package/src/refactoring/boundary/detectors/class-detector.js +247 -0
- package/src/refactoring/boundary/detectors/config-detector.js +270 -0
- package/src/refactoring/boundary/detectors/constant-detector.js +269 -0
- package/src/refactoring/boundary/detectors/function-detector.js +248 -0
- package/src/refactoring/boundary/detectors/module-detector.js +249 -0
- package/src/refactoring/boundary/detectors/object-detector.js +247 -0
- package/src/refactoring/boundary/detectors/type-detectors.js +338 -0
- package/src/refactoring/boundary/detectors/utility-detector.js +270 -0
- package/src/refactoring/circular-dependency-resolver-original.js +16 -76
- package/src/refactoring/code-mover-refactored.js +309 -0
- package/src/refactoring/code-mover.js +48 -355
- package/src/refactoring/execution-status.js +18 -0
- package/src/refactoring/execution-strategies.js +172 -0
- package/src/refactoring/file-splitter-core.js +568 -0
- package/src/refactoring/file-splitter-types.js +136 -0
- package/src/refactoring/file-splitter.js +2 -682
- package/src/refactoring/functionality-validator.js +11 -51
- package/src/refactoring/import-manager-refactored.js +385 -0
- package/src/refactoring/import-manager.js +112 -487
- package/src/refactoring/import-models.js +189 -0
- package/src/refactoring/import-parser.js +306 -0
- package/src/refactoring/move-executor.js +431 -0
- package/src/refactoring/move-utils.js +368 -0
- package/src/refactoring/operation-executor.js +76 -0
- package/src/refactoring/plan-creator.js +36 -0
- package/src/refactoring/plan-executor.js +143 -0
- package/src/refactoring/plan-validator.js +68 -0
- package/src/refactoring/refactoring-executor-result.js +70 -0
- package/src/refactoring/refactoring-executor.js +34 -569
- package/src/refactoring/refactoring-operation.js +94 -0
- package/src/refactoring/refactoring-plan.js +69 -0
- package/src/refactoring/refactoring-rollback.js +22 -527
- package/src/refactoring/rollback-handlers/RollbackExecutor.js +107 -0
- package/src/refactoring/rollback-handlers/RollbackManager.js +265 -0
- package/src/refactoring/rollback-handlers/RollbackOperation.js +105 -0
- package/src/refactoring/rollback-handlers/RollbackResult.js +109 -0
- package/src/refactoring/rollback-handlers/RollbackStatistics.js +77 -0
- package/src/refactoring/test-validator.js +32 -448
- package/src/refactoring/validation/baseline-runner.js +71 -0
- package/src/refactoring/validation/report-generator.js +136 -0
- package/src/refactoring/validation/result-comparator.js +92 -0
- package/src/refactoring/validation/test-suite.js +59 -0
- package/src/refactoring/validation/test-validation-result.js +83 -0
- package/src/refactoring/validation/validation-runner.js +95 -0
- package/src/refactoring/validation/validation-status.js +18 -0
- package/src/rui/commands/AgentCommandParser.js +60 -369
- package/src/rui/commands/AgentResponseFormatter.js +7 -47
- package/src/rui/commands/parsers/CommandMapper.js +148 -0
- package/src/rui/commands/parsers/CommandValidator.js +228 -0
- package/src/rui/commands/parsers/ComponentExtractor.js +100 -0
- package/src/rui/commands/parsers/TokenParser.js +69 -0
- package/src/rui/commands/parsers/tokenizer.js +153 -0
- package/src/utils/current-requirement-operations.js +50 -1
- package/src/utils/report-generator.js +18 -514
- package/src/utils/report-generators/analysis-generator.js +115 -0
- package/src/utils/report-generators/base-generator.js +141 -0
- package/src/utils/report-generators/compliance-generator.js +41 -0
- package/src/utils/report-generators/format-handlers.js +185 -0
- package/src/utils/report-generators/refactoring-generator.js +46 -0
- package/src/utils/report-generators/validation-generator.js +63 -0
- package/src/utils/requirement-enable-disable.js +265 -0
- package/src/utils/requirement-helpers/requirement-file-ops.js +69 -1
- package/src/utils/requirement-helpers/requirement-mover.js +88 -1
- package/src/utils/requirement-helpers.js +5 -2
- package/src/utils/smoke-test-cli.js +45 -8
- package/src/utils/specification-enable-disable.js +122 -0
- package/src/utils/specification-helpers.js +30 -4
- package/src/utils/specification-migration.js +5 -5
- package/src/utils/test-comparator.js +118 -0
- package/src/utils/test-config.js +54 -0
- package/src/utils/test-executor.js +133 -0
- package/src/utils/test-parser.js +215 -0
- package/src/utils/test-runner-baseline.js +63 -0
- package/src/utils/test-runner-core.js +98 -0
- package/src/utils/test-runner-report.js +39 -0
- package/src/utils/test-runner-validation.js +71 -0
- package/src/utils/test-runner.js +11 -535
- package/src/validation/comparison-analyzer.js +333 -0
- package/src/validation/compliance-reporter-new.js +282 -0
- package/src/validation/compliance-reporter-refactored.js +344 -0
- package/src/validation/compliance-reporter.js +278 -591
- package/src/validation/compliance-utils.js +278 -0
- package/src/validation/html-generator.js +446 -0
- package/src/validation/metrics/category-calculator.js +137 -0
- package/src/validation/metrics/metrics-helpers.js +155 -0
- package/src/validation/metrics/overview-calculator.js +85 -0
- package/src/validation/metrics/overview-metrics.js +41 -0
- package/src/validation/metrics/quality-calculator.js +166 -0
- package/src/validation/metrics/size-calculator.js +69 -0
- package/src/validation/metrics-calculator.js +27 -551
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Compliance Metrics Calculator
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* providing insights into file size compliance, code quality, and trends.
|
|
4
|
+
* Orchestrates metrics calculation using specialized calculator modules.
|
|
6
5
|
*/
|
|
7
6
|
|
|
8
|
-
const
|
|
7
|
+
const OverviewCalculator = require('./metrics/overview-calculator');
|
|
8
|
+
const SizeCalculator = require('./metrics/size-calculator');
|
|
9
|
+
const CategoryCalculator = require('./metrics/category-calculator');
|
|
10
|
+
const QualityCalculator = require('./metrics/quality-calculator');
|
|
11
|
+
const metricsHelpers = require('./metrics/metrics-helpers');
|
|
9
12
|
|
|
10
13
|
/**
|
|
11
14
|
* Metrics calculator class
|
|
@@ -18,6 +21,12 @@ class MetricsCalculator {
|
|
|
18
21
|
criticalThreshold: options.criticalThreshold || 800,
|
|
19
22
|
...options
|
|
20
23
|
};
|
|
24
|
+
|
|
25
|
+
// Initialize specialized calculators
|
|
26
|
+
this.overviewCalculator = new OverviewCalculator(this.options);
|
|
27
|
+
this.sizeCalculator = new SizeCalculator(this.options);
|
|
28
|
+
this.categoryCalculator = new CategoryCalculator(this.options);
|
|
29
|
+
this.qualityCalculator = new QualityCalculator(this.options);
|
|
21
30
|
}
|
|
22
31
|
|
|
23
32
|
/**
|
|
@@ -25,14 +34,14 @@ class MetricsCalculator {
|
|
|
25
34
|
*/
|
|
26
35
|
calculateMetrics(complianceReport) {
|
|
27
36
|
const metrics = {
|
|
28
|
-
overview: this.calculateOverviewMetrics(complianceReport),
|
|
29
|
-
fileMetrics: this.calculateFileMetrics(complianceReport),
|
|
30
|
-
sizeMetrics: this.calculateSizeMetrics(complianceReport),
|
|
31
|
-
categoryMetrics: this.calculateCategoryMetrics(complianceReport),
|
|
32
|
-
severityMetrics: this.calculateSeverityMetrics(complianceReport),
|
|
37
|
+
overview: this.overviewCalculator.calculateOverviewMetrics(complianceReport),
|
|
38
|
+
fileMetrics: this.overviewCalculator.calculateFileMetrics(complianceReport, metricsHelpers),
|
|
39
|
+
sizeMetrics: this.sizeCalculator.calculateSizeMetrics(complianceReport),
|
|
40
|
+
categoryMetrics: this.categoryCalculator.calculateCategoryMetrics(complianceReport),
|
|
41
|
+
severityMetrics: this.categoryCalculator.calculateSeverityMetrics(complianceReport),
|
|
33
42
|
trendMetrics: this.calculateTrendMetrics(complianceReport),
|
|
34
|
-
performanceMetrics: this.calculatePerformanceMetrics(complianceReport),
|
|
35
|
-
qualityMetrics: this.calculateQualityMetrics(complianceReport)
|
|
43
|
+
performanceMetrics: this.qualityCalculator.calculatePerformanceMetrics(complianceReport.fileSummaries),
|
|
44
|
+
qualityMetrics: this.qualityCalculator.calculateQualityMetrics(complianceReport.fileSummaries)
|
|
36
45
|
};
|
|
37
46
|
|
|
38
47
|
return {
|
|
@@ -43,173 +52,6 @@ class MetricsCalculator {
|
|
|
43
52
|
};
|
|
44
53
|
}
|
|
45
54
|
|
|
46
|
-
/**
|
|
47
|
-
* Calculate overview metrics
|
|
48
|
-
*/
|
|
49
|
-
calculateOverviewMetrics(report) {
|
|
50
|
-
const totalFiles = report.summary.totalFiles;
|
|
51
|
-
const compliantFiles = report.summary.compliantFiles;
|
|
52
|
-
const totalIssues = report.summary.totalIssues;
|
|
53
|
-
|
|
54
|
-
return {
|
|
55
|
-
totalFiles,
|
|
56
|
-
compliantFiles,
|
|
57
|
-
nonCompliantFiles: totalFiles - compliantFiles,
|
|
58
|
-
totalIssues,
|
|
59
|
-
overallComplianceScore: report.summary.overallComplianceScore,
|
|
60
|
-
complianceRate: totalFiles > 0 ? (compliantFiles / totalFiles * 100) : 100,
|
|
61
|
-
averageIssuesPerFile: totalFiles > 0 ? (totalIssues / totalFiles) : 0,
|
|
62
|
-
healthStatus: this.getHealthStatus(report.summary.overallComplianceScore)
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Calculate file-specific metrics
|
|
68
|
-
*/
|
|
69
|
-
calculateFileMetrics(report) {
|
|
70
|
-
const fileSummaries = report.fileSummaries;
|
|
71
|
-
|
|
72
|
-
// Sort files by various criteria
|
|
73
|
-
const filesBySize = [...fileSummaries].sort((a, b) => b.lineCount - a.lineCount);
|
|
74
|
-
const filesByCompliance = [...fileSummaries].sort((a, b) => a.complianceScore - b.complianceScore);
|
|
75
|
-
const filesByIssues = [...fileSummaries].sort((a, b) => b.totalIssues - a.totalIssues);
|
|
76
|
-
|
|
77
|
-
return {
|
|
78
|
-
largestFiles: filesBySize.slice(0, 10).map(f => ({
|
|
79
|
-
filePath: f.filePath,
|
|
80
|
-
lineCount: f.lineCount,
|
|
81
|
-
status: f.status,
|
|
82
|
-
complianceScore: f.complianceScore
|
|
83
|
-
})),
|
|
84
|
-
smallestFiles: filesBySize.slice(-10).reverse().map(f => ({
|
|
85
|
-
filePath: f.filePath,
|
|
86
|
-
lineCount: f.lineCount,
|
|
87
|
-
status: f.status,
|
|
88
|
-
complianceScore: f.complianceScore
|
|
89
|
-
})),
|
|
90
|
-
leastCompliantFiles: filesByCompliance.slice(0, 10).map(f => ({
|
|
91
|
-
filePath: f.filePath,
|
|
92
|
-
complianceScore: f.complianceScore,
|
|
93
|
-
status: f.status,
|
|
94
|
-
totalIssues: f.totalIssues
|
|
95
|
-
})),
|
|
96
|
-
mostProblematicFiles: filesByIssues.slice(0, 10).map(f => ({
|
|
97
|
-
filePath: f.filePath,
|
|
98
|
-
totalIssues: f.totalIssues,
|
|
99
|
-
status: f.status,
|
|
100
|
-
complianceScore: f.complianceScore
|
|
101
|
-
})),
|
|
102
|
-
averageFileSize: fileSummaries.length > 0 ?
|
|
103
|
-
fileSummaries.reduce((sum, f) => sum + f.lineCount, 0) / fileSummaries.length : 0,
|
|
104
|
-
medianFileSize: this.calculateMedian(fileSummaries.map(f => f.lineCount)),
|
|
105
|
-
fileSizeDistribution: this.calculateSizeDistribution(fileSummaries)
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Calculate size-specific metrics
|
|
111
|
-
*/
|
|
112
|
-
calculateSizeMetrics(report) {
|
|
113
|
-
const fileSummaries = report.fileSummaries;
|
|
114
|
-
const maxLimit = this.options.maxFileSize;
|
|
115
|
-
const warningThreshold = this.options.warningThreshold;
|
|
116
|
-
const criticalThreshold = this.options.criticalThreshold;
|
|
117
|
-
|
|
118
|
-
const sizeCategories = {
|
|
119
|
-
small: fileSummaries.filter(f => f.lineCount <= warningThreshold * 0.5).length,
|
|
120
|
-
medium: fileSummaries.filter(f => f.lineCount > warningThreshold * 0.5 && f.lineCount <= warningThreshold).length,
|
|
121
|
-
large: fileSummaries.filter(f => f.lineCount > warningThreshold && f.lineCount <= maxLimit).length,
|
|
122
|
-
oversized: fileSummaries.filter(f => f.lineCount > maxLimit && f.lineCount <= criticalThreshold).length,
|
|
123
|
-
critical: fileSummaries.filter(f => f.lineCount > criticalThreshold).length
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
const totalLines = fileSummaries.reduce((sum, f) => sum + f.lineCount, 0);
|
|
127
|
-
const excessLines = fileSummaries
|
|
128
|
-
.filter(f => f.lineCount > maxLimit)
|
|
129
|
-
.reduce((sum, f) => sum + (f.lineCount - maxLimit), 0);
|
|
130
|
-
|
|
131
|
-
return {
|
|
132
|
-
sizeCategories,
|
|
133
|
-
totalLines,
|
|
134
|
-
excessLines,
|
|
135
|
-
averageExcessPerOversizedFile: sizeCategories.oversized > 0 ?
|
|
136
|
-
excessLines / (sizeCategories.oversized + sizeCategories.critical) : 0,
|
|
137
|
-
sizeComplianceRate: ((sizeCategories.small + sizeCategories.medium + sizeCategories.large) / fileSummaries.length * 100),
|
|
138
|
-
criticalSizeFiles: sizeCategories.critical,
|
|
139
|
-
oversizedFiles: sizeCategories.oversized,
|
|
140
|
-
sizeRiskScore: this.calculateSizeRiskScore(sizeCategories, fileSummaries.length)
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Calculate category-specific metrics
|
|
146
|
-
*/
|
|
147
|
-
calculateCategoryMetrics(report) {
|
|
148
|
-
const categories = {};
|
|
149
|
-
const totalIssues = report.summary.totalIssues;
|
|
150
|
-
|
|
151
|
-
// Calculate metrics for each category
|
|
152
|
-
for (const [category, issueCount] of Object.entries(report.issuesByCategory)) {
|
|
153
|
-
if (issueCount > 0) {
|
|
154
|
-
const categoryFiles = report.fileSummaries.filter(f =>
|
|
155
|
-
f.issues.some(issue => issue.category === category)
|
|
156
|
-
);
|
|
157
|
-
|
|
158
|
-
categories[category] = {
|
|
159
|
-
issueCount,
|
|
160
|
-
percentage: totalIssues > 0 ? (issueCount / totalIssues * 100) : 0,
|
|
161
|
-
affectedFiles: categoryFiles.length,
|
|
162
|
-
averageIssuesPerAffectedFile: categoryFiles.length > 0 ?
|
|
163
|
-
(issueCount / categoryFiles.length) : 0,
|
|
164
|
-
severity: this.getCategorySeverity(category, issueCount, report.summary.totalFiles)
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
return {
|
|
170
|
-
categories,
|
|
171
|
-
mostProblematicCategory: this.getMostProblematicCategory(categories),
|
|
172
|
-
categoryDistribution: this.calculateCategoryDistribution(categories)
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* Calculate severity-specific metrics
|
|
178
|
-
*/
|
|
179
|
-
calculateSeverityMetrics(report) {
|
|
180
|
-
const summary = report.summary;
|
|
181
|
-
const totalIssues = report.summary.totalIssues;
|
|
182
|
-
|
|
183
|
-
const severities = {
|
|
184
|
-
critical: {
|
|
185
|
-
count: summary.criticalFiles,
|
|
186
|
-
issues: report.fileSummaries.reduce((sum, f) => sum + f.criticalIssues, 0),
|
|
187
|
-
percentage: totalIssues > 0 ? (summary.criticalFiles / summary.totalFiles * 100) : 0
|
|
188
|
-
},
|
|
189
|
-
error: {
|
|
190
|
-
count: summary.violationFiles,
|
|
191
|
-
issues: report.fileSummaries.reduce((sum, f) => sum + f.violationIssues, 0),
|
|
192
|
-
percentage: totalIssues > 0 ? (summary.violationFiles / summary.totalFiles * 100) : 0
|
|
193
|
-
},
|
|
194
|
-
warning: {
|
|
195
|
-
count: summary.warningFiles,
|
|
196
|
-
issues: report.fileSummaries.reduce((sum, f) => sum + f.warningIssues, 0),
|
|
197
|
-
percentage: totalIssues > 0 ? (summary.warningFiles / summary.totalFiles * 100) : 0
|
|
198
|
-
},
|
|
199
|
-
info: {
|
|
200
|
-
count: summary.compliantFiles,
|
|
201
|
-
issues: report.fileSummaries.reduce((sum, f) => sum + f.compliantIssues, 0),
|
|
202
|
-
percentage: totalIssues > 0 ? (summary.compliantFiles / summary.totalFiles * 100) : 0
|
|
203
|
-
}
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
return {
|
|
207
|
-
severities,
|
|
208
|
-
severityRiskScore: this.calculateSeverityRiskScore(severities),
|
|
209
|
-
escalationRisk: this.calculateEscalationRisk(severities)
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
|
|
213
55
|
/**
|
|
214
56
|
* Calculate trend metrics (if historical data available)
|
|
215
57
|
*/
|
|
@@ -217,7 +59,7 @@ class MetricsCalculator {
|
|
|
217
59
|
// This would typically compare with previous reports
|
|
218
60
|
// For now, return placeholder metrics
|
|
219
61
|
return {
|
|
220
|
-
trendDirection: 'stable',
|
|
62
|
+
trendDirection: 'stable',
|
|
221
63
|
complianceScoreChange: 0,
|
|
222
64
|
issueCountChange: 0,
|
|
223
65
|
fileCountChange: 0,
|
|
@@ -226,52 +68,18 @@ class MetricsCalculator {
|
|
|
226
68
|
};
|
|
227
69
|
}
|
|
228
70
|
|
|
229
|
-
/**
|
|
230
|
-
* Calculate performance metrics
|
|
231
|
-
*/
|
|
232
|
-
calculatePerformanceMetrics(report) {
|
|
233
|
-
const fileSummaries = report.fileSummaries;
|
|
234
|
-
|
|
235
|
-
return {
|
|
236
|
-
averageAnalysisTime: 0, // Would be populated by actual timing data
|
|
237
|
-
totalAnalysisTime: 0,
|
|
238
|
-
filesPerSecond: 0,
|
|
239
|
-
memoryUsage: {
|
|
240
|
-
estimated: this.estimateMemoryUsage(fileSummaries),
|
|
241
|
-
peak: 0
|
|
242
|
-
},
|
|
243
|
-
efficiency: {
|
|
244
|
-
issuesDetectedPerMinute: 0,
|
|
245
|
-
filesProcessedPerMinute: 0
|
|
246
|
-
}
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
* Calculate quality metrics
|
|
252
|
-
*/
|
|
253
|
-
calculateQualityMetrics(report) {
|
|
254
|
-
const fileSummaries = report.fileSummaries;
|
|
255
|
-
|
|
256
|
-
return {
|
|
257
|
-
codeQualityScore: this.calculateCodeQualityScore(fileSummaries),
|
|
258
|
-
maintainabilityIndex: this.calculateMaintainabilityIndex(fileSummaries),
|
|
259
|
-
technicalDebt: this.calculateTechnicalDebt(fileSummaries),
|
|
260
|
-
complexityMetrics: this.calculateComplexityMetrics(fileSummaries),
|
|
261
|
-
documentationCoverage: this.calculateDocumentationCoverage(fileSummaries)
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
|
-
|
|
265
71
|
/**
|
|
266
72
|
* Calculate overall metrics summary
|
|
267
73
|
*/
|
|
268
74
|
calculateMetricsSummary(metrics) {
|
|
75
|
+
const overallScore = metricsHelpers.calculateOverallScore(metrics);
|
|
76
|
+
|
|
269
77
|
return {
|
|
270
|
-
overallScore
|
|
271
|
-
riskLevel:
|
|
272
|
-
healthGrade:
|
|
273
|
-
keyInsights:
|
|
274
|
-
priorityActions:
|
|
78
|
+
overallScore,
|
|
79
|
+
riskLevel: metricsHelpers.assessRiskLevel(overallScore),
|
|
80
|
+
healthGrade: metricsHelpers.assignHealthGrade(overallScore),
|
|
81
|
+
keyInsights: metricsHelpers.extractKeyInsights(metrics),
|
|
82
|
+
priorityActions: metricsHelpers.identifyPriorityActions(metrics)
|
|
275
83
|
};
|
|
276
84
|
}
|
|
277
85
|
|
|
@@ -323,338 +131,6 @@ class MetricsCalculator {
|
|
|
323
131
|
|
|
324
132
|
return recommendations.sort((a, b) => a.priority - b.priority);
|
|
325
133
|
}
|
|
326
|
-
|
|
327
|
-
/**
|
|
328
|
-
* Helper methods
|
|
329
|
-
*/
|
|
330
|
-
getHealthStatus(complianceScore) {
|
|
331
|
-
if (complianceScore >= 95) return 'excellent';
|
|
332
|
-
if (complianceScore >= 85) return 'good';
|
|
333
|
-
if (complianceScore >= 70) return 'fair';
|
|
334
|
-
if (complianceScore >= 50) return 'poor';
|
|
335
|
-
return 'critical';
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
calculateMedian(values) {
|
|
339
|
-
const sorted = [...values].sort((a, b) => a - b);
|
|
340
|
-
const mid = Math.floor(sorted.length / 2);
|
|
341
|
-
return sorted.length % 2 === 0 ?
|
|
342
|
-
(sorted[mid - 1] + sorted[mid]) / 2 : sorted[mid];
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
calculateSizeDistribution(fileSummaries) {
|
|
346
|
-
const sizes = fileSummaries.map(f => f.lineCount);
|
|
347
|
-
const max = Math.max(...sizes);
|
|
348
|
-
const min = Math.min(...sizes);
|
|
349
|
-
const ranges = 10;
|
|
350
|
-
const rangeSize = Math.ceil((max - min) / ranges);
|
|
351
|
-
|
|
352
|
-
const distribution = [];
|
|
353
|
-
for (let i = 0; i < ranges; i++) {
|
|
354
|
-
const lower = min + (i * rangeSize);
|
|
355
|
-
const upper = lower + rangeSize;
|
|
356
|
-
const count = sizes.filter(s => s >= lower && s < upper).length;
|
|
357
|
-
|
|
358
|
-
distribution.push({
|
|
359
|
-
range: `${lower}-${upper}`,
|
|
360
|
-
count,
|
|
361
|
-
percentage: (count / fileSummaries.length * 100).toFixed(1)
|
|
362
|
-
});
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
return distribution;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
calculateSizeRiskScore(sizeCategories, totalFiles) {
|
|
369
|
-
const weights = {
|
|
370
|
-
small: 0,
|
|
371
|
-
medium: 0,
|
|
372
|
-
large: 1,
|
|
373
|
-
oversized: 5,
|
|
374
|
-
critical: 10
|
|
375
|
-
};
|
|
376
|
-
|
|
377
|
-
let riskScore = 0;
|
|
378
|
-
for (const [category, count] of Object.entries(sizeCategories)) {
|
|
379
|
-
riskScore += weights[category] * count;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
return totalFiles > 0 ? (riskScore / totalFiles) : 0;
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
getCategorySeverity(category, issueCount, totalFiles) {
|
|
386
|
-
const severityRatio = issueCount / totalFiles;
|
|
387
|
-
if (severityRatio > 0.1) return 'high';
|
|
388
|
-
if (severityRatio > 0.05) return 'medium';
|
|
389
|
-
return 'low';
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
getMostProblematicCategory(categories) {
|
|
393
|
-
return Object.entries(categories)
|
|
394
|
-
.sort(([,a], [,b]) => b.issueCount - a.issueCount)[0]?.[1];
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
calculateCategoryDistribution(categories) {
|
|
398
|
-
const total = Object.values(categories).reduce((sum, cat) => sum + cat.issueCount, 0);
|
|
399
|
-
const distribution = {};
|
|
400
|
-
|
|
401
|
-
for (const [name, category] of Object.entries(categories)) {
|
|
402
|
-
distribution[name] = {
|
|
403
|
-
count: category.issueCount,
|
|
404
|
-
percentage: total > 0 ? (category.issueCount / total * 100) : 0
|
|
405
|
-
};
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
return distribution;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
calculateSeverityRiskScore(severities) {
|
|
412
|
-
const weights = {
|
|
413
|
-
critical: 10,
|
|
414
|
-
error: 5,
|
|
415
|
-
warning: 2,
|
|
416
|
-
info: 0
|
|
417
|
-
};
|
|
418
|
-
|
|
419
|
-
let riskScore = 0;
|
|
420
|
-
for (const [severity, data] of Object.entries(severities)) {
|
|
421
|
-
riskScore += weights[severity] * data.count;
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
return riskScore;
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
calculateEscalationRisk(severities) {
|
|
428
|
-
// Risk of warnings escalating to errors, errors to critical
|
|
429
|
-
const warningToErrorRatio = severities.warning.count > 0 ?
|
|
430
|
-
severities.error.count / severities.warning.count : 0;
|
|
431
|
-
const errorToCriticalRatio = severities.error.count > 0 ?
|
|
432
|
-
severities.critical.count / severities.error.count : 0;
|
|
433
|
-
|
|
434
|
-
return {
|
|
435
|
-
warningEscalationRisk: Math.min(warningToErrorRatio * 100, 100),
|
|
436
|
-
errorEscalationRisk: Math.min(errorToCriticalRatio * 100, 100),
|
|
437
|
-
overallEscalationRisk: (warningToErrorRatio + errorToCriticalRatio) / 2 * 100
|
|
438
|
-
};
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
estimateMemoryUsage(fileSummaries) {
|
|
442
|
-
// Rough estimation based on file sizes and issue counts
|
|
443
|
-
const baseMemory = 50 * 1024 * 1024; // 50MB base
|
|
444
|
-
const perFileMemory = 1024; // 1KB per file
|
|
445
|
-
const perIssueMemory = 512; // 512 bytes per issue
|
|
446
|
-
|
|
447
|
-
const totalIssues = fileSummaries.reduce((sum, f) => sum + f.totalIssues, 0);
|
|
448
|
-
|
|
449
|
-
return baseMemory + (fileSummaries.length * perFileMemory) + (totalIssues * perIssueMemory);
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
calculateCodeQualityScore(fileSummaries) {
|
|
453
|
-
const totalFiles = fileSummaries.length;
|
|
454
|
-
const compliantFiles = fileSummaries.filter(f => f.status === COMPLIANCE_STATUS.COMPLIANT).length;
|
|
455
|
-
const totalIssues = fileSummaries.reduce((sum, f) => sum + f.totalIssues, 0);
|
|
456
|
-
|
|
457
|
-
// Base score from compliance
|
|
458
|
-
let score = (compliantFiles / totalFiles) * 100;
|
|
459
|
-
|
|
460
|
-
// Penalize for high issue density
|
|
461
|
-
const avgIssuesPerFile = totalIssues / totalFiles;
|
|
462
|
-
score -= Math.min(avgIssuesPerFile * 5, 30);
|
|
463
|
-
|
|
464
|
-
return Math.max(0, Math.min(100, score));
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
calculateMaintainabilityIndex(fileSummaries) {
|
|
468
|
-
// Simplified maintainability index based on file sizes and issues
|
|
469
|
-
let totalIndex = 0;
|
|
470
|
-
|
|
471
|
-
for (const file of fileSummaries) {
|
|
472
|
-
let fileIndex = 100;
|
|
473
|
-
|
|
474
|
-
// Reduce based on file size
|
|
475
|
-
if (file.lineCount > 555) {
|
|
476
|
-
fileIndex -= ((file.lineCount - 555) / 555) * 30;
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
// Reduce based on issues
|
|
480
|
-
fileIndex -= file.totalIssues * 2;
|
|
481
|
-
|
|
482
|
-
totalIndex += Math.max(0, fileIndex);
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
return fileSummaries.length > 0 ? totalIndex / fileSummaries.length : 100;
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
calculateTechnicalDebt(fileSummaries) {
|
|
489
|
-
// Estimate technical debt in hours based on violations
|
|
490
|
-
let totalDebt = 0;
|
|
491
|
-
|
|
492
|
-
for (const file of fileSummaries) {
|
|
493
|
-
// Base debt per file
|
|
494
|
-
let fileDebt = 0;
|
|
495
|
-
|
|
496
|
-
// Size-related debt
|
|
497
|
-
if (file.lineCount > 555) {
|
|
498
|
-
fileDebt += (file.lineCount - 555) * 0.1; // 6 minutes per excess line
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
// Issue-related debt
|
|
502
|
-
fileDebt += file.criticalIssues * 4; // 4 hours per critical issue
|
|
503
|
-
fileDebt += file.violationIssues * 2; // 2 hours per violation
|
|
504
|
-
fileDebt += file.warningIssues * 0.5; // 30 minutes per warning
|
|
505
|
-
|
|
506
|
-
totalDebt += fileDebt;
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
return {
|
|
510
|
-
totalHours: totalDebt,
|
|
511
|
-
totalDays: totalDebt / 8,
|
|
512
|
-
estimatedCost: totalDebt * 100, // $100/hour assumption
|
|
513
|
-
priorityFiles: fileSummaries
|
|
514
|
-
.filter(f => f.lineCount > 555 || f.totalIssues > 5)
|
|
515
|
-
.map(f => ({
|
|
516
|
-
filePath: f.filePath,
|
|
517
|
-
estimatedHours: (f.lineCount > 555 ? (f.lineCount - 555) * 0.1 : 0) +
|
|
518
|
-
(f.criticalIssues * 4) +
|
|
519
|
-
(f.violationIssues * 2) +
|
|
520
|
-
(f.warningIssues * 0.5)
|
|
521
|
-
}))
|
|
522
|
-
.sort((a, b) => b.estimatedHours - a.estimatedHours)
|
|
523
|
-
.slice(0, 10)
|
|
524
|
-
};
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
calculateComplexityMetrics(fileSummaries) {
|
|
528
|
-
return {
|
|
529
|
-
averageComplexity: fileSummaries.length > 0 ?
|
|
530
|
-
fileSummaries.reduce((sum, f) => sum + (f.lineCount / 100), 0) / fileSummaries.length : 0,
|
|
531
|
-
highComplexityFiles: fileSummaries.filter(f => f.lineCount > 500).length,
|
|
532
|
-
complexityDistribution: this.calculateComplexityDistribution(fileSummaries)
|
|
533
|
-
};
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
calculateComplexityDistribution(fileSummaries) {
|
|
537
|
-
const complexity = fileSummaries.map(f => f.lineCount / 100);
|
|
538
|
-
const distribution = {
|
|
539
|
-
low: complexity.filter(c => c < 2).length,
|
|
540
|
-
medium: complexity.filter(c => c >= 2 && c < 5).length,
|
|
541
|
-
high: complexity.filter(c => c >= 5 && c < 10).length,
|
|
542
|
-
veryHigh: complexity.filter(c => c >= 10).length
|
|
543
|
-
};
|
|
544
|
-
|
|
545
|
-
return distribution;
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
calculateDocumentationCoverage(fileSummaries) {
|
|
549
|
-
const totalFiles = fileSummaries.length;
|
|
550
|
-
const documentedFiles = fileSummaries.filter(f =>
|
|
551
|
-
f.issues.some(issue => issue.category === COMPLIANCE_CATEGORIES.DOCUMENTATION)
|
|
552
|
-
).length;
|
|
553
|
-
|
|
554
|
-
return {
|
|
555
|
-
coveragePercentage: totalFiles > 0 ? (documentedFiles / totalFiles * 100) : 100,
|
|
556
|
-
documentedFiles,
|
|
557
|
-
undocumentedFiles: totalFiles - documentedFiles
|
|
558
|
-
};
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
calculateOverallScore(metrics) {
|
|
562
|
-
const weights = {
|
|
563
|
-
compliance: 0.3,
|
|
564
|
-
size: 0.25,
|
|
565
|
-
severity: 0.2,
|
|
566
|
-
quality: 0.15,
|
|
567
|
-
category: 0.1
|
|
568
|
-
};
|
|
569
|
-
|
|
570
|
-
const scores = {
|
|
571
|
-
compliance: metrics.overview.complianceRate,
|
|
572
|
-
size: Math.max(0, 100 - metrics.sizeMetrics.sizeRiskScore * 10),
|
|
573
|
-
severity: Math.max(0, 100 - metrics.severityMetrics.severityRiskScore),
|
|
574
|
-
quality: metrics.qualityMetrics.codeQualityScore,
|
|
575
|
-
category: 100 - (metrics.categoryMetrics.mostProblematicCategory?.issueCount || 0) * 5
|
|
576
|
-
};
|
|
577
|
-
|
|
578
|
-
let overallScore = 0;
|
|
579
|
-
for (const [metric, weight] of Object.entries(weights)) {
|
|
580
|
-
overallScore += scores[metric] * weight;
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
return Math.max(0, Math.min(100, overallScore));
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
assessRiskLevel(metrics) {
|
|
587
|
-
const overallScore = this.calculateOverallScore(metrics);
|
|
588
|
-
if (overallScore >= 90) return 'low';
|
|
589
|
-
if (overallScore >= 70) return 'medium';
|
|
590
|
-
if (overallScore >= 50) return 'high';
|
|
591
|
-
return 'critical';
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
assignHealthGrade(metrics) {
|
|
595
|
-
const overallScore = this.calculateOverallScore(metrics);
|
|
596
|
-
if (overallScore >= 95) return 'A+';
|
|
597
|
-
if (overallScore >= 90) return 'A';
|
|
598
|
-
if (overallScore >= 85) return 'B+';
|
|
599
|
-
if (overallScore >= 80) return 'B';
|
|
600
|
-
if (overallScore >= 75) return 'C+';
|
|
601
|
-
if (overallScore >= 70) return 'C';
|
|
602
|
-
if (overallScore >= 60) return 'D';
|
|
603
|
-
return 'F';
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
extractKeyInsights(metrics) {
|
|
607
|
-
const insights = [];
|
|
608
|
-
|
|
609
|
-
if (metrics.overview.complianceRate < 80) {
|
|
610
|
-
insights.push('Compliance rate below target - requires immediate attention');
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
if (metrics.sizeMetrics.criticalSizeFiles > 0) {
|
|
614
|
-
insights.push(`${metrics.sizeMetrics.criticalSizeFiles} files require immediate refactoring`);
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
if (metrics.severityMetrics.severities.critical.count > 0) {
|
|
618
|
-
insights.push('Critical violations detected - address immediately');
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
const mostProblematic = metrics.categoryMetrics.mostProblematicCategory;
|
|
622
|
-
if (mostProblematic && mostProblematic.issueCount > 5) {
|
|
623
|
-
insights.push(`${mostProblematic.category} category has highest violation count`);
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
return insights;
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
identifyPriorityActions(metrics) {
|
|
630
|
-
const actions = [];
|
|
631
|
-
|
|
632
|
-
if (metrics.sizeMetrics.criticalSizeFiles > 0) {
|
|
633
|
-
actions.push({
|
|
634
|
-
action: 'Refactor critical files',
|
|
635
|
-
priority: 1,
|
|
636
|
-
description: 'Address files exceeding critical size threshold'
|
|
637
|
-
});
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
if (metrics.severityMetrics.severities.critical.count > 0) {
|
|
641
|
-
actions.push({
|
|
642
|
-
action: 'Fix critical violations',
|
|
643
|
-
priority: 2,
|
|
644
|
-
description: 'Resolve all critical compliance issues'
|
|
645
|
-
});
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
if (metrics.overview.complianceRate < 80) {
|
|
649
|
-
actions.push({
|
|
650
|
-
action: 'Improve compliance rate',
|
|
651
|
-
priority: 3,
|
|
652
|
-
description: 'Focus on improving overall compliance to >90%'
|
|
653
|
-
});
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
return actions;
|
|
657
|
-
}
|
|
658
134
|
}
|
|
659
135
|
|
|
660
136
|
module.exports = MetricsCalculator;
|