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,470 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ============================================
|
|
3
|
+
// Detect Logic Errors 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.detectLogicErrors = detectLogicErrors;
|
|
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 detectLogicErrors(params) {
|
|
45
|
+
const { appStructure, analysisDepth = 'normal', checkTypes = ['all'], } = params;
|
|
46
|
+
const issues = [];
|
|
47
|
+
const extensions = getExtensions(appStructure.platform);
|
|
48
|
+
const files = (0, codeParser_js_1.getAllFiles)(appStructure.projectPath, extensions);
|
|
49
|
+
const shouldCheckAll = checkTypes.includes('all');
|
|
50
|
+
for (const file of files) {
|
|
51
|
+
try {
|
|
52
|
+
const content = fs.readFileSync(file, 'utf-8');
|
|
53
|
+
if (shouldCheckAll || checkTypes.includes('race_condition')) {
|
|
54
|
+
issues.push(...detectRaceConditions(file, content, appStructure.platform));
|
|
55
|
+
}
|
|
56
|
+
if (shouldCheckAll || checkTypes.includes('state_inconsistency')) {
|
|
57
|
+
issues.push(...detectStateInconsistencies(file, content, appStructure.platform));
|
|
58
|
+
}
|
|
59
|
+
if (shouldCheckAll || checkTypes.includes('null_reference')) {
|
|
60
|
+
issues.push(...detectNullReferences(file, content, appStructure.platform));
|
|
61
|
+
}
|
|
62
|
+
if (shouldCheckAll || checkTypes.includes('type_mismatch')) {
|
|
63
|
+
issues.push(...detectTypeMismatches(file, content, appStructure.platform));
|
|
64
|
+
}
|
|
65
|
+
if (analysisDepth === 'deep') {
|
|
66
|
+
issues.push(...detectAdvancedLogicErrors(file, content, appStructure.platform));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
// Skip files that can't be read
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// Save issues
|
|
74
|
+
(0, index_js_1.saveIssues)(issues, appStructure.projectPath);
|
|
75
|
+
// Generate summary
|
|
76
|
+
const byType = {};
|
|
77
|
+
const bySeverity = {};
|
|
78
|
+
for (const issue of issues) {
|
|
79
|
+
byType[issue.type] = (byType[issue.type] || 0) + 1;
|
|
80
|
+
bySeverity[issue.severity] = (bySeverity[issue.severity] || 0) + 1;
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
issues,
|
|
84
|
+
summary: {
|
|
85
|
+
totalIssues: issues.length,
|
|
86
|
+
byType,
|
|
87
|
+
bySeverity,
|
|
88
|
+
},
|
|
89
|
+
recommendations: generateRecommendations(issues, appStructure),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function detectRaceConditions(filePath, content, platform) {
|
|
93
|
+
const issues = [];
|
|
94
|
+
const lines = content.split('\n');
|
|
95
|
+
// Check for async state updates without proper synchronization
|
|
96
|
+
const asyncStatePattern = /async\s+.*\{[\s\S]*?(setState|state\s*=|\.value\s*=)[\s\S]*?\}/g;
|
|
97
|
+
let match;
|
|
98
|
+
while ((match = asyncStatePattern.exec(content)) !== null) {
|
|
99
|
+
const matchContent = match[0];
|
|
100
|
+
const lineNum = content.substring(0, match.index).split('\n').length;
|
|
101
|
+
// Check if there's proper handling for component unmount
|
|
102
|
+
if (!matchContent.includes('isMounted') && !matchContent.includes('mounted') &&
|
|
103
|
+
!matchContent.includes('disposed') && !matchContent.includes('cancelled')) {
|
|
104
|
+
issues.push({
|
|
105
|
+
id: (0, uuid_1.v4)(),
|
|
106
|
+
type: 'race_condition',
|
|
107
|
+
severity: 'high',
|
|
108
|
+
title: 'Async state update without mount check',
|
|
109
|
+
description: 'Async operation updates state without checking if component is still mounted',
|
|
110
|
+
file: filePath,
|
|
111
|
+
line: lineNum,
|
|
112
|
+
code: matchContent.substring(0, 150),
|
|
113
|
+
context: 'Async state update',
|
|
114
|
+
possibleCause: 'Component may unmount before async operation completes',
|
|
115
|
+
reproducibility: 'intermittent',
|
|
116
|
+
suggestion: 'Add isMounted check or use AbortController',
|
|
117
|
+
detectedAt: new Date().toISOString(),
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
// Check for race conditions in shared state
|
|
122
|
+
if (platform === 'react-native' || platform === 'web') {
|
|
123
|
+
// Multiple setState calls in sequence
|
|
124
|
+
const setStatePattern = /setState\s*\([^)]+\)[^;]*;[\s\n]*setState\s*\(/g;
|
|
125
|
+
while ((match = setStatePattern.exec(content)) !== null) {
|
|
126
|
+
const lineNum = content.substring(0, match.index).split('\n').length;
|
|
127
|
+
issues.push({
|
|
128
|
+
id: (0, uuid_1.v4)(),
|
|
129
|
+
type: 'race_condition',
|
|
130
|
+
severity: 'medium',
|
|
131
|
+
title: 'Multiple setState calls',
|
|
132
|
+
description: 'Multiple setState calls may cause race condition or batching issues',
|
|
133
|
+
file: filePath,
|
|
134
|
+
line: lineNum,
|
|
135
|
+
context: 'State updates',
|
|
136
|
+
possibleCause: 'State updates may not batch correctly',
|
|
137
|
+
reproducibility: 'intermittent',
|
|
138
|
+
suggestion: 'Combine into single setState call or use functional updates',
|
|
139
|
+
detectedAt: new Date().toISOString(),
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
// Check for shared mutable state
|
|
144
|
+
const sharedStatePattern = /let\s+(\w+)\s*=.*;\s*[\s\S]*?async[\s\S]*?\1\s*[+\-*\/]?=/g;
|
|
145
|
+
while ((match = sharedStatePattern.exec(content)) !== null) {
|
|
146
|
+
const lineNum = content.substring(0, match.index).split('\n').length;
|
|
147
|
+
issues.push({
|
|
148
|
+
id: (0, uuid_1.v4)(),
|
|
149
|
+
type: 'race_condition',
|
|
150
|
+
severity: 'high',
|
|
151
|
+
title: 'Shared mutable state in async context',
|
|
152
|
+
description: 'Mutable variable is accessed/modified in async context',
|
|
153
|
+
file: filePath,
|
|
154
|
+
line: lineNum,
|
|
155
|
+
context: 'Async modification',
|
|
156
|
+
possibleCause: 'Multiple async operations may access same variable',
|
|
157
|
+
reproducibility: 'intermittent',
|
|
158
|
+
suggestion: 'Use proper synchronization or immutable state pattern',
|
|
159
|
+
detectedAt: new Date().toISOString(),
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
return issues;
|
|
163
|
+
}
|
|
164
|
+
function detectStateInconsistencies(filePath, content, platform) {
|
|
165
|
+
const issues = [];
|
|
166
|
+
const lines = content.split('\n');
|
|
167
|
+
// Check for derived state not updated with source
|
|
168
|
+
if (platform === 'react-native' || platform === 'web') {
|
|
169
|
+
// useState that derives from props
|
|
170
|
+
const derivedStatePattern = /useState\s*\(\s*props\.(\w+)\s*\)/g;
|
|
171
|
+
let match;
|
|
172
|
+
while ((match = derivedStatePattern.exec(content)) !== null) {
|
|
173
|
+
const propName = match[1] || 'unknown';
|
|
174
|
+
const lineNum = content.substring(0, match.index).split('\n').length;
|
|
175
|
+
// Check if there's useEffect to sync
|
|
176
|
+
if (!content.includes(`useEffect`) || !content.includes(propName)) {
|
|
177
|
+
issues.push({
|
|
178
|
+
id: (0, uuid_1.v4)(),
|
|
179
|
+
type: 'state_inconsistency',
|
|
180
|
+
severity: 'medium',
|
|
181
|
+
title: 'Derived state may become stale',
|
|
182
|
+
description: `State initialized from props.${propName} but may not update when prop changes`,
|
|
183
|
+
file: filePath,
|
|
184
|
+
line: lineNum,
|
|
185
|
+
context: 'Props to state',
|
|
186
|
+
possibleCause: 'useState only uses initial value, subsequent prop changes are ignored',
|
|
187
|
+
reproducibility: 'always',
|
|
188
|
+
suggestion: 'Use useEffect to sync state with props, or compute value directly from props',
|
|
189
|
+
detectedAt: new Date().toISOString(),
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
// Check for conditional state updates
|
|
194
|
+
const conditionalStatePattern = /if\s*\([^)]+\)\s*\{[^}]*setState[^}]*\}(?!\s*else)/g;
|
|
195
|
+
while ((match = conditionalStatePattern.exec(content)) !== null) {
|
|
196
|
+
const lineNum = content.substring(0, match.index).split('\n').length;
|
|
197
|
+
const matchContent = match[0];
|
|
198
|
+
// Check if the condition involves state
|
|
199
|
+
if (matchContent.includes('state') || matchContent.includes('State')) {
|
|
200
|
+
issues.push({
|
|
201
|
+
id: (0, uuid_1.v4)(),
|
|
202
|
+
type: 'state_inconsistency',
|
|
203
|
+
severity: 'low',
|
|
204
|
+
title: 'Conditional state update without else branch',
|
|
205
|
+
description: 'State is updated conditionally which may lead to inconsistent states',
|
|
206
|
+
file: filePath,
|
|
207
|
+
line: lineNum,
|
|
208
|
+
code: matchContent.substring(0, 100),
|
|
209
|
+
context: 'Conditional update',
|
|
210
|
+
possibleCause: 'State may remain in unexpected state when condition is false',
|
|
211
|
+
reproducibility: 'always',
|
|
212
|
+
suggestion: 'Ensure all state paths are handled, or document expected behavior',
|
|
213
|
+
detectedAt: new Date().toISOString(),
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
// Flutter specific
|
|
219
|
+
if (platform === 'flutter') {
|
|
220
|
+
// Check for setState after async gap
|
|
221
|
+
const asyncSetStatePattern = /await\s+[^;]+;\s*[\s\S]{0,50}?setState/g;
|
|
222
|
+
let match;
|
|
223
|
+
while ((match = asyncSetStatePattern.exec(content)) !== null) {
|
|
224
|
+
const lineNum = content.substring(0, match.index).split('\n').length;
|
|
225
|
+
if (!content.includes('mounted')) {
|
|
226
|
+
issues.push({
|
|
227
|
+
id: (0, uuid_1.v4)(),
|
|
228
|
+
type: 'state_inconsistency',
|
|
229
|
+
severity: 'high',
|
|
230
|
+
title: 'setState after async operation',
|
|
231
|
+
description: 'setState called after await without checking mounted state',
|
|
232
|
+
file: filePath,
|
|
233
|
+
line: lineNum,
|
|
234
|
+
context: 'Async setState',
|
|
235
|
+
possibleCause: 'Widget may be disposed before setState is called',
|
|
236
|
+
reproducibility: 'intermittent',
|
|
237
|
+
suggestion: 'Check if (mounted) before calling setState after await',
|
|
238
|
+
detectedAt: new Date().toISOString(),
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return issues;
|
|
244
|
+
}
|
|
245
|
+
function detectNullReferences(filePath, content, platform) {
|
|
246
|
+
const issues = [];
|
|
247
|
+
const lines = content.split('\n');
|
|
248
|
+
// TypeScript/JavaScript null checks
|
|
249
|
+
if (platform === 'react-native' || platform === 'web') {
|
|
250
|
+
// Force unwrap with !
|
|
251
|
+
const forceUnwrapPattern = /(\w+)!\./g;
|
|
252
|
+
let match;
|
|
253
|
+
while ((match = forceUnwrapPattern.exec(content)) !== null) {
|
|
254
|
+
const lineNum = content.substring(0, match.index).split('\n').length;
|
|
255
|
+
issues.push({
|
|
256
|
+
id: (0, uuid_1.v4)(),
|
|
257
|
+
type: 'null_reference',
|
|
258
|
+
severity: 'medium',
|
|
259
|
+
title: 'Non-null assertion operator',
|
|
260
|
+
description: `Force unwrap of ${match[1]} may cause runtime error if null`,
|
|
261
|
+
file: filePath,
|
|
262
|
+
line: lineNum,
|
|
263
|
+
code: lines[lineNum - 1]?.trim(),
|
|
264
|
+
context: 'Force unwrap',
|
|
265
|
+
possibleCause: 'Value may be null at runtime despite assertion',
|
|
266
|
+
reproducibility: 'intermittent',
|
|
267
|
+
suggestion: 'Use optional chaining (?.) or proper null check',
|
|
268
|
+
detectedAt: new Date().toISOString(),
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
// Accessing property without null check
|
|
272
|
+
const nullableAccessPattern = /(\w+)\?\.[a-zA-Z]+\s*\(/g;
|
|
273
|
+
while ((match = nullableAccessPattern.exec(content)) !== null) {
|
|
274
|
+
// This is actually safe - it's using optional chaining
|
|
275
|
+
}
|
|
276
|
+
// Potential null access after conditional
|
|
277
|
+
const unsafeAccessPattern = /if\s*\(\s*(\w+)\s*\)\s*\{[\s\S]*?\}\s*[\s\S]{0,50}?\1\./g;
|
|
278
|
+
while ((match = unsafeAccessPattern.exec(content)) !== null) {
|
|
279
|
+
const lineNum = content.substring(0, match.index).split('\n').length;
|
|
280
|
+
const varName = match[1];
|
|
281
|
+
// Check if there's an else that returns/throws
|
|
282
|
+
if (!match[0].includes('return') && !match[0].includes('throw')) {
|
|
283
|
+
issues.push({
|
|
284
|
+
id: (0, uuid_1.v4)(),
|
|
285
|
+
type: 'null_reference',
|
|
286
|
+
severity: 'low',
|
|
287
|
+
title: 'Potential unsafe access after null check',
|
|
288
|
+
description: `${varName} accessed outside of null-check block`,
|
|
289
|
+
file: filePath,
|
|
290
|
+
line: lineNum,
|
|
291
|
+
context: 'Null check scope',
|
|
292
|
+
possibleCause: 'Variable may be null when accessed outside if block',
|
|
293
|
+
reproducibility: 'always',
|
|
294
|
+
suggestion: 'Ensure access is within null-check block or add guard clause',
|
|
295
|
+
detectedAt: new Date().toISOString(),
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
// Swift null checks
|
|
301
|
+
if (platform === 'ios') {
|
|
302
|
+
// Force unwrap
|
|
303
|
+
const forceUnwrapPattern = /(\w+)!/g;
|
|
304
|
+
let match;
|
|
305
|
+
while ((match = forceUnwrapPattern.exec(content)) !== null) {
|
|
306
|
+
const lineNum = content.substring(0, match.index).split('\n').length;
|
|
307
|
+
const varName = match[1];
|
|
308
|
+
// Skip common false positives
|
|
309
|
+
if (['try', 'as', 'NSObject'].includes(varName || ''))
|
|
310
|
+
continue;
|
|
311
|
+
issues.push({
|
|
312
|
+
id: (0, uuid_1.v4)(),
|
|
313
|
+
type: 'null_reference',
|
|
314
|
+
severity: 'medium',
|
|
315
|
+
title: 'Force unwrap of optional',
|
|
316
|
+
description: `Force unwrap of ${varName} may cause crash if nil`,
|
|
317
|
+
file: filePath,
|
|
318
|
+
line: lineNum,
|
|
319
|
+
code: lines[lineNum - 1]?.trim(),
|
|
320
|
+
context: 'Force unwrap',
|
|
321
|
+
possibleCause: 'Optional value may be nil at runtime',
|
|
322
|
+
reproducibility: 'intermittent',
|
|
323
|
+
suggestion: 'Use if let, guard let, or nil coalescing (??) instead',
|
|
324
|
+
detectedAt: new Date().toISOString(),
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
// Kotlin null checks
|
|
329
|
+
if (platform === 'android') {
|
|
330
|
+
// Not-null assertion
|
|
331
|
+
const notNullPattern = /(\w+)!!/g;
|
|
332
|
+
let match;
|
|
333
|
+
while ((match = notNullPattern.exec(content)) !== null) {
|
|
334
|
+
const lineNum = content.substring(0, match.index).split('\n').length;
|
|
335
|
+
issues.push({
|
|
336
|
+
id: (0, uuid_1.v4)(),
|
|
337
|
+
type: 'null_reference',
|
|
338
|
+
severity: 'medium',
|
|
339
|
+
title: 'Not-null assertion operator',
|
|
340
|
+
description: `Not-null assertion on ${match[1]} may throw NPE`,
|
|
341
|
+
file: filePath,
|
|
342
|
+
line: lineNum,
|
|
343
|
+
code: lines[lineNum - 1]?.trim(),
|
|
344
|
+
context: 'Not-null assertion',
|
|
345
|
+
possibleCause: 'Value may be null at runtime',
|
|
346
|
+
reproducibility: 'intermittent',
|
|
347
|
+
suggestion: 'Use safe call (?.) or null check',
|
|
348
|
+
detectedAt: new Date().toISOString(),
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
return issues;
|
|
353
|
+
}
|
|
354
|
+
function detectTypeMismatches(filePath, content, platform) {
|
|
355
|
+
const issues = [];
|
|
356
|
+
const lines = content.split('\n');
|
|
357
|
+
// Check for 'any' type usage (TypeScript)
|
|
358
|
+
if (platform === 'react-native' || platform === 'web') {
|
|
359
|
+
const anyPattern = /:\s*any\b/g;
|
|
360
|
+
let match;
|
|
361
|
+
while ((match = anyPattern.exec(content)) !== null) {
|
|
362
|
+
const lineNum = content.substring(0, match.index).split('\n').length;
|
|
363
|
+
issues.push({
|
|
364
|
+
id: (0, uuid_1.v4)(),
|
|
365
|
+
type: 'type_mismatch',
|
|
366
|
+
severity: 'low',
|
|
367
|
+
title: 'Usage of any type',
|
|
368
|
+
description: 'Using any type bypasses TypeScript type checking',
|
|
369
|
+
file: filePath,
|
|
370
|
+
line: lineNum,
|
|
371
|
+
code: lines[lineNum - 1]?.trim(),
|
|
372
|
+
context: 'Type annotation',
|
|
373
|
+
possibleCause: 'May hide type errors that would be caught at compile time',
|
|
374
|
+
reproducibility: 'always',
|
|
375
|
+
suggestion: 'Replace any with specific type or unknown',
|
|
376
|
+
detectedAt: new Date().toISOString(),
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
// Type assertion misuse
|
|
380
|
+
const assertionPattern = /as\s+\w+(?:\[\])?\s*(?![\w<])/g;
|
|
381
|
+
while ((match = assertionPattern.exec(content)) !== null) {
|
|
382
|
+
// This is informational only
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
return issues;
|
|
386
|
+
}
|
|
387
|
+
function detectAdvancedLogicErrors(filePath, content, platform) {
|
|
388
|
+
const issues = [];
|
|
389
|
+
const lines = content.split('\n');
|
|
390
|
+
// Check for infinite loops
|
|
391
|
+
const infiniteLoopPattern = /while\s*\(\s*true\s*\)|\bfor\s*\(\s*;\s*;\s*\)/g;
|
|
392
|
+
let match;
|
|
393
|
+
while ((match = infiniteLoopPattern.exec(content)) !== null) {
|
|
394
|
+
const lineNum = content.substring(0, match.index).split('\n').length;
|
|
395
|
+
const afterMatch = content.substring(match.index, match.index + 200);
|
|
396
|
+
if (!afterMatch.includes('break') && !afterMatch.includes('return')) {
|
|
397
|
+
issues.push({
|
|
398
|
+
id: (0, uuid_1.v4)(),
|
|
399
|
+
type: 'state_inconsistency',
|
|
400
|
+
severity: 'critical',
|
|
401
|
+
title: 'Potential infinite loop',
|
|
402
|
+
description: 'Loop without apparent exit condition',
|
|
403
|
+
file: filePath,
|
|
404
|
+
line: lineNum,
|
|
405
|
+
code: lines[lineNum - 1]?.trim(),
|
|
406
|
+
context: 'Loop control',
|
|
407
|
+
possibleCause: 'Loop may never terminate',
|
|
408
|
+
reproducibility: 'always',
|
|
409
|
+
suggestion: 'Add break condition or refactor loop',
|
|
410
|
+
detectedAt: new Date().toISOString(),
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
// Check for dead code after return
|
|
415
|
+
const deadCodePattern = /return[^;]*;\s*\n\s*[a-zA-Z]/g;
|
|
416
|
+
while ((match = deadCodePattern.exec(content)) !== null) {
|
|
417
|
+
const lineNum = content.substring(0, match.index).split('\n').length;
|
|
418
|
+
issues.push({
|
|
419
|
+
id: (0, uuid_1.v4)(),
|
|
420
|
+
type: 'state_inconsistency',
|
|
421
|
+
severity: 'low',
|
|
422
|
+
title: 'Dead code after return',
|
|
423
|
+
description: 'Code after return statement is unreachable',
|
|
424
|
+
file: filePath,
|
|
425
|
+
line: lineNum + 1,
|
|
426
|
+
context: 'Unreachable code',
|
|
427
|
+
possibleCause: 'Code after return will never execute',
|
|
428
|
+
reproducibility: 'always',
|
|
429
|
+
suggestion: 'Remove unreachable code',
|
|
430
|
+
detectedAt: new Date().toISOString(),
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
return issues;
|
|
434
|
+
}
|
|
435
|
+
function getExtensions(platform) {
|
|
436
|
+
switch (platform) {
|
|
437
|
+
case 'ios': return ['.swift'];
|
|
438
|
+
case 'android': return ['.kt', '.java'];
|
|
439
|
+
case 'flutter': return ['.dart'];
|
|
440
|
+
case 'react-native':
|
|
441
|
+
case 'web': return ['.tsx', '.ts', '.jsx', '.js'];
|
|
442
|
+
default: return ['.ts', '.js'];
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
function generateRecommendations(issues, appStructure) {
|
|
446
|
+
const recommendations = [];
|
|
447
|
+
const issueTypes = new Set(issues.map(i => i.type));
|
|
448
|
+
if (issueTypes.has('race_condition')) {
|
|
449
|
+
recommendations.push('Implement proper async/await patterns with cancellation support');
|
|
450
|
+
recommendations.push('Use React useEffect cleanup or AbortController for async operations');
|
|
451
|
+
}
|
|
452
|
+
if (issueTypes.has('state_inconsistency')) {
|
|
453
|
+
recommendations.push('Consider using state machines for complex state logic');
|
|
454
|
+
recommendations.push('Implement proper error boundaries and state recovery');
|
|
455
|
+
}
|
|
456
|
+
if (issueTypes.has('null_reference')) {
|
|
457
|
+
recommendations.push('Enable strict null checks in TypeScript/Swift/Kotlin');
|
|
458
|
+
recommendations.push('Use optional chaining and nullish coalescing operators');
|
|
459
|
+
}
|
|
460
|
+
if (issueTypes.has('type_mismatch')) {
|
|
461
|
+
recommendations.push('Avoid using any type - prefer unknown or specific types');
|
|
462
|
+
recommendations.push('Enable stricter TypeScript compiler options');
|
|
463
|
+
}
|
|
464
|
+
if (issues.filter(i => i.severity === 'critical' || i.severity === 'high').length > 5) {
|
|
465
|
+
recommendations.push('Consider code review focused on async patterns and state management');
|
|
466
|
+
}
|
|
467
|
+
return recommendations;
|
|
468
|
+
}
|
|
469
|
+
exports.default = detectLogicErrors;
|
|
470
|
+
//# sourceMappingURL=detectLogicErrors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detectLogicErrors.js","sourceRoot":"","sources":["../../../src/tools/detection/detectLogicErrors.ts"],"names":[],"mappings":";AAAA,+CAA+C;AAC/C,2BAA2B;AAC3B,+CAA+C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6B/C,8CA8DC;AAzFD,+BAAoC;AACpC,uCAAyB;AAOzB,6DAAwD;AACxD,qDAAoD;AAkBpD,SAAgB,iBAAiB,CAAC,MAA+B;IAC/D,MAAM,EACJ,YAAY,EACZ,aAAa,GAAG,QAAQ,EACxB,UAAU,GAAG,CAAC,KAAK,CAAC,GACrB,GAAG,MAAM,CAAC;IAEX,MAAM,MAAM,GAAqB,EAAE,CAAC;IACpC,MAAM,UAAU,GAAG,aAAa,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IACxD,MAAM,KAAK,GAAG,IAAA,2BAAW,EAAC,YAAY,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IAEhE,MAAM,cAAc,GAAG,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAElD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YAE/C,IAAI,cAAc,IAAI,UAAU,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC;gBAC5D,MAAM,CAAC,IAAI,CAAC,GAAG,oBAAoB,CAAC,IAAI,EAAE,OAAO,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC;YAC7E,CAAC;YAED,IAAI,cAAc,IAAI,UAAU,CAAC,QAAQ,CAAC,qBAAqB,CAAC,EAAE,CAAC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AI,CAAC,yDAAyD,CAAC,CAAC;QAChF,eAAe,CAAC,IAAI,CAAC,6CAA6C,CAAC,CAAC;IACtE,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,UAAU,IAAI,CAAC,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtF,eAAe,CAAC,IAAI,CAAC,qEAAqE,CAAC,CAAC;IAC9F,CAAC;IAED,OAAO,eAAe,CAAC;AACzB,CAAC;AAED,kBAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { MemoryLeakInfo, AppStructure } from '../../types.js';
|
|
2
|
+
interface DetectMemoryLeaksParams {
|
|
3
|
+
appStructure: AppStructure;
|
|
4
|
+
analysisType?: 'static' | 'dynamic' | 'both';
|
|
5
|
+
thresholds?: {
|
|
6
|
+
minLeakSizeMB?: number;
|
|
7
|
+
maxRetainCount?: number;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
interface DetectMemoryLeaksResult {
|
|
11
|
+
issues: MemoryLeakInfo[];
|
|
12
|
+
summary: {
|
|
13
|
+
totalIssues: number;
|
|
14
|
+
critical: number;
|
|
15
|
+
high: number;
|
|
16
|
+
medium: number;
|
|
17
|
+
low: number;
|
|
18
|
+
};
|
|
19
|
+
recommendations: string[];
|
|
20
|
+
}
|
|
21
|
+
export declare function detectMemoryLeaks(params: DetectMemoryLeaksParams): DetectMemoryLeaksResult;
|
|
22
|
+
export default detectMemoryLeaks;
|
|
23
|
+
//# sourceMappingURL=detectMemoryLeaks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detectMemoryLeaks.d.ts","sourceRoot":"","sources":["../../../src/tools/detection/detectMemoryLeaks.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,cAAc,EAEd,YAAY,EAEb,MAAM,gBAAgB,CAAC;AAIxB,UAAU,uBAAuB;IAC/B,YAAY,EAAE,YAAY,CAAC;IAC3B,YAAY,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAC;IAC7C,UAAU,CAAC,EAAE;QACX,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;CACH;AAED,UAAU,uBAAuB;IAC/B,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,OAAO,EAAE;QACP,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;QACf,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;IACF,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,uBAAuB,GAAG,uBAAuB,CAsC1F;AAwaD,eAAe,iBAAiB,CAAC"}
|