roast-my-codebase 1.1.2 → 1.3.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 +38 -3
- package/dist/bundle-OG535XKC.js +9 -0
- package/dist/chunk-4KMMPANT.js +279 -0
- package/dist/index.js +14687 -5143
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -114,12 +114,24 @@ npx roast-my-codebase --markdown-file # Save to .roast-report.md
|
|
|
114
114
|
### Fully Supported
|
|
115
115
|
- **JavaScript** (.js, .jsx, .mjs, .cjs)
|
|
116
116
|
- **TypeScript** (.ts, .tsx)
|
|
117
|
-
- **Python** (.py) — Complexity, type hints, imports
|
|
117
|
+
- **Python** (.py) — Complexity, type hints, imports, docstrings, security, class design
|
|
118
118
|
- **Go** (.go) — Complexity, error handling, lint conventions
|
|
119
119
|
- **Rust** (.rs) — Complexity, unsafe usage, clippy hints
|
|
120
120
|
- **Java** (.java) — Complexity, code smells, naming conventions
|
|
121
121
|
- **C#** (.cs) — Complexity, code smells, async patterns
|
|
122
122
|
|
|
123
|
+
### Framework-Specific Checks
|
|
124
|
+
|
|
125
|
+
| Framework | What's detected |
|
|
126
|
+
|-----------|----------------|
|
|
127
|
+
| **Next.js** | Missing metadata exports, server/client component misuse |
|
|
128
|
+
| **React** | Missing error boundaries |
|
|
129
|
+
| **Vue 3** | Options API in Vue 3, v-for without :key, deep watchers |
|
|
130
|
+
| **Angular** | Missing OnPush strategy, direct DOM manipulation, untyped events |
|
|
131
|
+
| **Svelte** | Reactive side effects, inaccessible buttons |
|
|
132
|
+
| **Express** | Missing error middleware, no rate limiting, sync I/O in routes |
|
|
133
|
+
| **FastAPI** | Missing response_model, sync endpoints, missing status codes |
|
|
134
|
+
|
|
123
135
|
### Language-Specific Checks
|
|
124
136
|
|
|
125
137
|
| Language | Scanners |
|
|
@@ -272,7 +284,12 @@ roast-my-codebase --interactive
|
|
|
272
284
|
- ✅ Remove unused dependencies (`npm uninstall`)
|
|
273
285
|
- ✅ Add issue references to TODO comments
|
|
274
286
|
- ✅ Remove dead exports
|
|
275
|
-
-
|
|
287
|
+
- ✅ Add `'use client'` directive to Next.js components
|
|
288
|
+
- ✅ Add missing metadata export to Next.js pages
|
|
289
|
+
- ✅ Add `.env` files to `.gitignore`
|
|
290
|
+
- ✅ Upgrade `@ts-ignore` to `@ts-expect-error`
|
|
291
|
+
- ✅ Create skeleton test files for untested source files
|
|
292
|
+
- ✅ Add secret files to `.gitignore`
|
|
276
293
|
|
|
277
294
|
**Example session:**
|
|
278
295
|
```
|
|
@@ -296,7 +313,25 @@ Unused dependency `lodash` is installed but never imported
|
|
|
296
313
|
Exit interactive mode
|
|
297
314
|
```
|
|
298
315
|
|
|
299
|
-
###
|
|
316
|
+
### HTML Report
|
|
317
|
+
```bash
|
|
318
|
+
roast-my-codebase --html-file
|
|
319
|
+
```
|
|
320
|
+
- Saves `.roast-report.html` — a beautiful standalone HTML report
|
|
321
|
+
- Dark theme, SVG health gauge, sortable findings table, severity chart
|
|
322
|
+
- Fully self-contained (no CDN, works offline)
|
|
323
|
+
- Perfect for sharing with the team
|
|
324
|
+
|
|
325
|
+
# Incremental Scanning
|
|
326
|
+
```bash
|
|
327
|
+
roast-my-codebase --incremental # Only changed files since last commit
|
|
328
|
+
roast-my-codebase --since main # Only files changed since branching from main
|
|
329
|
+
```
|
|
330
|
+
- Dramatically faster on large repos — only scans changed files
|
|
331
|
+
- Global findings (circular deps, excessive dependencies) are always shown
|
|
332
|
+
- Falls back to full scan if not in a git repository
|
|
333
|
+
|
|
334
|
+
# Watch Mode
|
|
300
335
|
```bash
|
|
301
336
|
roast-my-codebase --watch
|
|
302
337
|
```
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
9
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
10
|
+
}) : x)(function(x) {
|
|
11
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
12
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
13
|
+
});
|
|
14
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
15
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
16
|
+
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
+
for (let key of __getOwnPropNames(from))
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
26
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
27
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
28
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
29
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
30
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
31
|
+
mod
|
|
32
|
+
));
|
|
33
|
+
|
|
34
|
+
// src/scanners/bundle.ts
|
|
35
|
+
import fg from "fast-glob";
|
|
36
|
+
import fs from "fs";
|
|
37
|
+
import path from "path";
|
|
38
|
+
|
|
39
|
+
// src/utils/constants.ts
|
|
40
|
+
var SOURCE_EXTENSIONS = [
|
|
41
|
+
".ts",
|
|
42
|
+
".tsx",
|
|
43
|
+
".js",
|
|
44
|
+
".jsx",
|
|
45
|
+
".mjs",
|
|
46
|
+
".cjs",
|
|
47
|
+
".py",
|
|
48
|
+
// Python
|
|
49
|
+
".go",
|
|
50
|
+
// Go
|
|
51
|
+
".rs",
|
|
52
|
+
// Rust
|
|
53
|
+
".java",
|
|
54
|
+
// Java
|
|
55
|
+
".cs",
|
|
56
|
+
// C#
|
|
57
|
+
".rb",
|
|
58
|
+
// Ruby
|
|
59
|
+
".php",
|
|
60
|
+
// PHP
|
|
61
|
+
".swift",
|
|
62
|
+
// Swift
|
|
63
|
+
".kt",
|
|
64
|
+
// Kotlin
|
|
65
|
+
".kts"
|
|
66
|
+
// Kotlin script
|
|
67
|
+
];
|
|
68
|
+
var IGNORE_PATTERNS = [
|
|
69
|
+
"**/node_modules/**",
|
|
70
|
+
"**/dist/**",
|
|
71
|
+
"**/build/**",
|
|
72
|
+
"**/.next/**",
|
|
73
|
+
"**/coverage/**",
|
|
74
|
+
"**/.git/**",
|
|
75
|
+
"**/.turbo/**",
|
|
76
|
+
"**/.cache/**",
|
|
77
|
+
"**/out/**",
|
|
78
|
+
"**/.output/**"
|
|
79
|
+
];
|
|
80
|
+
function buildIgnorePatterns(extraPatterns = []) {
|
|
81
|
+
return [...IGNORE_PATTERNS, ...extraPatterns];
|
|
82
|
+
}
|
|
83
|
+
var SAFE_GLOB_OPTIONS = {
|
|
84
|
+
followSymbolicLinks: false,
|
|
85
|
+
deep: 20
|
|
86
|
+
};
|
|
87
|
+
var LARGE_FILE_THRESHOLDS = {
|
|
88
|
+
warning: 500,
|
|
89
|
+
large: 1e3,
|
|
90
|
+
extreme: 2e3
|
|
91
|
+
};
|
|
92
|
+
var HEALTH_DEDUCTIONS = {
|
|
93
|
+
unusedDependency: -2,
|
|
94
|
+
todo: -0.25,
|
|
95
|
+
largeFile: -3,
|
|
96
|
+
extremeFile: -5,
|
|
97
|
+
circularDependency: -5,
|
|
98
|
+
criticalIssue: -10,
|
|
99
|
+
excessiveDeps: -5,
|
|
100
|
+
deepNesting: -2,
|
|
101
|
+
utilExplosion: -1,
|
|
102
|
+
complexFunction: -2,
|
|
103
|
+
veryComplexFunction: -4,
|
|
104
|
+
duplicateCode: -3,
|
|
105
|
+
deadExport: -1,
|
|
106
|
+
typeSafetyIssue: -2,
|
|
107
|
+
criticalTypeSafety: -5,
|
|
108
|
+
gitChurn: -3,
|
|
109
|
+
largePRSize: -2,
|
|
110
|
+
secret: -10,
|
|
111
|
+
envInGit: -10,
|
|
112
|
+
evalUsage: -3,
|
|
113
|
+
missingTest: -0.5,
|
|
114
|
+
frameworkViolation: -2
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// src/scanners/bundle.ts
|
|
118
|
+
function formatBytes(bytes) {
|
|
119
|
+
if (bytes < 1024) return `${bytes} B`;
|
|
120
|
+
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
121
|
+
return `${(bytes / 1024 / 1024).toFixed(2)} MB`;
|
|
122
|
+
}
|
|
123
|
+
var OUTPUT_DIRS = ["dist", "build", ".next", "out", ".output"];
|
|
124
|
+
var BundleSizeScanner = class {
|
|
125
|
+
constructor() {
|
|
126
|
+
this.name = "bundle-size";
|
|
127
|
+
}
|
|
128
|
+
async scan(rootDir) {
|
|
129
|
+
let outputDir = null;
|
|
130
|
+
for (const dir of OUTPUT_DIRS) {
|
|
131
|
+
const candidate = path.join(rootDir, dir);
|
|
132
|
+
if (fs.existsSync(candidate) && fs.statSync(candidate).isDirectory()) {
|
|
133
|
+
outputDir = candidate;
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (!outputDir) {
|
|
138
|
+
return {
|
|
139
|
+
findings: [],
|
|
140
|
+
stats: { skipped: true, reason: "No build output found (run build first)" }
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
const files = await fg(["**/*.{js,mjs,cjs,css,wasm}"], {
|
|
144
|
+
cwd: outputDir,
|
|
145
|
+
ignore: ["**/node_modules/**", "**/*.map", "**/*.LICENSE.*"],
|
|
146
|
+
...SAFE_GLOB_OPTIONS,
|
|
147
|
+
absolute: true
|
|
148
|
+
});
|
|
149
|
+
const currentSizes = {};
|
|
150
|
+
let totalBytes = 0;
|
|
151
|
+
for (const file of files) {
|
|
152
|
+
const rel = path.relative(outputDir, file).replace(/\\/g, "/");
|
|
153
|
+
const size = fs.statSync(file).size;
|
|
154
|
+
currentSizes[rel] = size;
|
|
155
|
+
totalBytes += size;
|
|
156
|
+
}
|
|
157
|
+
const cachePath = path.join(rootDir, ".roast-bundle-sizes.json");
|
|
158
|
+
let previousCache = null;
|
|
159
|
+
if (fs.existsSync(cachePath)) {
|
|
160
|
+
try {
|
|
161
|
+
previousCache = JSON.parse(fs.readFileSync(cachePath, "utf-8"));
|
|
162
|
+
} catch {
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
const findings = [];
|
|
166
|
+
if (!previousCache) {
|
|
167
|
+
if (totalBytes > 5 * 1024 * 1024) {
|
|
168
|
+
findings.push({
|
|
169
|
+
id: "bundle-size-total-critical",
|
|
170
|
+
severity: "critical",
|
|
171
|
+
category: "bundle-size",
|
|
172
|
+
message: `Total bundle size is ${formatBytes(totalBytes)} \u2014 that's a lot to send over the wire`,
|
|
173
|
+
detail: `${formatBytes(totalBytes)}`
|
|
174
|
+
});
|
|
175
|
+
} else if (totalBytes > 1024 * 1024) {
|
|
176
|
+
findings.push({
|
|
177
|
+
id: "bundle-size-total-warning",
|
|
178
|
+
severity: "warning",
|
|
179
|
+
category: "bundle-size",
|
|
180
|
+
message: `Total bundle size is ${formatBytes(totalBytes)}`,
|
|
181
|
+
detail: `${formatBytes(totalBytes)}`
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
} else {
|
|
185
|
+
const previousSizes = previousCache.sizes;
|
|
186
|
+
for (const [file, curr] of Object.entries(currentSizes)) {
|
|
187
|
+
const prev = previousSizes[file];
|
|
188
|
+
if (prev === void 0) {
|
|
189
|
+
if (curr > 100 * 1024) {
|
|
190
|
+
findings.push({
|
|
191
|
+
id: `bundle-size-new-${file}`,
|
|
192
|
+
severity: "info",
|
|
193
|
+
category: "bundle-size",
|
|
194
|
+
message: `New bundle file ${file} (${formatBytes(curr)})`,
|
|
195
|
+
file,
|
|
196
|
+
detail: formatBytes(curr)
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
} else {
|
|
200
|
+
const delta = (curr - prev) / prev * 100;
|
|
201
|
+
const growthBytes = curr - prev;
|
|
202
|
+
if (delta > 50 && growthBytes > 50 * 1024) {
|
|
203
|
+
findings.push({
|
|
204
|
+
id: `bundle-size-critical-${file}`,
|
|
205
|
+
severity: "critical",
|
|
206
|
+
category: "bundle-size",
|
|
207
|
+
message: `${file} grew ${delta.toFixed(0)}% (${formatBytes(prev)} \u2192 ${formatBytes(curr)})`,
|
|
208
|
+
file,
|
|
209
|
+
detail: `+${delta.toFixed(0)}%`
|
|
210
|
+
});
|
|
211
|
+
} else if (delta > 10 && growthBytes > 10 * 1024) {
|
|
212
|
+
findings.push({
|
|
213
|
+
id: `bundle-size-warning-${file}`,
|
|
214
|
+
severity: "warning",
|
|
215
|
+
category: "bundle-size",
|
|
216
|
+
message: `${file} grew ${delta.toFixed(0)}% (${formatBytes(prev)} \u2192 ${formatBytes(curr)})`,
|
|
217
|
+
file,
|
|
218
|
+
detail: `+${delta.toFixed(0)}%`
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
for (const file of Object.keys(previousSizes)) {
|
|
224
|
+
if (!(file in currentSizes)) {
|
|
225
|
+
findings.push({
|
|
226
|
+
id: `bundle-size-removed-${file}`,
|
|
227
|
+
severity: "info",
|
|
228
|
+
category: "bundle-size",
|
|
229
|
+
message: `${file} removed from bundle`,
|
|
230
|
+
file
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
const prevTotal = Object.values(previousSizes).reduce((a, b) => a + b, 0);
|
|
235
|
+
if (prevTotal > 0) {
|
|
236
|
+
const totalDelta = (totalBytes - prevTotal) / prevTotal * 100;
|
|
237
|
+
if (totalDelta > 20) {
|
|
238
|
+
findings.push({
|
|
239
|
+
id: "bundle-size-total-growth",
|
|
240
|
+
severity: "warning",
|
|
241
|
+
category: "bundle-size",
|
|
242
|
+
message: `Total bundle size grew ${totalDelta.toFixed(0)}% (${formatBytes(prevTotal)} \u2192 ${formatBytes(totalBytes)})`,
|
|
243
|
+
detail: `+${totalDelta.toFixed(0)}%`
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
const newCache = { timestamp: Date.now(), sizes: currentSizes };
|
|
249
|
+
try {
|
|
250
|
+
fs.writeFileSync(cachePath, JSON.stringify(newCache, null, 2), "utf-8");
|
|
251
|
+
} catch {
|
|
252
|
+
}
|
|
253
|
+
const relativeOutputDir = outputDir.replace(rootDir, ".");
|
|
254
|
+
return {
|
|
255
|
+
findings,
|
|
256
|
+
stats: {
|
|
257
|
+
totalBytes,
|
|
258
|
+
totalFormatted: formatBytes(totalBytes),
|
|
259
|
+
fileCount: files.length,
|
|
260
|
+
outputDir: relativeOutputDir,
|
|
261
|
+
hasBaseline: previousCache !== null
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
export {
|
|
268
|
+
__require,
|
|
269
|
+
__commonJS,
|
|
270
|
+
__toESM,
|
|
271
|
+
SOURCE_EXTENSIONS,
|
|
272
|
+
IGNORE_PATTERNS,
|
|
273
|
+
buildIgnorePatterns,
|
|
274
|
+
SAFE_GLOB_OPTIONS,
|
|
275
|
+
LARGE_FILE_THRESHOLDS,
|
|
276
|
+
HEALTH_DEDUCTIONS,
|
|
277
|
+
formatBytes,
|
|
278
|
+
BundleSizeScanner
|
|
279
|
+
};
|