Repository navigation
Pin jscpd version in setup-duplicates-analysis and analyze-duplicates - #45
Conversation
`jscpd@latest` is non-reproducible: a future release can change parsing/config or fail independently of any repository change, turning an unchanged commit into a failing CI job later. setup-duplicates-analysis resolves a version once per session and uses it everywhere: baseline, the wrapper script committed into the target project, the report, and the mitigation loop's re-checks. analyze-duplicates likewise fixes one version per run and accepts --jscpd-version so setup's report matches the pin its CI enforces. Prompted by Copilot flagging `jscpd@latest` in con/duct#450's generated tools/check-duplication.sh. Originally a3f3cba, which was not pushed before #15 merged. Co-Authored-By: Claude Code 2.1.322 / Claude Opus 5.5 <noreply@anthropic.com>
yarikoptic-gitmate
left a comment
There was a problem hiding this comment.
Review of head 060078d. Pinning is the right change, and CI is green. Two things should be fixed before merge, because each one lets a run fall back to an unpinned jscpd without anyone noticing. The rest is recommended tidying that makes the files shorter, not longer. All points have inline suggestions except the last one, whose lines are outside the diff.
Should fix
analyze-duplicatesStep 1 gives no version when jscpd is installed.command -v jscpdprints a path, so there is no number to pin. Suggestion inline (lines 65-76), plus a one-word follow-on at line 43.${PINNED_VERSION}is a shell variable nothing assigns. Unset, it becomesjscpd@, which npx resolves to latest with exit 0 (checked here: it printedjscpd 5.4.3). The files' existing placeholder forms avoid that:PINNED_VERSIONinanalyze-duplicates(lines 91, 149) and<PINNED_VERSION>insetup-duplicates-analysis(lines 309, 629, 667). The wrapper script's own${JSCPD_VERSION}(lines 400, 411) is assigned inside the script and is correct as is.
Recommended
- Prerequisites bullet in
setup-duplicates-analysis(lines 44-53): reuse the pin the project already has before resolving a new one, drop "(or globally installed)", and shrink it from ten lines to four. Suggestion inline. - Step 4.0 uses a second placeholder for the same value. On the pre-commit path the pin CI enforces is the hook
rev, writtenv<VERSION>, and nothing ties it to<PINNED_VERSION>, which the baseline, report and re-checks use. Upstream tags arevplus the npm version (the hook atv5.4.3pinsjscpd==5.4.3), so one placeholder is right for both:- line 352:
rev: v<PINNED_VERSION> #pre-commit autoupdatebumps it - line 369:
additional_dependencies: ["jscpd@<PINNED_VERSION>"]
- line 352:
Not for this PR
review-repo-code-quality and review-org-code-quality could later pass --jscpd-version to analyze-duplicates. That changes what their runs do, so it would be a separate PR with a MINOR bump of both.
Neither touched skill declares version:, so the skill-version rule asks for nothing here.
Generated by Claude Code
PINNED_VERSION was written as a shell variable that nothing assigns; unset, `jscpd@` resolves to latest and silently undoes the pin. It is now a text placeholder like the skills' other values. analyze-duplicates: take the default from `jscpd --version` so an installed jscpd also yields a version. setup-duplicates-analysis: use the version the project already pins (Step 0.1 now looks for it, CI workflows included); a setup that still runs jscpd@latest or mixes versions counts as partially wired; the pre-commit hook rev uses the same version, with a fallback when upstream has no such tag. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PvaGRYu7bNGqsozPje18f8
|
312419d addresses all eight review threads, mostly as suggested:
Beyond the suggestions, in
Not changed here, both older than this PR:
Generated by Claude Code |
yarikoptic-gitmate
left a comment
There was a problem hiding this comment.
Re-review of head 312419d. All four points from the first review are resolved, and CI is green:
analyze-duplicatesStep 1 yields a version with or without an installed jscpd.PINNED_VERSIONis a text placeholder everywhere; no${PINNED_VERSION}is left in either skill.- The Prerequisites bullet is six lines, with the project's existing pin first.
- The pre-commit hook
revand therepo: localfallback use<PINNED_VERSION>.
The Step 0.1 search for an existing pin and the "partially wired" rule for unpinned or mixed setups are consistent with the 0.3 table and Steps 4, 7 and 9 on every path I walked.
Two statements in the text this commit added are factually off and should be fixed; both have inline suggestions that keep the line count the same or lower:
npm ls jscpddoes not read the lockfile (line 127), and a barenpx jscpdis pinned oncenpm cihas run.- The upstream-tag bullet (lines 383-385): tags go back to
v1.0.0, and the hook only works fromv5.2.1, so a version test replaces thels-remotetest.
Two optional nits are inline (a wider grep pattern, a shorter parenthetical). Nothing else to request.
Generated by Claude Code
Read a package.json range's version from the lockfile with `npm ls jscpd --package-lock-only` (plain `npm ls` reads node_modules), and do not count a bare `npx jscpd` that follows `npm ci` as unpinned. The upstream pre-commit hook works from v5.2.1 (language: python), not v5.3.0; below that use the repo: local hook, so the tag lookup goes. The pin search also matches `JSCPD_VERSION: X` and `jscpd==X`, and the version-output example no longer claims a format that 5.0.x contradicts. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PvaGRYu7bNGqsozPje18f8
yarikoptic-gitmate
left a comment
There was a problem hiding this comment.
Re-review of head f10ce92 (12 lines changed since 312419d). All four points from the previous review are resolved, and I am resolving their threads:
- The lockfile lookup is
npm ls jscpd --package-lock-only. - The bare
npx jscpdexception is narrower than I suggested (jscpd inpackage-lock.jsonandnpm cirun first), which is the more accurate rule. - The hook bullet is a version test (below 5.2.1 use the
repo: localhook), thels-remotestep is gone, and the earlier bullet now says "Since v5.2.1", so the two agree. - The wider grep pattern and the shorter version-output parenthetical are in. I re-ran the pattern on a small fixture: it matches the
env:form,jscpd==,jscpd@and thepackage.jsonrange, and skips- id: jscpdand a barenpx jscpd ..
No further requests from me. CI on this head was still running when I looked (validate passed; apm, security-static and security-deps in progress).
Generated by Claude Code
|
Anyone else to review approve merge? |
Summary
Replace
jscpd@latestwith a version resolved once per run insetup-duplicates-analysisandanalyze-duplicates. With@latest, a new jscpd release can change parsing or config, or fail on its own, so an unchanged commit can start failing CI later. Copilot flagged exactly that in thetools/check-duplication.shthis skill generated for con/duct#450.setup-duplicates-analysisuses one<PINNED_VERSION>for the baseline, the report, the mitigation re-checks, and the pre-commit hookrevor wrapper script it commits into the target project. That version is the one the project already pins, if any (Step 0.1 now searches for it, CI workflows included), otherwisenpm view jscpd version. An existing setup that still runsjscpd@latest, or whose runners pin different versions, counts as partially wired, so the skill pins it instead of stopping at "already clean".analyze-duplicatesfixes one version for the whole run and gets a new--jscpd-versionflag, so setup's report uses the same version that the project's check is pinned to. Without the flag it uses the installed jscpd's version, else the current release.PINNED_VERSIONis a text placeholder the agent fills in, like the skills' other values, not a shell variable: unset,jscpd@resolves to latest and would silently undo the pin.This was left out of #15: it was committed locally but not pushed before #15 merged.
Test plan
tox -e validate,security-static--jscpd-version 5.4.2, fresh setup with the wrapper script, existing wrapper and hook pins)🤖 Generated with Claude Code
https://claude.ai/code/session_01PvaGRYu7bNGqsozPje18f8