microsoft / microsoft/FluidFramework

Duplicate Code: Repeated declarativeTasks blocks for syncpack in fluidBuild.config.cjs

Open
#26,641 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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

  1. 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.
  2. (Optional) Use a small factory helper

    • If future variants diverge slightly, use makeSyncpackTask({ /* overrides */ }) with shallow overrides.

Implementation Checklist

  • Review duplication findings
  • Decide between shared-constant vs factory approach
  • Implement refactor in fluidBuild.config.cjs
  • Verify fluid-build incremental behavior unchanged for these tasks

Analysis Metadata

  • Analyzed Files: 5 (*.cjs, *.mjs at 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.