microsoft / microsoft/FluidFramework
Duplicate Code: Repeated declarativeTasks blocks for syncpack in fluidBuild.config.cjs
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 4.9k
- Forks
- 586
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 146
Description
🔍 Duplicate Code Detected: Syncpack declarativeTasks definitions
Analysis of commit 96b0702e00ffbee17ca26533a989d44a0f8427ca
Assignee: @copilot
Summary
fluidBuild.config.cjs defines two declarative tasks (syncpack lint-semver-ranges and syncpack list-mismatches) with near-identical inputGlobs/outputGlobs/gitignore blocks. This is a copy-paste pattern where only the task key differs, and it risks the two tasks drifting over time.
Duplication Details
Pattern: identical declarative task configuration objects
- Severity: Medium
- Occurrences: 2
- Locations:
fluidBuild.config.cjs(lines 230-243)fluidBuild.config.cjs(lines 244-257)
- Code Sample:
"syncpack lint-semver-ranges": { inputGlobs: [ "syncpack.config.cjs", "package.json", ...releaseGroupPackageJsonGlobs, ], outputGlobs: [ "package.json", ...releaseGroupPackageJsonGlobs, ], gitignore: ["input", "output"], }, "syncpack list-mismatches": { inputGlobs: [ "syncpack.config.cjs", "package.json", ...releaseGroupPackageJsonGlobs, ], outputGlobs: [ "package.json", ...releaseGroupPackageJsonGlobs, ], gitignore: ["input", "output"], },
Impact Analysis
- Maintainability: Updates to the glob set (e.g., adding/removing inputs) must be made twice.
- Bug Risk: One task can be updated while the other is accidentally left behind, creating inconsistent incremental build behavior.
- Code Bloat: ~28 lines of duplicated configuration.
Refactoring Recommendations
-
Extract a shared task object
- Define a constant like
const syncpackDeclarativeTask = { inputGlobs: [...], outputGlobs: [...], gitignore: [...] }. - Reuse it for both keys:
"syncpack lint-semver-ranges": syncpackDeclarativeTask"syncpack list-mismatches": syncpackDeclarativeTask
- Estimated effort: ~0.25h
- Benefits: eliminates drift risk and reduces repeated edits.
- Define a constant like
-
(Optional) Use a small factory helper
- If future variants diverge slightly, use
makeSyncpackTask({ /* overrides */ })with shallow overrides.
- If future variants diverge slightly, use
Implementation Checklist
- Review duplication findings
- Decide between shared-constant vs factory approach
- Implement refactor in
fluidBuild.config.cjs - Verify
fluid-buildincremental behavior unchanged for these tasks
Analysis Metadata
- Analyzed Files: 5 (
*.cjs,*.mjsat repo root; excluding workflows/tests) - Detection Method: Serena semantic + pattern analysis
- Commit: 96b0702e00ffbee17ca26533a989d44a0f8427ca
- Analysis Date: 2026-03-04T07:58:25.089Z
AI generated by Duplicate Code Detector
To add this workflow in your repository, run
gh aw add github/gh-aw/.github/workflows/duplicate-code-detector.md@94662b1dee8ce96c876ba9f33b3ab8be32de82a4. See usage guide.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in fluidBuild.config.cjs at lines 230-257 and compare the two syncpack declarative task definitions. Extract their shared configuration while preserving the two task keys, then verify that fluid-build incremental behavior is unchanged for these tasks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- build-system
- Issue type
- Refactor
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100