You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+24-10Lines changed: 24 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,10 +24,14 @@ Manual code review is time-consuming and inconsistent. InspectoRepo provides det
24
24
| Rule | Severity | Description |
25
25
|------|----------|-------------|
26
26
|`unused-imports`| warn | Detects unused import specifiers (default, namespace, named) and suggests removal with a safe proposed patch |
27
-
|`complexity-hotspot`| warn | Flags functions with high cyclomatic-like complexity (≥ 12) and suggests refactoring strategies|
27
+
|`complexity-hotspot`| warn | Flags functions with high cyclomatic-like complexity (≥ 12) with specific contributor breakdown (nested conditionals, loops, ternaries, logical chains) and tailored suggestions|
28
28
|`optional-chaining`| info | Detects monotonic guard chains like `a && a.b && a.b.c` and suggests optional chaining (`a?.b?.c`) |
29
29
|`boolean-simplification`| info | Simplifies `x === true`, `x === false`, `!!x`, and `x ? true : false` patterns |
30
30
|`early-return`| info | Detects unnecessary block-style early returns and suggests single-line guard clauses |
31
+
|`no-debugger`| warn | Detects `debugger` statements left in code — auto-fixable |
32
+
|`no-empty-catch`| warn | Flags empty catch blocks that silently hide errors — report only |
33
+
|`no-useless-return`| info | Detects redundant `return;` at the end of functions — auto-fixable |
34
+
|`ts-diagnostics`| error | Reports high-confidence TypeScript compiler diagnostics (unreachable code, duplicate identifiers, missing names, type mismatches) — report only |
31
35
32
36
## Tech Stack
33
37
@@ -88,6 +92,8 @@ npm test
88
92
|`npm test`| Run Vitest tests |
89
93
|`npm run repopack`| Generate repomix exports |
90
94
95
+
> **Export packs:**`npm run repopack` generates four versioned files under `ai/exports/`. Use `repo-pack-latest-vN.md` for a quick lightweight review — it includes project structure and core source without docs, screenshots, or scripts.
The fix command runs analysis, finds issues with safe auto-fix suggestions, shows a preview of each proposed change, and asks for confirmation before applying. Only `optional-chaining`, `boolean-simplification`, and `unused-imports` rules support auto-fix. `complexity-hotspot` is never auto-applied.
149
+
The fix command runs analysis, finds issues with safe auto-fix suggestions, shows a preview of each proposed change, and asks for confirmation before applying. Rules with auto-fix support: `optional-chaining`, `boolean-simplification`, `unused-imports`, `early-return`, `no-debugger`, and `no-useless-return`. Advisory rules like `complexity-hotspot`, `no-empty-catch`, and `ts-diagnostics` are never auto-applied.
144
150
145
151
### Fix Preview Mode
146
152
@@ -196,13 +202,17 @@ The CLI uses the same analysis engine as the web UI. Output is deterministic —
Copy file name to clipboardExpand all lines: docs/agent-worklog.md
+36Lines changed: 36 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,42 @@ Development log for InspectoRepo. Each entry describes what was implemented, why
4
4
5
5
---
6
6
7
+
## 2026-03-11 — Richer Analysis Rules and Export Polish
8
+
9
+
### What was implemented
10
+
11
+
-**Enriched complexity-hotspot warnings** — each complexity issue now includes function name, complexity score, contributor breakdown (if statements, loops, ternaries, logical chains, switch cases, nesting depth), and specific tailored suggestions instead of generic messages.
12
+
-**New rule: `no-debugger`** — detects `debugger` statements left in code. Auto-fixable by removing the statement.
13
+
-**New rule: `no-empty-catch`** — flags empty catch blocks that silently swallow errors. Report-only (no auto-fix).
14
+
-**New rule: `no-useless-return`** — detects redundant `return;` at the end of function bodies. Auto-fixable.
-**Extended auto-fix support** — `no-debugger` and `no-useless-return` now supported in the fix engine (preview + apply modes).
17
+
-**Export workflow polish** — human summary generation now bans milestone-title bullets and raw commit prefixes more strictly. Regenerate section lists all 4 export files. repo-pack-latest documented as the preferred lightweight pack.
18
+
-**Web UI details panel** — expanded issue view now shows both suggestion summary and details for richer context (e.g. complexity contributors).
19
+
-**Preset updates** — all four presets (`recommended`, `strict`, `cleanup`, `react`) updated to include the new rules with conservative defaults.
20
+
21
+
### Why
22
+
23
+
The previous complexity warnings were too generic — every function got the same message regardless of what was actually making it complex. The new rules (`no-debugger`, `no-empty-catch`, `no-useless-return`, `ts-diagnostics`) are all syntax-exact or diagnostics-backed, making them highly reliable with zero false positives for their defined scope.
24
+
25
+
### How to verify
26
+
27
+
```bash
28
+
npm run lint
29
+
npm run typecheck
30
+
npm run build
31
+
npm test
32
+
```
33
+
34
+
### Design decisions
35
+
36
+
-**Complexity breakdown is tracked per-function** — a `ComplexityBreakdown` struct accumulates counts for each contributor type during the recursive walk. This makes the output deterministic and the rule predictable.
37
+
-**New rules are conservative** — `no-debugger` and `no-empty-catch` are exact syntax matches with no ambiguity. `no-useless-return` only flags bare `return;` as the last statement. `ts-diagnostics` uses a curated subset of TS error codes.
38
+
-**Auto-fix only for safe removals** — `no-debugger` (remove statement) and `no-useless-return` (remove redundant return) are trivially safe. `no-empty-catch` and `ts-diagnostics` are never auto-fixed.
39
+
-**ts-diagnostics off by default** — in `recommended` and `cleanup` presets, because in-memory ts-morph projects may not resolve all external types. Enabled in `strict` preset.
Counts control-flow complexity per function: if/else, switch cases, ternaries, logical operators, loops, try/catch, plus nesting depth bonus. Each function gets a `ComplexityBreakdown` struct tracking counts for each contributor type (ifStatements, loops, ternaries, logicalChains, switchCases, catchClauses, maxNestingDepth). Flags functions scoring ≥ 12.
250
+
251
+
Messages are specific: `Function "renderDashboard" has high complexity (22) driven by nested conditionals and ternaries.` Details include contributor counts (e.g. "4 if statements, 3 ternaries, nesting depth 3"). Suggestions are tailored to what was actually found (e.g. "replace nested conditionals with early returns" when if-statements dominate).
252
+
253
+
### `src/rules/no-debugger.ts`
254
+
255
+
Detects `debugger` statements via `SyntaxKind.DebuggerStatement`. Auto-fixable by removing the statement line. Severity: warn.
256
+
257
+
### `src/rules/no-empty-catch.ts`
258
+
259
+
Detects catch blocks with no statements inside via `SyntaxKind.CatchClause` → `getBlock().getStatements().length === 0`. Report-only (no auto-fix). Severity: warn.
260
+
261
+
### `src/rules/no-useless-return.ts`
262
+
263
+
Detects bare `return;` as the final statement of a function body. Only flags when the return text is exactly `"return;"` — does not flag returns with values. Auto-fixable by removing the redundant line. Severity: info.
264
+
265
+
### `src/rules/ts-diagnostics.ts`
266
+
267
+
Reports selected high-confidence TypeScript diagnostics from the analyzed file using `sourceFile.getPreEmitDiagnostics()`. Only maps a conservative subset of diagnostic codes: TS7027 (unreachable code), TS2300 (duplicate identifier), TS2304 (cannot find name), TS2339 (property does not exist), TS2554 (argument count mismatch), TS2322 (type assignment mismatch). Off by default in recommended/cleanup presets; enabled in strict preset.
250
268
251
269
### `src/rules/optional-chaining.ts`
252
270
@@ -284,7 +302,7 @@ Rule preset system:
284
302
-`isValidPreset(name)` — type guard checking if a string is a valid `PresetName`
285
303
-`getPresetNames()` — returns the list of available preset names
286
304
287
-
Presets: `recommended` (all warn), `strict` (unused-imports + complexity at error), `cleanup` (complexity off, style rules on), `react` (unused-imports at error for TS+React projects).
0 commit comments