-
Notifications
You must be signed in to change notification settings - Fork 38
chore(deadcode): fix dead-code ratchet — remove unused devDeps + rebaseline knip (#607) #673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| { | ||
| "count": 78, | ||
| "comment": "Dead-code ratchet baseline for issue #282 (cairn MVG gate #6). This is the knip issue count at the time the gate was introduced — pre-existing unused exports/types that are out of scope to remove in the gate PR. The ratchet (scripts/check-deadcode-ratchet.mjs) fails the build only if the count rises above this number. When dead code is removed and the count drops, lower this value in the same PR to lock in the gain. Per-category false positives belong in knip.json, not here." | ||
| "count": 85, | ||
| "comment": "Dead-code ratchet baseline for issue #282 (cairn MVG gate #6). This is the knip issue count the ratchet (scripts/check-deadcode-ratchet.mjs) holds the build to: it fails only if the count rises above this number. When dead code is removed and the count drops, lower this value in the same PR to lock in the gain. Per-category false positives belong in knip.json, not here. The remaining 85 are all pre-existing unused exports (44) and types (41), deferred to future dead-code PRs to ratchet down (tracking: #682)." | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,7 +20,11 @@ | |
| "docs": { | ||
| "entry": ["astro.config.mjs", "src/content.config.ts", "src/components/**/*.astro"], | ||
| "project": ["src/**/*.{astro,ts,tsx}"], | ||
| "ignoreDependencies": ["@astrojs/check", "remark-gfm", "@pagefind/default-ui", "jest"] | ||
| "ignoreDependencies": ["@astrojs/check", "markdown-link-check", "remark-gfm", "@pagefind/default-ui", "jest"] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
knip flags all three only because I verified the fix. Adding "ignore": [
".semgrep/**",
"scripts/**",
"integrations/**"
]drops the count from 88 to 85, with Worth doing rather than deferring: the baseline is the durable artifact every future dead-code PR ratchets against, so 3 phantom findings embedded now are 3 that can never be cleaned up, and they push the "driven to zero" flip-to-blocking milestone permanently out of reach.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done — but as a scoped knip workspace entry rather than a blanket Verified locally: |
||
| }, | ||
| "integrations/jira-forge-app": { | ||
| "entry": ["src/index.js!", "test/**/*.test.js"], | ||
| "project": ["src/**/*.js"] | ||
| } | ||
| } | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing this is correct, and safe for a slightly different reason than the description gives.
cdk/tsconfig.jsonsets"types": ["node"], which already blocked@types/pdf-parsefrom being auto-included, and the localdeclare module 'pdf-parse'incdk/src/types/pdf-parse.d.tsshadowsnode_modules/@typeson explicit import anyway. So this devDep was already inert and its removal is a genuine no-op. Good call either way, since a v1 type stub against an installed v2 is a trap.The problem is the justification recorded in
knip-baseline.json, which describes the removal as "superseded bypdf-parse@2's bundled types plus the localcdk/src/types/pdf-parse.d.tsambient declaration." Those two are not complementary. The ambient declaration overrides v2's real bundled types, and it describes the v1 API:pdf-parse@2.4.5exports no callable default. Verified against the installed package:So in
cdk/src/handlers/shared/attachment-screening.ts:258,pdfParseFn = (mod as any).default ?? modresolves to the module namespace object, and the call at line 277 throwsTypeError: pdfParseFn is not a function. It is caught and rewrapped, so everyapplication/pdfattachment reaching line 201 fails asPDF "<name>" could not be processed. It may be corrupt or use unsupported features.PDF attachment screening is broken for all inputs, and the failure is indistinguishable from a genuinely corrupt PDF.The
{ virtual: true }mock atcdk/test/handlers/shared/attachment-screening.test.ts:365supplies{ __esModule: true, default: jest.fn() }, so the suite asserts against a v1 shape that no longer exists and cannot catch this.This predates the PR:
pdf-parse@^2.4.5and the ambient decl landed together in #434 (2026-06-30), and theas anyplus the ambient override is what kepttscquiet. I am not asking you to fix it here. Two smaller asks:new PDFParse({ data: content }).getText()returning aTextResult, and fixing it means deleting the ambient decl, letting v2's own types apply, and replacing the mock with something that reflects the real module.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks — reproduced the v2-shape mismatch independently (
require('pdf-parse')exportsPDFParse/VerbosityLevel/… and.defaultisundefined, so(mod as any).default ?? modyields the namespace object and the call throwsTypeError). Both asks done:knip-baseline.jsonso this PR no longer cites the version-mismatched stub as justification.new PDFParse({ data }).getText()API, and add a real-PDF end-to-end test so a future mismatch fails loudly).Fixed in e825a75.