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
{{ message }}
Repository navigation
Commit 75df385
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,7 @@ All notable changes will be documented in this file.
9
9
-`swallowed_error` (medium): a `catch` block whose only statements are `console` calls. The error is logged and the code carries on as if the operation succeeded. A comment in the block explaining why that is safe, a rethrow, or any other statement (such as `setError(e)`) means it is not reported, and so does a fallback after the `try`, as for `empty_catch`.
10
10
11
11
### Changed
12
+
-`empty_catch` skips `void p.catch(() => {})`, where `void` says the result is dropped on purpose, and a `try` that declares locals before assigning the outer variable (`const stats = await stat(p); isDir = stats.isDirectory();`). hono uses both.
12
13
- The package ships compiled JavaScript (`dist/`) and runs it directly with Node. It used to run the TypeScript sources through `tsx` on every call: `karpeslop --version` took 1.5 s and an install was 43 MB. It now takes 0.6 s and 31 MB, most of it the TypeScript compiler the rules use to parse code. `tsx` is no longer a runtime dependency.
13
14
-`fresh_package_version` skips packages the scanned workspace publishes itself (any `name` in a scanned package.json) and lockfile entries that link a workspace folder. TanStack Query got 184 warnings for `@tanstack/*` versions it had just released.
14
15
- Folders named `build`, `out` or `temp` are skipped only at the scan root or next to a package.json, where they hold build output. Deeper ones are often source: Next.js keeps its build pipeline in `packages/next/src/build/`, which was never scanned.
Copy file name to clipboardExpand all lines: README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,7 @@ npx karpeslop@latest
28
28
|`placeholder_implementation`| high | A body that returns a constant (or nothing) under a TODO or placeholder comment; a short body under a comment that says the real code is elsewhere ("Simulate API call", "In a real app you would..."); a body that only logs and returns success; or `throw new Error("Not implemented")`|
29
29
|`elided_code_comment`| high |`// ... rest of the code`, `// ...existing code...`, `{/* ... other fields */}`, `// Add more cases as needed` and similar, in line, block and JSX comments |
30
30
|`placeholder_value`| high |`"YOUR_API_KEY"`, `"<your-token>"`, `"Bearer <API_KEY>"`, `"sk-xxxxxx"`, `"sk_test_your_key_here"`, `"postgres://postgres:password@..."`, `"https://your-project.supabase.co"`, `"xxxx"` stored as a key or token, an `example.com` URL stored in config, and a hard-coded fallback for a secret (`process.env.JWT_SECRET \|\| "secret"`) |
31
-
|`empty_catch`| high |`catch {}` or `.catch(() => {})` with no comment explaining why and no `_`-named binding. Not reported when the `try` returns and code after it is the fallback (`try { return parse(x) } catch {}` then a default), or when the `try` only assigns variables declared before it that are read after it (`let found = fallback; try { found = probe() } catch {}`) |
31
+
|`empty_catch`| high |`catch {}` or `.catch(() => {})` with no comment explaining why, no `_`-named binding and no `void` in front. Not reported when the `try` returns and code after it is the fallback (`try { return parse(x) } catch {}` then a default), or when the `try` only assigns variables declared before it that are read after it (`let found = fallback; try { found = probe() } catch {}`) |
32
32
|`swallowed_error`| medium | A `catch` block that only logs (`console.error('Failed', err)`) and lets execution continue as if nothing failed, or logs and then returns `[]`, `{}` or `''`, which the caller cannot tell apart from an empty success |
33
33
|`unsafe_type_assertion`| high |`as any`|
34
34
|`unsafe_double_type_assertion`| high |`as unknown as T` and other chained casts |
'async function isDir(p: string) {\n let dir;\n try {\n dir = (await stat(p)).isDirectory();\n } catch {}\n return dir;\n}',
219
221
'let als: unknown;\nfor (const probe of probes) {\n try {\n als = probe();\n } catch {}\n if (als) break;\n}',
222
+
'async function isDir(p: string) {\n let dir;\n try {\n const stats = await stat(p);\n dir = stats.isDirectory();\n } catch {}\n return dir;\n}',
220
223
'function f(src: S) {\n let x = 1;\n try {\n x = load();\n } catch {}\n ({ a = x } = src);\n return a;\n}'
221
224
]){
222
225
assert.equal(countOf(code,'empty_catch'),0,code);
@@ -230,7 +233,10 @@ test('empty catch: a variable assigned in the try keeps its earlier value as the
230
233
// Written again, or read only by a callback's own parameter of the same name.
231
234
'function f(src: S) {\n let x = 1;\n try {\n x = load();\n } catch {}\n ({ x } = src);\n [x] = [2];\n}',
232
235
'function f(xs: number[]) {\n let x = 1;\n try {\n x = load();\n } catch {}\n return xs.map((x) => x * 2);\n}',
233
-
'function f(xs: number[]) {\n let x = 1;\n try {\n x = load();\n } catch {}\n for (const x of xs) use(x);\n if (xs.length) { const x = 2; use(x); }\n xs.forEach(() => { var x = 3; use(x); });\n}'
236
+
'function f(xs: number[]) {\n let x = 1;\n try {\n x = load();\n } catch {}\n for (const x of xs) use(x);\n if (xs.length) { const x = 2; use(x); }\n xs.forEach(() => { var x = 3; use(x); });\n}',
0 commit comments