chore: add jscpd + knip dead-code/duplication scanners (warn mode) - #195
Conversation
Adds two report-only (warn mode) static-analysis workflows plus knip config, modeled on the merged pilot receptron/slashgpt-js#29. Neither gates CI. - .github/workflows/duplication-scan.yaml: jscpd 5.0.12 (SHA-pinned), SARIF to code scanning, no --threshold (never fails). continue-on-error on upload. - .github/workflows/dead-code-scan.yaml: knip report to job summary, forced exit 0. - knip.jsonc: every rule warn/off; project src/**/*.{ts,vue}. - package.json: knip@^6 devDep + "knip" script; removed 3 confirmed-dead deps (vue-drawing-canvas, @types/uuid, @types/dotenv). - .gitignore: ignore jscpd report/ output. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool. What Enabling Code Scanning Means:
For more information about GitHub Code Scanning, check out the documentation. |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Warning Review the following alerts detected in dependencies. According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.
|
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThis PR adds two report-only GitHub Actions workflows: a Knip-based dead-code scan and a jscpd-based duplication scan. It adds a Knip configuration file, a Knip script and devDependency, a .gitignore entry for scan output, and removes three unused dependencies from package.json. ChangesCI Scanning Workflows
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant Trigger as PR/Push Event
participant Workflow as GitHub Actions
participant Scanner as Knip/jscpd
participant Output as Summary/SARIF
Trigger->>Workflow: trigger on matching paths
Workflow->>Workflow: checkout code, install dependencies
Workflow->>Scanner: run scan (report-only)
Scanner-->>Output: write findings (job summary or SARIF)
Workflow->>Workflow: exit successfully regardless of findings
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Adds two report-only (warn mode) static-analysis workflows plus a
knipconfig, modeled onthe merged pilot
receptron/slashgpt-js#29.Neither gates CI.
Added
.github/workflows/duplication-scan.yaml— jscpd copy/paste detection. Installs thejscpd
5.0.12binary pinned by SHA256, scans over--format typescript,vue, uploads SARIF toGitHub code scanning. No
--threshold, so jscpd never fails the job (findings are SARIFannotations only). Job
permissions: {contents: read, security-events: write, actions: read};top-level
permissions: contents: read;actions/checkout@v6+persist-credentials: false;the
upload-sarifstep iscontinue-on-error: true..github/workflows/dead-code-scan.yaml— knip unused files/exports/deps. Writes the compactreport to the job summary and forces
exit 0so it can never gate, regardless of future rulechanges.
actions/checkout@v6+actions/setup-node@v6(node 22),yarn install --frozen-lockfile --network-timeout 120000.knip.jsonc— every rule iswarnoroff, soknipitself exits 0 (warn mode).package.json—knip@^6devDependency (resolves to6.29.0) +"knip": "knip"script, and3 confirmed-dead dependencies removed (see below).
.gitignore— ignores jscpd'sreport/output so scan artifacts are never committed.knip config chosen for this repo
project: ["src/**/*.{ts,vue}"]— the Vite/Vue client source under analysis. The Expressbackend (
server/**) andbenchmark/**are intentionally out of scope.index.html->src/main.ts; knip'sbuilt-in vite plugin auto-detects
index.html, so listing an entry only produces a "redundantentry" hint.
ignoreExportsUsedInFile: true,includeEntryExports: false.ignoreDependencies: none. The@gui-chat-plugin/*/@mulmochat-plugin/*plugins(including the two
github:git-ref deps,@gui-chat-plugin/pianoandguichat-plugin-akinator) are all statically imported via.../vuesubpaths insrc/tools/index.ts, so knip resolves them and there was nothing structurally invisible tosilence.
unresolvedisoff, so the/vuesubpath imports never surface as noise.Items to Confirm / Review
knip findings — FIXED (3 dependencies removed)
All three are behavior-preserving and confirmed against external ground truth; the clean-install
CI gates below pass with them gone.
vue-drawing-canvas— zero references anywhere in the repo (src, server, benchmark,configs). It is a regular dependency of
@gui-chat-plugin/canvas(not apeerDependency), sothe plugin brings its own copy; it stays in
yarn.locktransitively. Removing the directdep is safe.
@types/uuid— redundant stub;uuid@14bundles its own types (dist/index.d.ts).@types/dotenv— redundant stub;dotenv@17bundles its own types (lib/main.d.ts).knip findings — LEFT (warn), for human judgment
@anthropic-ai/sdk,@google/genai,exa-js,winston,winston-daily-rotate-file— false positives of thesrc/**-only project scope: each isimported by the Express backend under
server/**(e.g.server/llm/providers/*,server/utils/logger.ts). Do not remove.yauzl— no direct import in src/server, but it is also pinned inresolutions. Whether thedirect dependency should stay alongside the resolution pin is a maintainer call — left.
@tailwindcss/postcss,autoprefixer,postcss,ts-node—the app uses
@tailwindcss/viteand there is nopostcss.config.*, so the three PostCSS-pipelinepackages look like leftovers, and
ts-nodehas no reference (tsxis used instead). These arebuild-tooling packages that a config could pull in implicitly, so they are left as follow-up
candidates rather than removed in a scanner-onboarding PR.
src/components/TextSelectionMenu.vue,src/session/types.ts,src/tools/utils/index.ts,src/tools/utils/blankImage.ts,src/tools/utils/htmlTypes.ts—all substantive, not empty scaffold: a complete 101-line selection-menu component, a session
adapter type contract, and a shared-utils barrel (+2 modules) from the recent
move shared plugin code to src/tools/utilsrefactor. Currently orphaned but plausiblymid-refactor / intended surface — left for the maintainer.
src/components/settings/index.ts,src/tools/backend/index.ts) and plugin/tool helpers that read as an intended module surface.Left.
jscpd findings — FIXED: none
37 clones (4.46% duplicated tokens). None are trivial/mechanical; each is real structural
duplication needing a semantic refactor, so all are left reported for a human:
server/routes/textLLM.ts(per-providerLLM streaming/response handling repeated across branches).
src/composables/useGoogleLiveSession.ts↔useRealtimeSession.ts/useTextSession.ts(22–29 line blocks) — parallel session-adapter boilerplate; deduping means changing the
abstraction (which
src/session/types.tsappears to be heading toward).src/tools/backend/html.ts↔markdown.ts(14 lines) and asrc/tools/index.tsself-clone(29 lines, plugin-registration list).
Also confirm
actions/checkout@v6in both new workflows matches the pilot pattern, but this repo'sexisting
pull_request.yamlusesactions/checkout@v7. If the fleet should track the newestaction versions, bump both to
@v7.upload-sarifstep iscontinue-on-error: true, so ifcode scanning / GitHub Advanced Security is not enabled for the repo, that one step is skipped
without failing the job. Enable code scanning to see the annotations.
Verification (clean install)
From a fresh
rm -rf node_modules && yarn install --frozen-lockfile(isolated cache):yarn buildOK (vite build+tsc -p server/tsconfig.json),yarn typecheckOK(
vue-tsc --noEmit),yarn lintOK (eslint src server),yarn knipOK (exit 0, warn mode),jscpdOK (exit 0).--frozen-lockfilesucceeded, confirmingyarn.lockis in sync after the3 removals. No build/scan artifacts (
dist/,report/) are staged.🤖 Generated with Claude Code
Summary by CodeRabbit