Skip to content

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

@github-actions

Description

@github-actions

🔍 Duplicate Code Detected: Syncpack declarativeTasks definitions

Analysis of commit 96b0702

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: 96b0702
  • 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions