Analysis of commit 19a716b6250d945acb514205d6f452bd524b4a57
Assignee: @copilot
Summary
The latestVersions CI command logic contains an identical (>10 LOC) block that logs status/warnings and sets Azure DevOps output variables. This block is duplicated between the deprecated command (check/latestVersions) and its replacement (vnext/check/latestVersions), increasing maintenance cost and risk of behavior drift.
Duplication Details
Pattern: ADO output variable + warning logging for isLatestInMajor result
- Severity: Medium
- Occurrences: 2 (exact/near-exact duplication)
- Locations:
build-tools/packages/build-cli/src/commands/check/latestVersions.ts (lines 51–79)
build-tools/packages/build-cli/src/commands/vnext/check/latestVersions.ts (lines 63–91)
Code sample (duplicated block)
if (result.isLatest) {
this.log(
`Version \$\{versionInput.version} is the latest version for major version \$\{result.majorVersion}`,
);
this.log(`##vso[task.setvariable variable=shouldDeploy;isoutput=true]true`);
this.log(
`##vso[task.setvariable variable=majorVersion;isoutput=true]\$\{result.majorVersion}`,
);
return;
}
if (result.latestVersion !== undefined) {
this.log(
`##[warning]skipping deployment stage. input version \$\{versionInput.version} does not match the latest version \$\{result.latestVersion}`,
);
this.log(`##vso[task.setvariable variable=shouldDeploy;isoutput=true]false`);
this.log(
`##vso[task.setvariable variable=majorVersion;isoutput=true]\$\{result.majorVersion}`,
);
return;
}
this.log(
`##[warning]No major version found corresponding to input version \$\{versionInput.version}`,
);
this.log(`##vso[task.setvariable variable=shouldDeploy;isoutput=true]false`);
this.log(
`##vso[task.setvariable variable=majorVersion;isoutput=true]\$\{result.majorVersion}`,
);
Impact Analysis
- Maintainability: Any tweak to CI messaging/ADO variables must be made twice.
- Bug Risk: Small differences between the two command implementations can lead to inconsistent pipeline behavior.
- Code Bloat: Duplicated logic adds noise in two command entrypoints.
Refactoring Recommendations
-
Extract the shared result-handling block into a helper
- Suggested location:
build-tools/packages/build-cli/src/library/latestVersions.ts
- Suggested shape:
logLatestVersionsAdoResult(logFn, inputVersion, result)
- where
logFn is this.log.bind(this)
- Then both commands call the shared helper.
-
Keep the deprecated command as a thin wrapper
- Since
check/latestVersions.ts is already deprecated, keep only the parts that differ (argument parsing + version discovery), then delegate result reporting to the shared helper.
Implementation Checklist
Analysis Metadata
- Analyzed Files: 2 (plus targeted scanning of build-cli sources)
- Detection Method: Serena semantic inspection + cross-file duplicate-window scan
- Commit:
19a716b6250d945acb514205d6f452bd524b4a57
- Analysis Date: 2026-04-05
Generated by Duplicate Code Detector · ◷
To install this agentic workflow, run
gh aw add github/gh-aw/.github/workflows/duplicate-code-detector.md@94662b1dee8ce96c876ba9f33b3ab8be32de82a4
Analysis of commit
19a716b6250d945acb514205d6f452bd524b4a57Assignee:
@copilotSummary
The
latestVersionsCI command logic contains an identical (>10 LOC) block that logs status/warnings and sets Azure DevOps output variables. This block is duplicated between the deprecated command (check/latestVersions) and its replacement (vnext/check/latestVersions), increasing maintenance cost and risk of behavior drift.Duplication Details
Pattern: ADO output variable + warning logging for
isLatestInMajorresultbuild-tools/packages/build-cli/src/commands/check/latestVersions.ts(lines 51–79)build-tools/packages/build-cli/src/commands/vnext/check/latestVersions.ts(lines 63–91)Code sample (duplicated block)
Impact Analysis
Refactoring Recommendations
Extract the shared result-handling block into a helper
build-tools/packages/build-cli/src/library/latestVersions.tslogLatestVersionsAdoResult(logFn, inputVersion, result)logFnisthis.log.bind(this)Keep the deprecated command as a thin wrapper
check/latestVersions.tsis already deprecated, keep only the parts that differ (argument parsing + version discovery), then delegate result reporting to the shared helper.Implementation Checklist
src/library/latestVersions.tsfor ADO variable/reporting logicAnalysis Metadata
19a716b6250d945acb514205d6f452bd524b4a57