coverme-scanner 1.0.9 → 1.0.11
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/dist/prompts/quality-analyzer.md +239 -43
- package/dist/report/index.d.ts.map +1 -1
- package/dist/report/index.js +23 -4
- package/dist/report/index.js.map +1 -1
- package/package.json +1 -1
- package/src/prompts/quality-analyzer.md +239 -43
- package/src/report/index.ts +26 -5
|
@@ -9,7 +9,173 @@ You will receive PROJECT CONTEXT from the Context Discovery agent. Use it to und
|
|
|
9
9
|
- Architecture patterns in use
|
|
10
10
|
- Existing abstractions and utilities
|
|
11
11
|
|
|
12
|
-
##
|
|
12
|
+
## CRITICAL: Active Detection Strategies
|
|
13
|
+
|
|
14
|
+
### Strategy 1: Find Dead Code (Orphan Detection)
|
|
15
|
+
|
|
16
|
+
**Step 1: Build the call graph mentally**
|
|
17
|
+
- Identify all entry points: routes, exports, event handlers, CLI commands
|
|
18
|
+
- Trace what each entry point calls
|
|
19
|
+
- Anything NOT reachable from entry points is dead code
|
|
20
|
+
|
|
21
|
+
**Step 2: Search for orphaned exports**
|
|
22
|
+
```bash
|
|
23
|
+
# Find all exports
|
|
24
|
+
grep -r "export\s" --include="*.ts" --include="*.js"
|
|
25
|
+
|
|
26
|
+
# For each export, verify it's imported somewhere
|
|
27
|
+
grep -r "import.*{.*ExportName.*}" --include="*.ts" --include="*.js"
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**Step 3: Check for disconnected files**
|
|
31
|
+
- Files that export but are never imported
|
|
32
|
+
- Components that exist but aren't used in any route/page
|
|
33
|
+
- Utility functions that have no callers
|
|
34
|
+
- API endpoints with no frontend calls
|
|
35
|
+
|
|
36
|
+
**Red flags for dead code:**
|
|
37
|
+
- Functions with 0 callers (check with: where is this function called?)
|
|
38
|
+
- Files not imported anywhere
|
|
39
|
+
- Routes not linked from UI
|
|
40
|
+
- Event handlers for events never emitted
|
|
41
|
+
- Feature flags that are always false
|
|
42
|
+
- Code behind `if (false)` or `if (0)`
|
|
43
|
+
|
|
44
|
+
### Strategy 2: Find Duplicate Code
|
|
45
|
+
|
|
46
|
+
**Step 1: Look for similar function names**
|
|
47
|
+
```bash
|
|
48
|
+
# Functions with similar names often do similar things
|
|
49
|
+
grep -r "function validate" --include="*.ts"
|
|
50
|
+
grep -r "function format" --include="*.ts"
|
|
51
|
+
grep -r "function parse" --include="*.ts"
|
|
52
|
+
grep -r "function handle" --include="*.ts"
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**Step 2: Look for repeated patterns**
|
|
56
|
+
- Same regex appearing in multiple files
|
|
57
|
+
- Same error handling pattern copy-pasted
|
|
58
|
+
- Same API call structure repeated
|
|
59
|
+
- Same validation logic in multiple places
|
|
60
|
+
- Same date/string formatting code
|
|
61
|
+
|
|
62
|
+
**Step 3: Compare similar files**
|
|
63
|
+
- Controllers that handle similar resources
|
|
64
|
+
- Components that render similar UI
|
|
65
|
+
- Services that call similar APIs
|
|
66
|
+
|
|
67
|
+
**Report duplicates with ALL locations:**
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"locations": [
|
|
71
|
+
{"file": "src/a.ts", "line": 10},
|
|
72
|
+
{"file": "src/b.ts", "line": 25},
|
|
73
|
+
{"file": "src/c.ts", "line": 42}
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Strategy 3: Find Silent Failures (Fallback שקט)
|
|
79
|
+
|
|
80
|
+
**This is CRITICAL - silent failures hide bugs!**
|
|
81
|
+
|
|
82
|
+
**Pattern 1: Empty catch blocks**
|
|
83
|
+
```javascript
|
|
84
|
+
// BAD - silent failure
|
|
85
|
+
try {
|
|
86
|
+
await doSomething();
|
|
87
|
+
} catch (e) {
|
|
88
|
+
// nothing here - BUG HIDER!
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**Pattern 2: Catch with only console.log**
|
|
93
|
+
```javascript
|
|
94
|
+
// BAD - logs but continues as if success
|
|
95
|
+
try {
|
|
96
|
+
await saveToDatabase();
|
|
97
|
+
} catch (e) {
|
|
98
|
+
console.log(e); // No rethrow, no return, continues execution!
|
|
99
|
+
}
|
|
100
|
+
// Code here runs even on failure
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
**Pattern 3: Default values hiding errors**
|
|
104
|
+
```javascript
|
|
105
|
+
// BAD - returns empty instead of failing
|
|
106
|
+
function getUsers() {
|
|
107
|
+
try {
|
|
108
|
+
return fetchUsers();
|
|
109
|
+
} catch {
|
|
110
|
+
return []; // Silent! Caller thinks there are 0 users
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
**Pattern 4: Optional chaining abuse**
|
|
116
|
+
```javascript
|
|
117
|
+
// Suspicious - why would this be undefined?
|
|
118
|
+
const name = user?.profile?.name ?? 'Unknown';
|
|
119
|
+
// If user should always exist, this hides a bug
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**Pattern 5: || and ?? hiding errors**
|
|
123
|
+
```javascript
|
|
124
|
+
// BAD - error becomes empty string
|
|
125
|
+
const data = riskyOperation() || '';
|
|
126
|
+
const config = parseConfig() ?? {};
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**Pattern 6: .catch() with no action**
|
|
130
|
+
```javascript
|
|
131
|
+
// BAD
|
|
132
|
+
fetchData().catch(() => {});
|
|
133
|
+
promise.catch(console.error); // logs but doesn't handle
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
**Search commands:**
|
|
137
|
+
```bash
|
|
138
|
+
# Empty catch
|
|
139
|
+
grep -r "catch.*{[\s]*}" --include="*.ts" --include="*.js"
|
|
140
|
+
|
|
141
|
+
# Catch with only console
|
|
142
|
+
grep -r "catch.*console\.(log|error)" --include="*.ts"
|
|
143
|
+
|
|
144
|
+
# Silent fallbacks
|
|
145
|
+
grep -r "catch.*return \[\]" --include="*.ts"
|
|
146
|
+
grep -r "catch.*return {}" --include="*.ts"
|
|
147
|
+
grep -r "catch.*return null" --include="*.ts"
|
|
148
|
+
grep -r "catch.*return ''" --include="*.ts"
|
|
149
|
+
|
|
150
|
+
# Empty .catch()
|
|
151
|
+
grep -r "\.catch\(\s*\(\)\s*=>" --include="*.ts"
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Strategy 4: Find Disconnected Code
|
|
155
|
+
|
|
156
|
+
**Code that exists but isn't wired up:**
|
|
157
|
+
|
|
158
|
+
1. **React components not in routes**
|
|
159
|
+
- Check every component in /components
|
|
160
|
+
- Verify it's used in a page or another component
|
|
161
|
+
|
|
162
|
+
2. **API endpoints not called**
|
|
163
|
+
- List all routes
|
|
164
|
+
- Search frontend for each endpoint URL
|
|
165
|
+
|
|
166
|
+
3. **Event handlers not connected**
|
|
167
|
+
- onClick handlers defined but not attached
|
|
168
|
+
- Event listeners for events never emitted
|
|
169
|
+
|
|
170
|
+
4. **Config options not used**
|
|
171
|
+
- Config keys defined but never read
|
|
172
|
+
- Feature flags that are never checked
|
|
173
|
+
|
|
174
|
+
5. **Database fields not used**
|
|
175
|
+
- Schema fields with no queries
|
|
176
|
+
- Migrations that add columns never used
|
|
177
|
+
|
|
178
|
+
## Standard Quality Checks
|
|
13
179
|
|
|
14
180
|
### 1. DRY Violations (Don't Repeat Yourself)
|
|
15
181
|
- [ ] Duplicated code blocks (>10 lines similar)
|
|
@@ -18,15 +184,6 @@ You will receive PROJECT CONTEXT from the Context Discovery agent. Use it to und
|
|
|
18
184
|
- [ ] Repeated patterns that should be abstracted
|
|
19
185
|
- [ ] Duplicated constants/magic numbers
|
|
20
186
|
|
|
21
|
-
**How to find:**
|
|
22
|
-
```bash
|
|
23
|
-
# Look for similar function signatures
|
|
24
|
-
grep -r "function\|const.*=.*=>" --include="*.js" --include="*.ts" | sort | uniq -d
|
|
25
|
-
|
|
26
|
-
# Look for repeated patterns
|
|
27
|
-
# Use your judgment when reading code
|
|
28
|
-
```
|
|
29
|
-
|
|
30
187
|
### 2. Complexity Issues
|
|
31
188
|
- [ ] Functions >50 lines
|
|
32
189
|
- [ ] Cyclomatic complexity >10
|
|
@@ -36,13 +193,15 @@ grep -r "function\|const.*=.*=>" --include="*.js" --include="*.ts" | sort | uniq
|
|
|
36
193
|
- [ ] Files with >500 lines
|
|
37
194
|
|
|
38
195
|
### 3. Dead Code
|
|
39
|
-
- [ ] Unused functions
|
|
196
|
+
- [ ] Unused functions (no callers)
|
|
40
197
|
- [ ] Unused variables
|
|
41
198
|
- [ ] Unreachable code paths
|
|
42
|
-
- [ ] Commented-out code blocks
|
|
199
|
+
- [ ] Commented-out code blocks (>3 lines)
|
|
43
200
|
- [ ] Unused imports
|
|
44
201
|
- [ ] Unused dependencies in package.json
|
|
45
202
|
- [ ] Deprecated code still present
|
|
203
|
+
- [ ] Feature flags always false
|
|
204
|
+
- [ ] Exports with no imports
|
|
46
205
|
|
|
47
206
|
### 4. Anti-Patterns
|
|
48
207
|
- [ ] God objects (classes doing too much)
|
|
@@ -54,14 +213,16 @@ grep -r "function\|const.*=.*=>" --include="*.js" --include="*.ts" | sort | uniq
|
|
|
54
213
|
- [ ] Magic numbers/strings
|
|
55
214
|
- [ ] Stringly-typed code
|
|
56
215
|
|
|
57
|
-
### 5. Error Handling
|
|
58
|
-
- [ ] Empty catch blocks
|
|
59
|
-
- [ ] Swallowed errors (catch without
|
|
216
|
+
### 5. Error Handling Issues (FOCUS HERE!)
|
|
217
|
+
- [ ] Empty catch blocks (**CRITICAL**)
|
|
218
|
+
- [ ] Swallowed errors (catch without rethrow)
|
|
219
|
+
- [ ] Silent fallbacks (return default on error)
|
|
60
220
|
- [ ] Missing error handling on async operations
|
|
61
221
|
- [ ] Inconsistent error formats
|
|
62
222
|
- [ ] No error boundaries in React
|
|
63
223
|
- [ ] No try-catch around JSON.parse
|
|
64
|
-
- [ ]
|
|
224
|
+
- [ ] .catch() with no meaningful action
|
|
225
|
+
- [ ] Errors logged but not propagated
|
|
65
226
|
|
|
66
227
|
### 6. Type Safety (TypeScript)
|
|
67
228
|
- [ ] `any` type usage
|
|
@@ -106,45 +267,80 @@ For EACH finding, output:
|
|
|
106
267
|
```json
|
|
107
268
|
{
|
|
108
269
|
"id": "QUAL-001",
|
|
109
|
-
"title": "
|
|
270
|
+
"title": "Silent Error Handling in Payment Service",
|
|
271
|
+
"severity": "critical",
|
|
272
|
+
"category": "quality",
|
|
273
|
+
"subcategory": "silent_failure",
|
|
274
|
+
"file": "src/services/paymentService.ts",
|
|
275
|
+
"line": 45,
|
|
276
|
+
"endLine": 52,
|
|
277
|
+
"code": "try {\n await chargeCard(amount);\n} catch (e) {\n console.error(e);\n // continues to \"success\" response!\n}",
|
|
278
|
+
"description": "Payment errors are caught and logged but execution continues as if payment succeeded. Customer could receive product without paying.",
|
|
279
|
+
"impact": "Financial loss. Customers charged $0 for orders. Silent data corruption.",
|
|
280
|
+
"recommendation": "Rethrow the error or return error response:\n\n```typescript\ntry {\n await chargeCard(amount);\n} catch (e) {\n logger.error('Payment failed', { error: e, orderId });\n throw new PaymentError('Payment processing failed');\n}\n```",
|
|
281
|
+
"effort": "low"
|
|
282
|
+
}
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### Dead Code Finding Example
|
|
286
|
+
```json
|
|
287
|
+
{
|
|
288
|
+
"id": "QUAL-015",
|
|
289
|
+
"title": "Orphaned Component: UserAvatar",
|
|
290
|
+
"severity": "medium",
|
|
291
|
+
"category": "quality",
|
|
292
|
+
"subcategory": "dead_code",
|
|
293
|
+
"file": "src/components/UserAvatar.tsx",
|
|
294
|
+
"line": 1,
|
|
295
|
+
"endLine": 45,
|
|
296
|
+
"description": "UserAvatar component is defined but never imported or used anywhere in the codebase. It appears to be leftover from a removed feature.",
|
|
297
|
+
"evidence": [
|
|
298
|
+
"grep for 'UserAvatar' returns only the definition file",
|
|
299
|
+
"No imports found in any other file",
|
|
300
|
+
"Component not in any route or page"
|
|
301
|
+
],
|
|
302
|
+
"recommendation": "Delete the file or integrate it if it was meant to be used.",
|
|
303
|
+
"effort": "low"
|
|
304
|
+
}
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
### Duplicate Code Finding Example
|
|
308
|
+
```json
|
|
309
|
+
{
|
|
310
|
+
"id": "QUAL-022",
|
|
311
|
+
"title": "Duplicated Date Formatting Logic",
|
|
110
312
|
"severity": "medium",
|
|
111
313
|
"category": "quality",
|
|
112
314
|
"subcategory": "dry_violation",
|
|
113
|
-
"file": "src/
|
|
114
|
-
"line":
|
|
115
|
-
"endLine": 55,
|
|
315
|
+
"file": "src/utils/formatters.ts",
|
|
316
|
+
"line": 12,
|
|
116
317
|
"additionalLocations": [
|
|
117
|
-
{"file": "src/
|
|
118
|
-
{"file": "src/
|
|
318
|
+
{"file": "src/components/OrderList.tsx", "line": 34},
|
|
319
|
+
{"file": "src/components/InvoiceTable.tsx", "line": 89},
|
|
320
|
+
{"file": "src/pages/Dashboard.tsx", "line": 156}
|
|
119
321
|
],
|
|
120
|
-
"code": "const
|
|
121
|
-
"description": "
|
|
122
|
-
"
|
|
123
|
-
"
|
|
124
|
-
"effort": "low"
|
|
125
|
-
"linesAffected": 33,
|
|
126
|
-
"evidence": [
|
|
127
|
-
"Found in userService.js:45-55",
|
|
128
|
-
"Found in authController.js:78-88",
|
|
129
|
-
"Found in validators.js:12-22"
|
|
130
|
-
]
|
|
322
|
+
"code": "const formatted = `${date.getMonth()+1}/${date.getDate()}/${date.getFullYear()}`",
|
|
323
|
+
"description": "Same date formatting pattern appears in 4 different files. Any format change requires 4 updates.",
|
|
324
|
+
"recommendation": "Extract to shared utility:\n\n```typescript\n// src/utils/date.ts\nexport function formatDate(date: Date): string {\n return new Intl.DateTimeFormat('en-US').format(date);\n}\n```",
|
|
325
|
+
"linesAffected": 4,
|
|
326
|
+
"effort": "low"
|
|
131
327
|
}
|
|
132
328
|
```
|
|
133
329
|
|
|
134
330
|
## Severity Guidelines
|
|
135
331
|
|
|
136
|
-
- **Critical**:
|
|
137
|
-
- **High**: Significant maintainability risk (
|
|
138
|
-
- **Medium**: Should be fixed (
|
|
139
|
-
- **Low**: Nice to fix (
|
|
140
|
-
- **Info**: Suggestions (
|
|
332
|
+
- **Critical**: Silent failures that hide bugs, especially in payments/auth/data
|
|
333
|
+
- **High**: Significant maintainability risk (large dead code, major duplication)
|
|
334
|
+
- **Medium**: Should be fixed (DRY violations, missing types, smaller dead code)
|
|
335
|
+
- **Low**: Nice to fix (naming issues, minor dead code, small duplication)
|
|
336
|
+
- **Info**: Suggestions (could be more idiomatic)
|
|
141
337
|
|
|
142
338
|
## Rules
|
|
143
339
|
|
|
144
|
-
1. **
|
|
145
|
-
2. **
|
|
146
|
-
3. **
|
|
147
|
-
4. **
|
|
340
|
+
1. **Actively search** - Don't just read, grep for patterns
|
|
341
|
+
2. **Verify dead code** - Confirm it's really not called anywhere
|
|
342
|
+
3. **Find ALL duplicates** - List every location, not just the first two
|
|
343
|
+
4. **Silent failures are CRITICAL** - Empty catch blocks hide production bugs
|
|
148
344
|
5. **Give fixes** - Show exactly how to refactor
|
|
149
345
|
|
|
150
|
-
START SCANNING NOW.
|
|
346
|
+
START SCANNING NOW. Be aggressive about finding dead code and silent failures.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/report/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/report/index.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAC;IAC1D,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEpF,MAAM,WAAW,UAAU;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,cAAc,EAAE,aAAa,EAAE,CAAC;IAChC,oBAAoB,EAAE,mBAAmB,EAAE,CAAC;IAC5C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AA8HD,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAiRvD;AAED,wBAAsB,WAAW,CAAC,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA4BvF;AAED,wBAAsB,cAAc,CAClC,QAAQ,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,MAAM,EACnB,MAAM,GAAE,KAAK,GAAG,MAAc,GAC7B,OAAO,CAAC,IAAI,CAAC,CAgCf"}
|
package/dist/report/index.js
CHANGED
|
@@ -41,6 +41,7 @@ exports.generatePdf = generatePdf;
|
|
|
41
41
|
exports.generateReport = generateReport;
|
|
42
42
|
const fs = __importStar(require("fs"));
|
|
43
43
|
const puppeteer_1 = __importDefault(require("puppeteer"));
|
|
44
|
+
const generator_js_1 = require("./generator.js");
|
|
44
45
|
function escapeHtml(text) {
|
|
45
46
|
if (!text)
|
|
46
47
|
return '';
|
|
@@ -453,13 +454,31 @@ async function generateReport(jsonPath, outputPath, format = 'pdf') {
|
|
|
453
454
|
const reportData = JSON.parse(fs.readFileSync(jsonPath, 'utf-8'));
|
|
454
455
|
const ext = format === 'pdf' ? '.pdf' : '.html';
|
|
455
456
|
const finalPath = outputPath || jsonPath.replace('.json', ext);
|
|
457
|
+
// Convert old ScanReport format to new ScanResult format if needed
|
|
458
|
+
const findings = reportData.findings || [];
|
|
459
|
+
const scanResult = {
|
|
460
|
+
projectName: reportData.projectName,
|
|
461
|
+
scanDate: reportData.scanDate,
|
|
462
|
+
filesScanned: reportData.filesScanned || 0,
|
|
463
|
+
agentsUsed: reportData.agentsUsed || [],
|
|
464
|
+
summary: reportData.summary || {
|
|
465
|
+
total: findings.length,
|
|
466
|
+
critical: findings.filter((f) => f.severity === 'critical').length,
|
|
467
|
+
high: findings.filter((f) => f.severity === 'high').length,
|
|
468
|
+
medium: findings.filter((f) => f.severity === 'medium').length,
|
|
469
|
+
low: findings.filter((f) => f.severity === 'low').length,
|
|
470
|
+
info: findings.filter((f) => f.severity === 'info').length,
|
|
471
|
+
avgConfidence: 0,
|
|
472
|
+
},
|
|
473
|
+
findings,
|
|
474
|
+
positiveObservations: reportData.positiveObservations || [],
|
|
475
|
+
scanDuration: reportData.scanDuration || 0,
|
|
476
|
+
};
|
|
456
477
|
if (format === 'pdf') {
|
|
457
|
-
await
|
|
478
|
+
await (0, generator_js_1.generatePdfReport)(scanResult, finalPath);
|
|
458
479
|
}
|
|
459
480
|
else {
|
|
460
|
-
|
|
461
|
-
fs.writeFileSync(finalPath, html);
|
|
462
|
-
console.log(`HTML generated: ${finalPath}`);
|
|
481
|
+
await (0, generator_js_1.generateHtmlReport)(scanResult, finalPath, reportData.falsePositives || []);
|
|
463
482
|
}
|
|
464
483
|
}
|
|
465
484
|
//# sourceMappingURL=index.js.map
|
package/dist/report/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/report/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/report/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsKA,oCAiRC;AAED,kCA4BC;AAED,wCAoCC;AA3fD,uCAAyB;AAEzB,0DAAkC;AAClC,iDAAwH;AAuCxH,SAAS,UAAU,CAAC,IAAY;IAC9B,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IACrB,OAAO,IAAI;SACR,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;SACvB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAC7B,CAAC;AAED,SAAS,cAAc,CAAC,QAAmB;IACzC,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,UAAU,CAAC,CAAC,MAAM,CAAC;IACxE,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,MAAM,CAAC;IAChE,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,MAAM,CAAC;IACpE,MAAM,GAAG,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAA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U,EAAE,SAAS,CAAC,CAAC;IACpD,CAAC;SAAM,CAAC;QACN,MAAM,IAAA,iCAAqB,EAAC,UAAU,EAAE,SAAS,EAAE,UAAU,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC;IACtF,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -9,7 +9,173 @@ You will receive PROJECT CONTEXT from the Context Discovery agent. Use it to und
|
|
|
9
9
|
- Architecture patterns in use
|
|
10
10
|
- Existing abstractions and utilities
|
|
11
11
|
|
|
12
|
-
##
|
|
12
|
+
## CRITICAL: Active Detection Strategies
|
|
13
|
+
|
|
14
|
+
### Strategy 1: Find Dead Code (Orphan Detection)
|
|
15
|
+
|
|
16
|
+
**Step 1: Build the call graph mentally**
|
|
17
|
+
- Identify all entry points: routes, exports, event handlers, CLI commands
|
|
18
|
+
- Trace what each entry point calls
|
|
19
|
+
- Anything NOT reachable from entry points is dead code
|
|
20
|
+
|
|
21
|
+
**Step 2: Search for orphaned exports**
|
|
22
|
+
```bash
|
|
23
|
+
# Find all exports
|
|
24
|
+
grep -r "export\s" --include="*.ts" --include="*.js"
|
|
25
|
+
|
|
26
|
+
# For each export, verify it's imported somewhere
|
|
27
|
+
grep -r "import.*{.*ExportName.*}" --include="*.ts" --include="*.js"
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**Step 3: Check for disconnected files**
|
|
31
|
+
- Files that export but are never imported
|
|
32
|
+
- Components that exist but aren't used in any route/page
|
|
33
|
+
- Utility functions that have no callers
|
|
34
|
+
- API endpoints with no frontend calls
|
|
35
|
+
|
|
36
|
+
**Red flags for dead code:**
|
|
37
|
+
- Functions with 0 callers (check with: where is this function called?)
|
|
38
|
+
- Files not imported anywhere
|
|
39
|
+
- Routes not linked from UI
|
|
40
|
+
- Event handlers for events never emitted
|
|
41
|
+
- Feature flags that are always false
|
|
42
|
+
- Code behind `if (false)` or `if (0)`
|
|
43
|
+
|
|
44
|
+
### Strategy 2: Find Duplicate Code
|
|
45
|
+
|
|
46
|
+
**Step 1: Look for similar function names**
|
|
47
|
+
```bash
|
|
48
|
+
# Functions with similar names often do similar things
|
|
49
|
+
grep -r "function validate" --include="*.ts"
|
|
50
|
+
grep -r "function format" --include="*.ts"
|
|
51
|
+
grep -r "function parse" --include="*.ts"
|
|
52
|
+
grep -r "function handle" --include="*.ts"
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**Step 2: Look for repeated patterns**
|
|
56
|
+
- Same regex appearing in multiple files
|
|
57
|
+
- Same error handling pattern copy-pasted
|
|
58
|
+
- Same API call structure repeated
|
|
59
|
+
- Same validation logic in multiple places
|
|
60
|
+
- Same date/string formatting code
|
|
61
|
+
|
|
62
|
+
**Step 3: Compare similar files**
|
|
63
|
+
- Controllers that handle similar resources
|
|
64
|
+
- Components that render similar UI
|
|
65
|
+
- Services that call similar APIs
|
|
66
|
+
|
|
67
|
+
**Report duplicates with ALL locations:**
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"locations": [
|
|
71
|
+
{"file": "src/a.ts", "line": 10},
|
|
72
|
+
{"file": "src/b.ts", "line": 25},
|
|
73
|
+
{"file": "src/c.ts", "line": 42}
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Strategy 3: Find Silent Failures (Fallback שקט)
|
|
79
|
+
|
|
80
|
+
**This is CRITICAL - silent failures hide bugs!**
|
|
81
|
+
|
|
82
|
+
**Pattern 1: Empty catch blocks**
|
|
83
|
+
```javascript
|
|
84
|
+
// BAD - silent failure
|
|
85
|
+
try {
|
|
86
|
+
await doSomething();
|
|
87
|
+
} catch (e) {
|
|
88
|
+
// nothing here - BUG HIDER!
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**Pattern 2: Catch with only console.log**
|
|
93
|
+
```javascript
|
|
94
|
+
// BAD - logs but continues as if success
|
|
95
|
+
try {
|
|
96
|
+
await saveToDatabase();
|
|
97
|
+
} catch (e) {
|
|
98
|
+
console.log(e); // No rethrow, no return, continues execution!
|
|
99
|
+
}
|
|
100
|
+
// Code here runs even on failure
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
**Pattern 3: Default values hiding errors**
|
|
104
|
+
```javascript
|
|
105
|
+
// BAD - returns empty instead of failing
|
|
106
|
+
function getUsers() {
|
|
107
|
+
try {
|
|
108
|
+
return fetchUsers();
|
|
109
|
+
} catch {
|
|
110
|
+
return []; // Silent! Caller thinks there are 0 users
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
**Pattern 4: Optional chaining abuse**
|
|
116
|
+
```javascript
|
|
117
|
+
// Suspicious - why would this be undefined?
|
|
118
|
+
const name = user?.profile?.name ?? 'Unknown';
|
|
119
|
+
// If user should always exist, this hides a bug
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**Pattern 5: || and ?? hiding errors**
|
|
123
|
+
```javascript
|
|
124
|
+
// BAD - error becomes empty string
|
|
125
|
+
const data = riskyOperation() || '';
|
|
126
|
+
const config = parseConfig() ?? {};
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**Pattern 6: .catch() with no action**
|
|
130
|
+
```javascript
|
|
131
|
+
// BAD
|
|
132
|
+
fetchData().catch(() => {});
|
|
133
|
+
promise.catch(console.error); // logs but doesn't handle
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
**Search commands:**
|
|
137
|
+
```bash
|
|
138
|
+
# Empty catch
|
|
139
|
+
grep -r "catch.*{[\s]*}" --include="*.ts" --include="*.js"
|
|
140
|
+
|
|
141
|
+
# Catch with only console
|
|
142
|
+
grep -r "catch.*console\.(log|error)" --include="*.ts"
|
|
143
|
+
|
|
144
|
+
# Silent fallbacks
|
|
145
|
+
grep -r "catch.*return \[\]" --include="*.ts"
|
|
146
|
+
grep -r "catch.*return {}" --include="*.ts"
|
|
147
|
+
grep -r "catch.*return null" --include="*.ts"
|
|
148
|
+
grep -r "catch.*return ''" --include="*.ts"
|
|
149
|
+
|
|
150
|
+
# Empty .catch()
|
|
151
|
+
grep -r "\.catch\(\s*\(\)\s*=>" --include="*.ts"
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Strategy 4: Find Disconnected Code
|
|
155
|
+
|
|
156
|
+
**Code that exists but isn't wired up:**
|
|
157
|
+
|
|
158
|
+
1. **React components not in routes**
|
|
159
|
+
- Check every component in /components
|
|
160
|
+
- Verify it's used in a page or another component
|
|
161
|
+
|
|
162
|
+
2. **API endpoints not called**
|
|
163
|
+
- List all routes
|
|
164
|
+
- Search frontend for each endpoint URL
|
|
165
|
+
|
|
166
|
+
3. **Event handlers not connected**
|
|
167
|
+
- onClick handlers defined but not attached
|
|
168
|
+
- Event listeners for events never emitted
|
|
169
|
+
|
|
170
|
+
4. **Config options not used**
|
|
171
|
+
- Config keys defined but never read
|
|
172
|
+
- Feature flags that are never checked
|
|
173
|
+
|
|
174
|
+
5. **Database fields not used**
|
|
175
|
+
- Schema fields with no queries
|
|
176
|
+
- Migrations that add columns never used
|
|
177
|
+
|
|
178
|
+
## Standard Quality Checks
|
|
13
179
|
|
|
14
180
|
### 1. DRY Violations (Don't Repeat Yourself)
|
|
15
181
|
- [ ] Duplicated code blocks (>10 lines similar)
|
|
@@ -18,15 +184,6 @@ You will receive PROJECT CONTEXT from the Context Discovery agent. Use it to und
|
|
|
18
184
|
- [ ] Repeated patterns that should be abstracted
|
|
19
185
|
- [ ] Duplicated constants/magic numbers
|
|
20
186
|
|
|
21
|
-
**How to find:**
|
|
22
|
-
```bash
|
|
23
|
-
# Look for similar function signatures
|
|
24
|
-
grep -r "function\|const.*=.*=>" --include="*.js" --include="*.ts" | sort | uniq -d
|
|
25
|
-
|
|
26
|
-
# Look for repeated patterns
|
|
27
|
-
# Use your judgment when reading code
|
|
28
|
-
```
|
|
29
|
-
|
|
30
187
|
### 2. Complexity Issues
|
|
31
188
|
- [ ] Functions >50 lines
|
|
32
189
|
- [ ] Cyclomatic complexity >10
|
|
@@ -36,13 +193,15 @@ grep -r "function\|const.*=.*=>" --include="*.js" --include="*.ts" | sort | uniq
|
|
|
36
193
|
- [ ] Files with >500 lines
|
|
37
194
|
|
|
38
195
|
### 3. Dead Code
|
|
39
|
-
- [ ] Unused functions
|
|
196
|
+
- [ ] Unused functions (no callers)
|
|
40
197
|
- [ ] Unused variables
|
|
41
198
|
- [ ] Unreachable code paths
|
|
42
|
-
- [ ] Commented-out code blocks
|
|
199
|
+
- [ ] Commented-out code blocks (>3 lines)
|
|
43
200
|
- [ ] Unused imports
|
|
44
201
|
- [ ] Unused dependencies in package.json
|
|
45
202
|
- [ ] Deprecated code still present
|
|
203
|
+
- [ ] Feature flags always false
|
|
204
|
+
- [ ] Exports with no imports
|
|
46
205
|
|
|
47
206
|
### 4. Anti-Patterns
|
|
48
207
|
- [ ] God objects (classes doing too much)
|
|
@@ -54,14 +213,16 @@ grep -r "function\|const.*=.*=>" --include="*.js" --include="*.ts" | sort | uniq
|
|
|
54
213
|
- [ ] Magic numbers/strings
|
|
55
214
|
- [ ] Stringly-typed code
|
|
56
215
|
|
|
57
|
-
### 5. Error Handling
|
|
58
|
-
- [ ] Empty catch blocks
|
|
59
|
-
- [ ] Swallowed errors (catch without
|
|
216
|
+
### 5. Error Handling Issues (FOCUS HERE!)
|
|
217
|
+
- [ ] Empty catch blocks (**CRITICAL**)
|
|
218
|
+
- [ ] Swallowed errors (catch without rethrow)
|
|
219
|
+
- [ ] Silent fallbacks (return default on error)
|
|
60
220
|
- [ ] Missing error handling on async operations
|
|
61
221
|
- [ ] Inconsistent error formats
|
|
62
222
|
- [ ] No error boundaries in React
|
|
63
223
|
- [ ] No try-catch around JSON.parse
|
|
64
|
-
- [ ]
|
|
224
|
+
- [ ] .catch() with no meaningful action
|
|
225
|
+
- [ ] Errors logged but not propagated
|
|
65
226
|
|
|
66
227
|
### 6. Type Safety (TypeScript)
|
|
67
228
|
- [ ] `any` type usage
|
|
@@ -106,45 +267,80 @@ For EACH finding, output:
|
|
|
106
267
|
```json
|
|
107
268
|
{
|
|
108
269
|
"id": "QUAL-001",
|
|
109
|
-
"title": "
|
|
270
|
+
"title": "Silent Error Handling in Payment Service",
|
|
271
|
+
"severity": "critical",
|
|
272
|
+
"category": "quality",
|
|
273
|
+
"subcategory": "silent_failure",
|
|
274
|
+
"file": "src/services/paymentService.ts",
|
|
275
|
+
"line": 45,
|
|
276
|
+
"endLine": 52,
|
|
277
|
+
"code": "try {\n await chargeCard(amount);\n} catch (e) {\n console.error(e);\n // continues to \"success\" response!\n}",
|
|
278
|
+
"description": "Payment errors are caught and logged but execution continues as if payment succeeded. Customer could receive product without paying.",
|
|
279
|
+
"impact": "Financial loss. Customers charged $0 for orders. Silent data corruption.",
|
|
280
|
+
"recommendation": "Rethrow the error or return error response:\n\n```typescript\ntry {\n await chargeCard(amount);\n} catch (e) {\n logger.error('Payment failed', { error: e, orderId });\n throw new PaymentError('Payment processing failed');\n}\n```",
|
|
281
|
+
"effort": "low"
|
|
282
|
+
}
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### Dead Code Finding Example
|
|
286
|
+
```json
|
|
287
|
+
{
|
|
288
|
+
"id": "QUAL-015",
|
|
289
|
+
"title": "Orphaned Component: UserAvatar",
|
|
290
|
+
"severity": "medium",
|
|
291
|
+
"category": "quality",
|
|
292
|
+
"subcategory": "dead_code",
|
|
293
|
+
"file": "src/components/UserAvatar.tsx",
|
|
294
|
+
"line": 1,
|
|
295
|
+
"endLine": 45,
|
|
296
|
+
"description": "UserAvatar component is defined but never imported or used anywhere in the codebase. It appears to be leftover from a removed feature.",
|
|
297
|
+
"evidence": [
|
|
298
|
+
"grep for 'UserAvatar' returns only the definition file",
|
|
299
|
+
"No imports found in any other file",
|
|
300
|
+
"Component not in any route or page"
|
|
301
|
+
],
|
|
302
|
+
"recommendation": "Delete the file or integrate it if it was meant to be used.",
|
|
303
|
+
"effort": "low"
|
|
304
|
+
}
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
### Duplicate Code Finding Example
|
|
308
|
+
```json
|
|
309
|
+
{
|
|
310
|
+
"id": "QUAL-022",
|
|
311
|
+
"title": "Duplicated Date Formatting Logic",
|
|
110
312
|
"severity": "medium",
|
|
111
313
|
"category": "quality",
|
|
112
314
|
"subcategory": "dry_violation",
|
|
113
|
-
"file": "src/
|
|
114
|
-
"line":
|
|
115
|
-
"endLine": 55,
|
|
315
|
+
"file": "src/utils/formatters.ts",
|
|
316
|
+
"line": 12,
|
|
116
317
|
"additionalLocations": [
|
|
117
|
-
{"file": "src/
|
|
118
|
-
{"file": "src/
|
|
318
|
+
{"file": "src/components/OrderList.tsx", "line": 34},
|
|
319
|
+
{"file": "src/components/InvoiceTable.tsx", "line": 89},
|
|
320
|
+
{"file": "src/pages/Dashboard.tsx", "line": 156}
|
|
119
321
|
],
|
|
120
|
-
"code": "const
|
|
121
|
-
"description": "
|
|
122
|
-
"
|
|
123
|
-
"
|
|
124
|
-
"effort": "low"
|
|
125
|
-
"linesAffected": 33,
|
|
126
|
-
"evidence": [
|
|
127
|
-
"Found in userService.js:45-55",
|
|
128
|
-
"Found in authController.js:78-88",
|
|
129
|
-
"Found in validators.js:12-22"
|
|
130
|
-
]
|
|
322
|
+
"code": "const formatted = `${date.getMonth()+1}/${date.getDate()}/${date.getFullYear()}`",
|
|
323
|
+
"description": "Same date formatting pattern appears in 4 different files. Any format change requires 4 updates.",
|
|
324
|
+
"recommendation": "Extract to shared utility:\n\n```typescript\n// src/utils/date.ts\nexport function formatDate(date: Date): string {\n return new Intl.DateTimeFormat('en-US').format(date);\n}\n```",
|
|
325
|
+
"linesAffected": 4,
|
|
326
|
+
"effort": "low"
|
|
131
327
|
}
|
|
132
328
|
```
|
|
133
329
|
|
|
134
330
|
## Severity Guidelines
|
|
135
331
|
|
|
136
|
-
- **Critical**:
|
|
137
|
-
- **High**: Significant maintainability risk (
|
|
138
|
-
- **Medium**: Should be fixed (
|
|
139
|
-
- **Low**: Nice to fix (
|
|
140
|
-
- **Info**: Suggestions (
|
|
332
|
+
- **Critical**: Silent failures that hide bugs, especially in payments/auth/data
|
|
333
|
+
- **High**: Significant maintainability risk (large dead code, major duplication)
|
|
334
|
+
- **Medium**: Should be fixed (DRY violations, missing types, smaller dead code)
|
|
335
|
+
- **Low**: Nice to fix (naming issues, minor dead code, small duplication)
|
|
336
|
+
- **Info**: Suggestions (could be more idiomatic)
|
|
141
337
|
|
|
142
338
|
## Rules
|
|
143
339
|
|
|
144
|
-
1. **
|
|
145
|
-
2. **
|
|
146
|
-
3. **
|
|
147
|
-
4. **
|
|
340
|
+
1. **Actively search** - Don't just read, grep for patterns
|
|
341
|
+
2. **Verify dead code** - Confirm it's really not called anywhere
|
|
342
|
+
3. **Find ALL duplicates** - List every location, not just the first two
|
|
343
|
+
4. **Silent failures are CRITICAL** - Empty catch blocks hide production bugs
|
|
148
344
|
5. **Give fixes** - Show exactly how to refactor
|
|
149
345
|
|
|
150
|
-
START SCANNING NOW.
|
|
346
|
+
START SCANNING NOW. Be aggressive about finding dead code and silent failures.
|
package/src/report/index.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as fs from 'fs';
|
|
2
2
|
import * as path from 'path';
|
|
3
3
|
import puppeteer from 'puppeteer';
|
|
4
|
+
import { generateHtmlReport as generateHtmlReportNew, generatePdfReport as generatePdfReportNew } from './generator.js';
|
|
5
|
+
import type { ScanResult } from '../types.js';
|
|
4
6
|
|
|
5
7
|
export interface Finding {
|
|
6
8
|
id: string;
|
|
@@ -472,16 +474,35 @@ export async function generateReport(
|
|
|
472
474
|
outputPath?: string,
|
|
473
475
|
format: 'pdf' | 'html' = 'pdf'
|
|
474
476
|
): Promise<void> {
|
|
475
|
-
const reportData = JSON.parse(fs.readFileSync(jsonPath, 'utf-8'))
|
|
477
|
+
const reportData = JSON.parse(fs.readFileSync(jsonPath, 'utf-8'));
|
|
476
478
|
|
|
477
479
|
const ext = format === 'pdf' ? '.pdf' : '.html';
|
|
478
480
|
const finalPath = outputPath || jsonPath.replace('.json', ext);
|
|
479
481
|
|
|
482
|
+
// Convert old ScanReport format to new ScanResult format if needed
|
|
483
|
+
const findings = reportData.findings || [];
|
|
484
|
+
const scanResult: ScanResult = {
|
|
485
|
+
projectName: reportData.projectName,
|
|
486
|
+
scanDate: reportData.scanDate,
|
|
487
|
+
filesScanned: reportData.filesScanned || 0,
|
|
488
|
+
agentsUsed: reportData.agentsUsed || [],
|
|
489
|
+
summary: reportData.summary || {
|
|
490
|
+
total: findings.length,
|
|
491
|
+
critical: findings.filter((f: Finding) => f.severity === 'critical').length,
|
|
492
|
+
high: findings.filter((f: Finding) => f.severity === 'high').length,
|
|
493
|
+
medium: findings.filter((f: Finding) => f.severity === 'medium').length,
|
|
494
|
+
low: findings.filter((f: Finding) => f.severity === 'low').length,
|
|
495
|
+
info: findings.filter((f: Finding) => f.severity === 'info').length,
|
|
496
|
+
avgConfidence: 0,
|
|
497
|
+
},
|
|
498
|
+
findings,
|
|
499
|
+
positiveObservations: reportData.positiveObservations || [],
|
|
500
|
+
scanDuration: reportData.scanDuration || 0,
|
|
501
|
+
};
|
|
502
|
+
|
|
480
503
|
if (format === 'pdf') {
|
|
481
|
-
await
|
|
504
|
+
await generatePdfReportNew(scanResult, finalPath);
|
|
482
505
|
} else {
|
|
483
|
-
|
|
484
|
-
fs.writeFileSync(finalPath, html);
|
|
485
|
-
console.log(`HTML generated: ${finalPath}`);
|
|
506
|
+
await generateHtmlReportNew(scanResult, finalPath, reportData.falsePositives || []);
|
|
486
507
|
}
|
|
487
508
|
}
|