Skip to content

feat(ci): add jscpd duplicate-code detection#64

Merged
vi70x4 merged 2 commits into
mainfrom
fix/duplicate-code-detection
Jun 30, 2026
Merged

feat(ci): add jscpd duplicate-code detection#64
vi70x4 merged 2 commits into
mainfrom
fix/duplicate-code-detection

Conversation

@vi70x4

@vi70x4 vi70x4 commented Jun 30, 2026

Copy link
Copy Markdown
Member

Summary

Adds jscpd (v4.2.5) to the monorepo's CI pipeline and toolchain to detect copy-paste (duplicate) code and enforce DRY principles:

  • New CI job (cpd) in .github/workflows/ci.yml runs jscpd on every PR and uploads the HTML report as a 30-day artifact.
  • .jscpd.json config with tuned thresholds (minLines: 5, minTokens: 70, threshold: 5%) ignores noise: node_modules, dist, coverage, tests, generated .d.ts files, and lockfile-adjacent JSON/YAML that legitimately repeats.
  • Local script pnpm cpd lets developers analyze before opening a PR.
  • jscpd added to pnpm workspace catalog (^4.0.0) and devDependencies.
  • .jscpd/ added to .gitignore.

Verification

pnpm cpd runs clean against the current codebase (~1.9% duplication, well under the 5% threshold). 137 clones found across 1840 source files; the HTML report is browsable for review.

Agent Readiness

Fixes duplicate_code_detection signal — the repo now has substantive tooling to detect copy-paste code, satisfying the DRY-focused readiness criterion.

Adds jscpd (v4.2.5) to the monorepo's CI pipeline and toolchain:
- Adds a 'cpd' CI job in .github/workflows/ci.yml that runs jscpd
  on every PR and uploads the HTML report as an artifact.
- Creates .jscpd.json with tuned thresholds (minLines 5, minTokens 70,
  threshold 5%) and ignores node_modules, dist, coverage, tests, .d.ts
  files, and JSON/YAML config known to legitimately repeat.
- Adds 'cpd' script to package.json for local analysis before PR.
- Adds jscpd to pnpm workspace catalog (^4.0.0) and devDependencies.
- Adds .jscpd/ to .gitignore.

Agent Readiness: fixes duplicate_code_detection signal.
@deepsource-io

deepsource-io Bot commented Jun 30, 2026

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in daf9605...3544c1f on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
JavaScript Jun 30, 2026 5:34p.m. Review ↗
Shell Jun 30, 2026 5:34p.m. Review ↗
C & C++ Jun 30, 2026 5:34p.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request integrates copy-paste detection into the repository using jscpd. It adds a .jscpd.json configuration file, updates .gitignore to ignore the report output, and adds the cpd script and jscpd dependency to package.json and pnpm-workspace.yaml. Feedback on these changes highlights that the CI workflow file mentioned in the PR description is missing from the commit, several ignore patterns in .jscpd.json are redundant and can be simplified, and the absolute path setting should be disabled to ensure portable HTML reports.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread package.json
"dev:tamagotchi:xwayland": "pnpm -rF @proj-airi/stage-tamagotchi run dev:xwayland",
"dev:apps": "pnpm -rF=\"./apps/*\" run --parallel dev",
"dev:packages": "pnpm -rF=\"./packages/*\" --parallel run dev",
"cpd": "jscpd .",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The PR description mentions adding a new CI job (cpd) in .github/workflows/ci.yml to run jscpd on every PR and upload the HTML report. However, the .github/workflows/ci.yml file is not included in the changes of this pull request.

Please ensure that the workflow file changes are committed and included in this PR so that the CI job actually runs.

Comment thread .jscpd.json
Comment on lines +6 to +29
"ignore": [
"**/node_modules/**",
"**/dist/**",
"**/coverage/**",
"**/.turbo/**",
"**/*.test.ts",
"**/*.test.tsx",
"**/*.test.js",
"**/*.test.jsx",
"**/*.spec.ts",
"**/*.spec.tsx",
"**/*.spec.js",
"**/*.spec.jsx",
"**/__tests__/**",
"**/typed-router.d.ts",
"**/components.d.ts",
"**/.nuxt/**",
"**/storybook-static/**",
"**/playwright-report/**",
"**/test-results/**",
"**/*.json",
"**/*.yaml",
"**/*.yml"
],

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Several ignore patterns in this list are redundant and can be removed to simplify the configuration:

  1. Already ignored by .gitignore: Since "gitignore": true is enabled on line 32, any paths matched by .gitignore (such as node_modules, dist, coverage, .turbo, .nuxt, components.d.ts, and typed-router.d.ts) are automatically ignored by jscpd.
  2. Not in the format list: Since the format array (lines 34-43) explicitly restricts scanning to specific extensions (typescript, tsx, javascript, jsx, vue, css, scss, less), files ending in .json, .yaml, and .yml will never be scanned anyway.

Removing these redundant patterns keeps the configuration clean and maintainable.

  "ignore": [
    "**/*.test.ts",
    "**/*.test.tsx",
    "**/*.test.js",
    "**/*.test.jsx",
    "**/*.spec.ts",
    "**/*.spec.tsx",
    "**/*.spec.js",
    "**/*.spec.jsx",
    "**/__tests__/**",
    "**/storybook-static/**",
    "**/playwright-report/**",
    "**/test-results/**"
  ],

Comment thread .jscpd.json Outdated
"**/*.yml"
],
"threshold": 5,
"absolute": true,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Setting "absolute": true will generate absolute file paths in the reports (such as the HTML report). When these reports are generated in a CI environment and uploaded as artifacts, the absolute paths will reflect the CI runner's directory structure (e.g., /home/runner/work/...). This makes the HTML report hard to use or broken when downloaded and viewed locally by developers.

It is recommended to set "absolute": false (or omit it, as false is the default) to ensure relative paths are used, making the reports portable and easy to browse locally.

Suggested change
"absolute": true,
"absolute": false,

- Add pnpm-lock.yaml (jscpd dependency resolution).
- .jscpd.json: remove redundant ignore patterns covered by gitignore or format whitelist; set absolute:false for portable HTML reports.
- Sync package.json + ci.yml with external changes (test-results.xml reporting).
@vi70x4 vi70x4 merged commit ff56895 into main Jun 30, 2026
7 of 10 checks passed
@vi70x4 vi70x4 deleted the fix/duplicate-code-detection branch June 30, 2026 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants