test-genie-mcp 2.0.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 +219 -0
- package/dist/analyzers/astAnalyzer.d.ts +108 -0
- package/dist/analyzers/astAnalyzer.d.ts.map +1 -0
- package/dist/analyzers/astAnalyzer.js +800 -0
- package/dist/analyzers/astAnalyzer.js.map +1 -0
- package/dist/analyzers/performanceAnalyzer.d.ts +90 -0
- package/dist/analyzers/performanceAnalyzer.d.ts.map +1 -0
- package/dist/analyzers/performanceAnalyzer.js +647 -0
- package/dist/analyzers/performanceAnalyzer.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +683 -0
- package/dist/index.js.map +1 -0
- package/dist/platforms/android/index.d.ts +90 -0
- package/dist/platforms/android/index.d.ts.map +1 -0
- package/dist/platforms/android/index.js +519 -0
- package/dist/platforms/android/index.js.map +1 -0
- package/dist/platforms/flutter/index.d.ts +105 -0
- package/dist/platforms/flutter/index.d.ts.map +1 -0
- package/dist/platforms/flutter/index.js +533 -0
- package/dist/platforms/flutter/index.js.map +1 -0
- package/dist/platforms/ios/index.d.ts +79 -0
- package/dist/platforms/ios/index.d.ts.map +1 -0
- package/dist/platforms/ios/index.js +393 -0
- package/dist/platforms/ios/index.js.map +1 -0
- package/dist/platforms/react-native/index.d.ts +160 -0
- package/dist/platforms/react-native/index.d.ts.map +1 -0
- package/dist/platforms/react-native/index.js +602 -0
- package/dist/platforms/react-native/index.js.map +1 -0
- package/dist/platforms/web/index.d.ts +177 -0
- package/dist/platforms/web/index.d.ts.map +1 -0
- package/dist/platforms/web/index.js +637 -0
- package/dist/platforms/web/index.js.map +1 -0
- package/dist/storage/index.d.ts +35 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +351 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/tools/analysis/analyzeAppStructure.d.ts +9 -0
- package/dist/tools/analysis/analyzeAppStructure.d.ts.map +1 -0
- package/dist/tools/analysis/analyzeAppStructure.js +289 -0
- package/dist/tools/analysis/analyzeAppStructure.js.map +1 -0
- package/dist/tools/analysis/createTestPlan.d.ts +21 -0
- package/dist/tools/analysis/createTestPlan.d.ts.map +1 -0
- package/dist/tools/analysis/createTestPlan.js +214 -0
- package/dist/tools/analysis/createTestPlan.js.map +1 -0
- package/dist/tools/analysis/generateScenarios.d.ts +21 -0
- package/dist/tools/analysis/generateScenarios.d.ts.map +1 -0
- package/dist/tools/analysis/generateScenarios.js +567 -0
- package/dist/tools/analysis/generateScenarios.js.map +1 -0
- package/dist/tools/automation/cicdIntegration.d.ts +41 -0
- package/dist/tools/automation/cicdIntegration.d.ts.map +1 -0
- package/dist/tools/automation/cicdIntegration.js +825 -0
- package/dist/tools/automation/cicdIntegration.js.map +1 -0
- package/dist/tools/automation/generateReport.d.ts +16 -0
- package/dist/tools/automation/generateReport.d.ts.map +1 -0
- package/dist/tools/automation/generateReport.js +406 -0
- package/dist/tools/automation/generateReport.js.map +1 -0
- package/dist/tools/automation/runFullAutomation.d.ts +25 -0
- package/dist/tools/automation/runFullAutomation.d.ts.map +1 -0
- package/dist/tools/automation/runFullAutomation.js +296 -0
- package/dist/tools/automation/runFullAutomation.js.map +1 -0
- package/dist/tools/detection/detectLogicErrors.d.ts +18 -0
- package/dist/tools/detection/detectLogicErrors.d.ts.map +1 -0
- package/dist/tools/detection/detectLogicErrors.js +470 -0
- package/dist/tools/detection/detectLogicErrors.js.map +1 -0
- package/dist/tools/detection/detectMemoryLeaks.d.ts +23 -0
- package/dist/tools/detection/detectMemoryLeaks.d.ts.map +1 -0
- package/dist/tools/detection/detectMemoryLeaks.js +453 -0
- package/dist/tools/detection/detectMemoryLeaks.js.map +1 -0
- package/dist/tools/execution/runScenarioTest.d.ts +34 -0
- package/dist/tools/execution/runScenarioTest.d.ts.map +1 -0
- package/dist/tools/execution/runScenarioTest.js +334 -0
- package/dist/tools/execution/runScenarioTest.js.map +1 -0
- package/dist/tools/execution/runSimulation.d.ts +17 -0
- package/dist/tools/execution/runSimulation.d.ts.map +1 -0
- package/dist/tools/execution/runSimulation.js +250 -0
- package/dist/tools/execution/runSimulation.js.map +1 -0
- package/dist/tools/execution/runStressTest.d.ts +52 -0
- package/dist/tools/execution/runStressTest.d.ts.map +1 -0
- package/dist/tools/execution/runStressTest.js +176 -0
- package/dist/tools/execution/runStressTest.js.map +1 -0
- package/dist/tools/fixing/applyFix.d.ts +44 -0
- package/dist/tools/fixing/applyFix.d.ts.map +1 -0
- package/dist/tools/fixing/applyFix.js +399 -0
- package/dist/tools/fixing/applyFix.js.map +1 -0
- package/dist/tools/fixing/confirmFix.d.ts +31 -0
- package/dist/tools/fixing/confirmFix.d.ts.map +1 -0
- package/dist/tools/fixing/confirmFix.js +136 -0
- package/dist/tools/fixing/confirmFix.js.map +1 -0
- package/dist/tools/fixing/suggestFixes.d.ts +23 -0
- package/dist/tools/fixing/suggestFixes.d.ts.map +1 -0
- package/dist/tools/fixing/suggestFixes.js +349 -0
- package/dist/tools/fixing/suggestFixes.js.map +1 -0
- package/dist/types.d.ts +322 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/codeParser.d.ts +12 -0
- package/dist/utils/codeParser.d.ts.map +1 -0
- package/dist/utils/codeParser.js +487 -0
- package/dist/utils/codeParser.js.map +1 -0
- package/package.json +68 -0
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ============================================
|
|
3
|
+
// Detect Memory Leaks Tool
|
|
4
|
+
// ============================================
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.detectMemoryLeaks = detectMemoryLeaks;
|
|
40
|
+
const uuid_1 = require("uuid");
|
|
41
|
+
const fs = __importStar(require("fs"));
|
|
42
|
+
const codeParser_js_1 = require("../../utils/codeParser.js");
|
|
43
|
+
const index_js_1 = require("../../storage/index.js");
|
|
44
|
+
function detectMemoryLeaks(params) {
|
|
45
|
+
const { appStructure, analysisType = 'both', thresholds = {}, } = params;
|
|
46
|
+
const issues = [];
|
|
47
|
+
// Static analysis
|
|
48
|
+
if (analysisType === 'static' || analysisType === 'both') {
|
|
49
|
+
const staticIssues = performStaticAnalysis(appStructure);
|
|
50
|
+
issues.push(...staticIssues);
|
|
51
|
+
}
|
|
52
|
+
// Dynamic analysis (simulated)
|
|
53
|
+
if (analysisType === 'dynamic' || analysisType === 'both') {
|
|
54
|
+
const dynamicIssues = performDynamicAnalysis(appStructure, thresholds);
|
|
55
|
+
issues.push(...dynamicIssues);
|
|
56
|
+
}
|
|
57
|
+
// Save issues
|
|
58
|
+
(0, index_js_1.saveIssues)(issues, appStructure.projectPath);
|
|
59
|
+
// Generate summary
|
|
60
|
+
const summary = {
|
|
61
|
+
totalIssues: issues.length,
|
|
62
|
+
critical: issues.filter(i => i.severity === 'critical').length,
|
|
63
|
+
high: issues.filter(i => i.severity === 'high').length,
|
|
64
|
+
medium: issues.filter(i => i.severity === 'medium').length,
|
|
65
|
+
low: issues.filter(i => i.severity === 'low').length,
|
|
66
|
+
};
|
|
67
|
+
return {
|
|
68
|
+
issues,
|
|
69
|
+
summary,
|
|
70
|
+
recommendations: generateRecommendations(issues, appStructure),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function performStaticAnalysis(appStructure) {
|
|
74
|
+
const issues = [];
|
|
75
|
+
const extensions = getExtensions(appStructure.platform);
|
|
76
|
+
const files = (0, codeParser_js_1.getAllFiles)(appStructure.projectPath, extensions);
|
|
77
|
+
for (const file of files) {
|
|
78
|
+
try {
|
|
79
|
+
const content = fs.readFileSync(file, 'utf-8');
|
|
80
|
+
const fileIssues = analyzeFileForMemoryLeaks(file, content, appStructure.platform);
|
|
81
|
+
issues.push(...fileIssues);
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
// Skip files that can't be read
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return issues;
|
|
88
|
+
}
|
|
89
|
+
function analyzeFileForMemoryLeaks(filePath, content, platform) {
|
|
90
|
+
const issues = [];
|
|
91
|
+
const lines = content.split('\n');
|
|
92
|
+
// Platform-specific patterns
|
|
93
|
+
switch (platform) {
|
|
94
|
+
case 'ios':
|
|
95
|
+
issues.push(...analyzeSwiftMemoryLeaks(filePath, content, lines));
|
|
96
|
+
break;
|
|
97
|
+
case 'android':
|
|
98
|
+
issues.push(...analyzeKotlinMemoryLeaks(filePath, content, lines));
|
|
99
|
+
break;
|
|
100
|
+
case 'flutter':
|
|
101
|
+
issues.push(...analyzeDartMemoryLeaks(filePath, content, lines));
|
|
102
|
+
break;
|
|
103
|
+
case 'react-native':
|
|
104
|
+
case 'web':
|
|
105
|
+
issues.push(...analyzeReactMemoryLeaks(filePath, content, lines));
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
return issues;
|
|
109
|
+
}
|
|
110
|
+
function analyzeSwiftMemoryLeaks(filePath, content, lines) {
|
|
111
|
+
const issues = [];
|
|
112
|
+
// Check for NotificationCenter without removeObserver
|
|
113
|
+
if (content.includes('NotificationCenter.default.addObserver') && !content.includes('removeObserver')) {
|
|
114
|
+
const lineNum = lines.findIndex(l => l.includes('addObserver')) + 1;
|
|
115
|
+
issues.push({
|
|
116
|
+
id: (0, uuid_1.v4)(),
|
|
117
|
+
type: 'memory_leak',
|
|
118
|
+
severity: 'high',
|
|
119
|
+
title: 'NotificationCenter observer not removed',
|
|
120
|
+
description: 'NotificationCenter observer is added but never removed, causing a memory leak',
|
|
121
|
+
file: filePath,
|
|
122
|
+
line: lineNum,
|
|
123
|
+
code: lines[lineNum - 1]?.trim(),
|
|
124
|
+
objectType: 'NotificationCenter',
|
|
125
|
+
suggestion: 'Add removeObserver in deinit or appropriate cleanup method',
|
|
126
|
+
detectedAt: new Date().toISOString(),
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
// Check for Timer without invalidate
|
|
130
|
+
if (content.includes('Timer.scheduledTimer') && !content.includes('invalidate')) {
|
|
131
|
+
const lineNum = lines.findIndex(l => l.includes('Timer.scheduledTimer')) + 1;
|
|
132
|
+
issues.push({
|
|
133
|
+
id: (0, uuid_1.v4)(),
|
|
134
|
+
type: 'memory_leak',
|
|
135
|
+
severity: 'high',
|
|
136
|
+
title: 'Timer not invalidated',
|
|
137
|
+
description: 'Timer is scheduled but never invalidated, causing a memory leak',
|
|
138
|
+
file: filePath,
|
|
139
|
+
line: lineNum,
|
|
140
|
+
code: lines[lineNum - 1]?.trim(),
|
|
141
|
+
objectType: 'Timer',
|
|
142
|
+
suggestion: 'Call timer.invalidate() in deinit or when timer is no longer needed',
|
|
143
|
+
detectedAt: new Date().toISOString(),
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
// Check for closures without weak self
|
|
147
|
+
const closurePattern = /\{[^}]*self\.[^}]*\}/g;
|
|
148
|
+
let match;
|
|
149
|
+
while ((match = closurePattern.exec(content)) !== null) {
|
|
150
|
+
const matchStart = content.substring(0, match.index).split('\n').length;
|
|
151
|
+
const closureContent = match[0];
|
|
152
|
+
if (!closureContent.includes('[weak self]') && !closureContent.includes('[unowned self]')) {
|
|
153
|
+
// Check if this is an escaping closure
|
|
154
|
+
const beforeClosure = content.substring(Math.max(0, match.index - 100), match.index);
|
|
155
|
+
if (beforeClosure.includes('Task') || beforeClosure.includes('async') ||
|
|
156
|
+
beforeClosure.includes('completion') || beforeClosure.includes('@escaping')) {
|
|
157
|
+
issues.push({
|
|
158
|
+
id: (0, uuid_1.v4)(),
|
|
159
|
+
type: 'retain_cycle',
|
|
160
|
+
severity: 'medium',
|
|
161
|
+
title: 'Potential retain cycle in closure',
|
|
162
|
+
description: 'Closure captures self strongly which may cause a retain cycle',
|
|
163
|
+
file: filePath,
|
|
164
|
+
line: matchStart,
|
|
165
|
+
code: closureContent.substring(0, 100),
|
|
166
|
+
objectType: 'Closure',
|
|
167
|
+
retainCycle: ['self', 'closure'],
|
|
168
|
+
suggestion: 'Use [weak self] or [unowned self] to prevent retain cycle',
|
|
169
|
+
detectedAt: new Date().toISOString(),
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
// Check for delegates without weak reference
|
|
175
|
+
const delegatePattern = /var\s+(\w*delegate\w*)\s*:\s*(\w+)\s*\??\s*(?!=.*weak)/gi;
|
|
176
|
+
while ((match = delegatePattern.exec(content)) !== null) {
|
|
177
|
+
if (!content.substring(Math.max(0, match.index - 10), match.index).includes('weak')) {
|
|
178
|
+
const lineNum = content.substring(0, match.index).split('\n').length;
|
|
179
|
+
issues.push({
|
|
180
|
+
id: (0, uuid_1.v4)(),
|
|
181
|
+
type: 'retain_cycle',
|
|
182
|
+
severity: 'medium',
|
|
183
|
+
title: 'Delegate should be weak',
|
|
184
|
+
description: 'Delegate property should be weak to prevent retain cycle',
|
|
185
|
+
file: filePath,
|
|
186
|
+
line: lineNum,
|
|
187
|
+
code: match[0],
|
|
188
|
+
objectType: 'Delegate',
|
|
189
|
+
retainCycle: ['self', match[1] ?? 'delegate'],
|
|
190
|
+
suggestion: 'Make delegate property weak: weak var delegate: DelegateProtocol?',
|
|
191
|
+
detectedAt: new Date().toISOString(),
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return issues;
|
|
196
|
+
}
|
|
197
|
+
function analyzeKotlinMemoryLeaks(filePath, content, lines) {
|
|
198
|
+
const issues = [];
|
|
199
|
+
// Check for BroadcastReceiver without unregister
|
|
200
|
+
if (content.includes('registerReceiver') && !content.includes('unregisterReceiver')) {
|
|
201
|
+
const lineNum = lines.findIndex(l => l.includes('registerReceiver')) + 1;
|
|
202
|
+
issues.push({
|
|
203
|
+
id: (0, uuid_1.v4)(),
|
|
204
|
+
type: 'memory_leak',
|
|
205
|
+
severity: 'high',
|
|
206
|
+
title: 'BroadcastReceiver not unregistered',
|
|
207
|
+
description: 'BroadcastReceiver is registered but never unregistered',
|
|
208
|
+
file: filePath,
|
|
209
|
+
line: lineNum,
|
|
210
|
+
code: lines[lineNum - 1]?.trim(),
|
|
211
|
+
objectType: 'BroadcastReceiver',
|
|
212
|
+
suggestion: 'Call unregisterReceiver in onPause or onDestroy',
|
|
213
|
+
detectedAt: new Date().toISOString(),
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
// Check for Handler without removeCallbacks
|
|
217
|
+
if (content.includes('Handler') && content.includes('postDelayed') && !content.includes('removeCallbacks')) {
|
|
218
|
+
const lineNum = lines.findIndex(l => l.includes('postDelayed')) + 1;
|
|
219
|
+
issues.push({
|
|
220
|
+
id: (0, uuid_1.v4)(),
|
|
221
|
+
type: 'memory_leak',
|
|
222
|
+
severity: 'medium',
|
|
223
|
+
title: 'Handler callbacks not removed',
|
|
224
|
+
description: 'Handler postDelayed is used but callbacks are not removed',
|
|
225
|
+
file: filePath,
|
|
226
|
+
line: lineNum,
|
|
227
|
+
code: lines[lineNum - 1]?.trim(),
|
|
228
|
+
objectType: 'Handler',
|
|
229
|
+
suggestion: 'Call handler.removeCallbacksAndMessages(null) in onDestroy',
|
|
230
|
+
detectedAt: new Date().toISOString(),
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
// Check for static Context reference
|
|
234
|
+
if (content.includes('companion object') && (content.includes('Context') || content.includes('Activity'))) {
|
|
235
|
+
const lineNum = lines.findIndex(l => l.includes('companion object')) + 1;
|
|
236
|
+
issues.push({
|
|
237
|
+
id: (0, uuid_1.v4)(),
|
|
238
|
+
type: 'memory_leak',
|
|
239
|
+
severity: 'critical',
|
|
240
|
+
title: 'Static Context reference',
|
|
241
|
+
description: 'Context or Activity stored in static field causes memory leak',
|
|
242
|
+
file: filePath,
|
|
243
|
+
line: lineNum,
|
|
244
|
+
objectType: 'Context',
|
|
245
|
+
suggestion: 'Use applicationContext instead of activity context, or avoid static references',
|
|
246
|
+
detectedAt: new Date().toISOString(),
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
return issues;
|
|
250
|
+
}
|
|
251
|
+
function analyzeDartMemoryLeaks(filePath, content, lines) {
|
|
252
|
+
const issues = [];
|
|
253
|
+
// Check for StreamSubscription without cancel
|
|
254
|
+
if (content.includes('StreamSubscription') && !content.includes('cancel()')) {
|
|
255
|
+
const lineNum = lines.findIndex(l => l.includes('StreamSubscription')) + 1;
|
|
256
|
+
issues.push({
|
|
257
|
+
id: (0, uuid_1.v4)(),
|
|
258
|
+
type: 'unclosed_resource',
|
|
259
|
+
severity: 'high',
|
|
260
|
+
title: 'StreamSubscription not cancelled',
|
|
261
|
+
description: 'StreamSubscription is created but never cancelled',
|
|
262
|
+
file: filePath,
|
|
263
|
+
line: lineNum,
|
|
264
|
+
code: lines[lineNum - 1]?.trim(),
|
|
265
|
+
objectType: 'StreamSubscription',
|
|
266
|
+
suggestion: 'Call subscription.cancel() in dispose method',
|
|
267
|
+
detectedAt: new Date().toISOString(),
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
// Check for AnimationController without dispose
|
|
271
|
+
if (content.includes('AnimationController') && !content.includes('dispose()')) {
|
|
272
|
+
const lineNum = lines.findIndex(l => l.includes('AnimationController')) + 1;
|
|
273
|
+
issues.push({
|
|
274
|
+
id: (0, uuid_1.v4)(),
|
|
275
|
+
type: 'unclosed_resource',
|
|
276
|
+
severity: 'high',
|
|
277
|
+
title: 'AnimationController not disposed',
|
|
278
|
+
description: 'AnimationController is created but never disposed',
|
|
279
|
+
file: filePath,
|
|
280
|
+
line: lineNum,
|
|
281
|
+
code: lines[lineNum - 1]?.trim(),
|
|
282
|
+
objectType: 'AnimationController',
|
|
283
|
+
suggestion: 'Call controller.dispose() in dispose method',
|
|
284
|
+
detectedAt: new Date().toISOString(),
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
// Check for TextEditingController without dispose
|
|
288
|
+
if (content.includes('TextEditingController()') && !content.includes('.dispose()')) {
|
|
289
|
+
const lineNum = lines.findIndex(l => l.includes('TextEditingController')) + 1;
|
|
290
|
+
issues.push({
|
|
291
|
+
id: (0, uuid_1.v4)(),
|
|
292
|
+
type: 'unclosed_resource',
|
|
293
|
+
severity: 'medium',
|
|
294
|
+
title: 'TextEditingController not disposed',
|
|
295
|
+
description: 'TextEditingController should be disposed when no longer needed',
|
|
296
|
+
file: filePath,
|
|
297
|
+
line: lineNum,
|
|
298
|
+
code: lines[lineNum - 1]?.trim(),
|
|
299
|
+
objectType: 'TextEditingController',
|
|
300
|
+
suggestion: 'Call controller.dispose() in dispose method',
|
|
301
|
+
detectedAt: new Date().toISOString(),
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
return issues;
|
|
305
|
+
}
|
|
306
|
+
function analyzeReactMemoryLeaks(filePath, content, lines) {
|
|
307
|
+
const issues = [];
|
|
308
|
+
// Check for useEffect without cleanup
|
|
309
|
+
const effectPattern = /useEffect\s*\(\s*\(\s*\)\s*=>\s*\{([^}]*(?:\{[^}]*\}[^}]*)*)\}/gs;
|
|
310
|
+
let match;
|
|
311
|
+
while ((match = effectPattern.exec(content)) !== null) {
|
|
312
|
+
const effectBody = match[1] || '';
|
|
313
|
+
const hasCleanup = effectBody.includes('return');
|
|
314
|
+
const lineNum = content.substring(0, match.index).split('\n').length;
|
|
315
|
+
// Check for subscriptions without cleanup
|
|
316
|
+
const needsCleanup = effectBody.includes('addEventListener') ||
|
|
317
|
+
effectBody.includes('subscribe') ||
|
|
318
|
+
effectBody.includes('setInterval') ||
|
|
319
|
+
effectBody.includes('setTimeout') ||
|
|
320
|
+
effectBody.includes('WebSocket');
|
|
321
|
+
if (needsCleanup && !hasCleanup) {
|
|
322
|
+
let objectType = 'Unknown';
|
|
323
|
+
if (effectBody.includes('addEventListener'))
|
|
324
|
+
objectType = 'EventListener';
|
|
325
|
+
else if (effectBody.includes('subscribe'))
|
|
326
|
+
objectType = 'Subscription';
|
|
327
|
+
else if (effectBody.includes('setInterval'))
|
|
328
|
+
objectType = 'Interval';
|
|
329
|
+
else if (effectBody.includes('setTimeout'))
|
|
330
|
+
objectType = 'Timeout';
|
|
331
|
+
else if (effectBody.includes('WebSocket'))
|
|
332
|
+
objectType = 'WebSocket';
|
|
333
|
+
issues.push({
|
|
334
|
+
id: (0, uuid_1.v4)(),
|
|
335
|
+
type: 'memory_leak',
|
|
336
|
+
severity: 'high',
|
|
337
|
+
title: `useEffect missing cleanup for ${objectType}`,
|
|
338
|
+
description: `useEffect creates ${objectType} but does not clean it up`,
|
|
339
|
+
file: filePath,
|
|
340
|
+
line: lineNum,
|
|
341
|
+
code: effectBody.substring(0, 100),
|
|
342
|
+
objectType,
|
|
343
|
+
suggestion: `Add return function to clean up ${objectType}`,
|
|
344
|
+
detectedAt: new Date().toISOString(),
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
// Check for event listeners without removal
|
|
349
|
+
if (content.includes('addEventListener') && !content.includes('removeEventListener')) {
|
|
350
|
+
const lineNum = lines.findIndex(l => l.includes('addEventListener')) + 1;
|
|
351
|
+
issues.push({
|
|
352
|
+
id: (0, uuid_1.v4)(),
|
|
353
|
+
type: 'memory_leak',
|
|
354
|
+
severity: 'high',
|
|
355
|
+
title: 'Event listener not removed',
|
|
356
|
+
description: 'Event listener is added but never removed',
|
|
357
|
+
file: filePath,
|
|
358
|
+
line: lineNum,
|
|
359
|
+
code: lines[lineNum - 1]?.trim(),
|
|
360
|
+
objectType: 'EventListener',
|
|
361
|
+
suggestion: 'Add removeEventListener in cleanup function',
|
|
362
|
+
detectedAt: new Date().toISOString(),
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
// Check for setInterval without clearInterval
|
|
366
|
+
if (content.includes('setInterval') && !content.includes('clearInterval')) {
|
|
367
|
+
const lineNum = lines.findIndex(l => l.includes('setInterval')) + 1;
|
|
368
|
+
issues.push({
|
|
369
|
+
id: (0, uuid_1.v4)(),
|
|
370
|
+
type: 'memory_leak',
|
|
371
|
+
severity: 'high',
|
|
372
|
+
title: 'Interval not cleared',
|
|
373
|
+
description: 'setInterval is used but interval is never cleared',
|
|
374
|
+
file: filePath,
|
|
375
|
+
line: lineNum,
|
|
376
|
+
code: lines[lineNum - 1]?.trim(),
|
|
377
|
+
objectType: 'Interval',
|
|
378
|
+
suggestion: 'Store interval ID and call clearInterval in cleanup',
|
|
379
|
+
detectedAt: new Date().toISOString(),
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
return issues;
|
|
383
|
+
}
|
|
384
|
+
function performDynamicAnalysis(appStructure, thresholds) {
|
|
385
|
+
const issues = [];
|
|
386
|
+
const { minLeakSizeMB = 5, maxRetainCount = 10 } = thresholds;
|
|
387
|
+
// Simulate dynamic analysis results
|
|
388
|
+
// In real implementation, this would use platform-specific profiling tools
|
|
389
|
+
// Check components with complex lifecycle
|
|
390
|
+
for (const component of appStructure.components) {
|
|
391
|
+
const hasSubscriptions = component.lifecycle.some(l => l.subscriptions.length > 0);
|
|
392
|
+
const hasCleanup = component.lifecycle.some(l => l.hasCleanup);
|
|
393
|
+
if (hasSubscriptions && !hasCleanup) {
|
|
394
|
+
issues.push({
|
|
395
|
+
id: (0, uuid_1.v4)(),
|
|
396
|
+
type: 'memory_leak',
|
|
397
|
+
severity: 'high',
|
|
398
|
+
title: `${component.name} - Missing lifecycle cleanup`,
|
|
399
|
+
description: `Component ${component.name} has subscriptions but no cleanup in lifecycle`,
|
|
400
|
+
file: component.path,
|
|
401
|
+
line: 1,
|
|
402
|
+
objectType: component.type,
|
|
403
|
+
suggestion: 'Add cleanup logic in appropriate lifecycle method',
|
|
404
|
+
detectedAt: new Date().toISOString(),
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
return issues;
|
|
409
|
+
}
|
|
410
|
+
function getExtensions(platform) {
|
|
411
|
+
switch (platform) {
|
|
412
|
+
case 'ios': return ['.swift', '.m'];
|
|
413
|
+
case 'android': return ['.kt', '.java'];
|
|
414
|
+
case 'flutter': return ['.dart'];
|
|
415
|
+
case 'react-native':
|
|
416
|
+
case 'web': return ['.tsx', '.ts', '.jsx', '.js'];
|
|
417
|
+
default: return ['.ts', '.js'];
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
function generateRecommendations(issues, appStructure) {
|
|
421
|
+
const recommendations = [];
|
|
422
|
+
const issueTypes = new Set(issues.map(i => i.type));
|
|
423
|
+
if (issueTypes.has('memory_leak')) {
|
|
424
|
+
recommendations.push('Review all subscription and listener registrations - ensure they are properly cleaned up');
|
|
425
|
+
}
|
|
426
|
+
if (issueTypes.has('retain_cycle')) {
|
|
427
|
+
recommendations.push('Use weak references for delegates and closures that capture self');
|
|
428
|
+
}
|
|
429
|
+
if (issueTypes.has('unclosed_resource')) {
|
|
430
|
+
recommendations.push('Implement proper dispose/cleanup methods for all controllers and streams');
|
|
431
|
+
}
|
|
432
|
+
if (issues.length > 10) {
|
|
433
|
+
recommendations.push('Consider implementing a centralized subscription management pattern');
|
|
434
|
+
}
|
|
435
|
+
// Platform-specific recommendations
|
|
436
|
+
switch (appStructure.platform) {
|
|
437
|
+
case 'ios':
|
|
438
|
+
recommendations.push('Use Instruments Leaks tool for runtime memory analysis');
|
|
439
|
+
break;
|
|
440
|
+
case 'android':
|
|
441
|
+
recommendations.push('Use Android Studio Memory Profiler and LeakCanary for runtime detection');
|
|
442
|
+
break;
|
|
443
|
+
case 'flutter':
|
|
444
|
+
recommendations.push('Use Flutter DevTools Memory view for runtime analysis');
|
|
445
|
+
break;
|
|
446
|
+
case 'react-native':
|
|
447
|
+
recommendations.push('Use Flipper Memory plugin for runtime memory analysis');
|
|
448
|
+
break;
|
|
449
|
+
}
|
|
450
|
+
return recommendations;
|
|
451
|
+
}
|
|
452
|
+
exports.default = detectMemoryLeaks;
|
|
453
|
+
//# sourceMappingURL=detectMemoryLeaks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detectMemoryLeaks.js","sourceRoot":"","sources":["../../../src/tools/detection/detectMemoryLeaks.ts"],"names":[],"mappings":";AAAA,+CAA+C;AAC/C,2BAA2B;AAC3B,+CAA+C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmC/C,8CAsCC;AAvED,+BAAoC;AACpC,uCAAyB;AAQzB,6DAAoF;AACpF,qDAAoD;AAuBpD,SAAgB,iBA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,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE,CAAC;QACnC,eAAe,CAAC,IAAI,CAAC,kEAAkE,CAAC,CAAC;IAC3F,CAAC;IAED,IAAI,UAAU,CAAC,GAAG,CAAC,mBAAmB,CAAC,EAAE,CAAC;QACxC,eAAe,CAAC,IAAI,CAAC,0EAA0E,CAAC,CAAC;IACnG,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;QACvB,eAAe,CAAC,IAAI,CAAC,qEAAqE,CAAC,CAAC;IAC9F,CAAC;IAED,oCAAoC;IACpC,QAAQ,YAAY,CAAC,QAAQ,EAAE,CAAC;QAC9B,KAAK,KAAK;YACR,eAAe,CAAC,IAAI,CAAC,wDAAwD,CAAC,CAAC;YAC/E,MAAM;QACR,KAAK,SAAS;YACZ,eAAe,CAAC,IAAI,CAAC,yEAAyE,CAAC,CAAC;YAChG,MAAM;QACR,KAAK,SAAS;YACZ,eAAe,CAAC,IAAI,CAAC,uDAAuD,CAAC,CAAC;YAC9E,MAAM;QACR,KAAK,cAAc;YACjB,eAAe,CAAC,IAAI,CAAC,uDAAuD,CAAC,CAAC;YAC9E,MAAM;IACV,CAAC;IAED,OAAO,eAAe,CAAC;AACzB,CAAC;AAED,kBAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { TestScenario, TestResult, Platform } from '../../types.js';
|
|
2
|
+
interface RunScenarioTestParams {
|
|
3
|
+
scenarioId?: string;
|
|
4
|
+
scenario?: TestScenario;
|
|
5
|
+
projectPath: string;
|
|
6
|
+
platform: Platform;
|
|
7
|
+
device?: string;
|
|
8
|
+
options?: {
|
|
9
|
+
timeout?: number;
|
|
10
|
+
retries?: number;
|
|
11
|
+
screenshots?: boolean;
|
|
12
|
+
verbose?: boolean;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
interface RunScenarioTestResult {
|
|
16
|
+
result: TestResult;
|
|
17
|
+
success: boolean;
|
|
18
|
+
duration: number;
|
|
19
|
+
summary: string;
|
|
20
|
+
}
|
|
21
|
+
export declare function runScenarioTest(params: RunScenarioTestParams): Promise<RunScenarioTestResult>;
|
|
22
|
+
export declare function runScenarios(scenarios: TestScenario[], projectPath: string, platform: Platform, options?: {
|
|
23
|
+
parallel?: boolean;
|
|
24
|
+
maxParallel?: number;
|
|
25
|
+
stopOnFailure?: boolean;
|
|
26
|
+
}): Promise<{
|
|
27
|
+
results: TestResult[];
|
|
28
|
+
passed: number;
|
|
29
|
+
failed: number;
|
|
30
|
+
skipped: number;
|
|
31
|
+
duration: number;
|
|
32
|
+
}>;
|
|
33
|
+
export default runScenarioTest;
|
|
34
|
+
//# sourceMappingURL=runScenarioTest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runScenarioTest.d.ts","sourceRoot":"","sources":["../../../src/tools/execution/runScenarioTest.ts"],"names":[],"mappings":"AASA,OAAO,EACL,YAAY,EACZ,UAAU,EAEV,QAAQ,EAET,MAAM,gBAAgB,CAAC;AAKxB,UAAU,qBAAqB;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,QAAQ,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE;QACR,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,CAAC;CACH;AAED,UAAU,qBAAqB;IAC7B,MAAM,EAAE,UAAU,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAsB,eAAe,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,C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