Add jscpd to find duplicated blocks of code#264
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
This PR introduces jscpd into the repository to detect duplicated code blocks and wires it into the main CI script, alongside a small refactor in the dashboard API layer to reduce pagination-related duplication.
Changes:
- Add
jscpdas a dev dependency and a newlint:duplicationscript. - Update
npm run cito include duplication linting. - Refactor dashboard API pagination validation/parameter building to reuse shared helpers.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/dashboard/src/lib/api.ts | Extracts shared pagination zod shape + param builder to reduce duplicated pagination handling. |
| package.json | Adds lint:duplication script and runs it in CI; adds jscpd dependency. |
| package-lock.json | Locks transitive dependencies introduced by jscpd. |
| jscpd.json | Adds baseline configuration for duplication scanning and ignore patterns. |
| "ignore": [ | ||
| "**/*.test.ts", | ||
| "packages/dashboard/.output", | ||
| "packages/openworkflow/postgres/backend.ts", | ||
| "packages/openworkflow/sqlite/backend.ts" | ||
| ] |
There was a problem hiding this comment.
ignore currently excludes **/*.test.ts, but the repo also has test-like files such as packages/openworkflow/backend.testsuite.ts that won’t be excluded by this glob. If the intention is to keep duplication checks focused on production code, consider expanding the ignore patterns to cover *.testsuite.ts (and any other test filename conventions used here).
| "threshold": 0, | ||
| "exitCode": 1, | ||
| "gitignore": true, |
There was a problem hiding this comment.
With "threshold": 0 and "exitCode": 1, jscpd will fail CI on any detected duplication. If the goal is to introduce duplication reporting incrementally, consider setting a non-zero threshold (or adjusting exitCode) to avoid blocking CI on pre-existing duplication until it’s addressed.
No description provided.