Skip to content

Duplicate Code Detected: Repo layout duplicated in fluidBuild.config.cjs and _buildProject.config.cjs #26710

@github-actions

Description

@github-actions

🔍 Duplicate Code Detected: Repo layout config duplication

Analysis of commit 58a9758

Assignee: @copilot

Summary

The repository/workspace layout (release group names → directories + independent package locations) is duplicated in two separate configuration files:

  • fluidBuild.config.cjs (repoPackages)
  • _buildProject.config.cjs (buildProject.workspaces)

These two blocks describe the same underlying repo topology (client/build-tools/server/gitrest/historian + common/tools packages) in two different schemas, creating a drift risk and requiring parallel updates.

Duplication Details

Pattern: Duplicated repo/workspace layout mapping

  • Severity: Medium

  • Occurrences: 2

  • Locations:

    • fluidBuild.config.cjs (lines 260-294)
    • _buildProject.config.cjs (lines 33-205)
  • Code Sample (excerpt from fluidBuild.config.cjs):

    // fluidBuild.config.cjs (261+)
    repoPackages: {
      "client": { directory: "", /* ... */ },
      "build-tools": { directory: "build-tools" },
      "server": { directory: "server/routerlicious" },
      "gitrest": { directory: "server/gitrest" },
      "historian": { directory: "server/historian" },
    
      "build-common": "common/build/build-common",
      "common-utils": "common/lib/common-utils",
      "protocol-def": "common/lib/protocol-definitions",
    
      "tools": [
        "tools/api-markdown-documenter",
        "tools/benchmark",
        "tools/getkeys",
        "tools/test-tools",
      ],
    },
  • Code Sample (excerpt from _buildProject.config.cjs):

    // _buildProject.config.cjs (33+)
    buildProject: {
      workspaces: {
        "client": { directory: ".", /* ... */ },
        "build-tools": { directory: "./build-tools", /* ... */ },
        "server": { directory: "./server/routerlicious", /* ... */ },
        "gitrest": { directory: "server/gitrest", /* ... */ },
        "historian": { directory: "server/historian", /* ... */ },
    
        "`@fluidframework/build-common`": { directory: "common/build/build-common", /* ... */ },
        "`@fluidframework/common-utils`": { directory: "common/lib/common-utils", /* ... */ },
        "`@fluidframework/protocol-definitions`": { directory: "common/lib/protocol-definitions", /* ... */ },
    
        "`@fluid-tools/api-markdown-documenter`": { directory: "tools/api-markdown-documenter", /* ... */ },
        "`@fluid-tools/benchmark`": { directory: "tools/benchmark", /* ... */ },
        "`@fluid-internal/getkeys`": { directory: "tools/getkeys", /* ... */ },
        "`@fluidframework/test-tools`": { directory: "tools/test-tools", /* ... */ },
      },
    },

Impact Analysis

  • Maintainability: Any workspace/release-group directory change (or addition/removal of an independent package workspace) must be made twice, with no automated consistency enforcement.
  • Bug Risk: Drift between these configs can cause build-tooling to disagree about workspace membership, leading to confusing CI/build behavior.
  • Code Bloat: This is effectively two parallel sources-of-truth for the same repo topology.

Refactoring Recommendations

  1. Introduce a single canonical repo-layout module

    • Extract the shared repo layout definition into a dedicated file (e.g. repoLayout.config.cjs), then have both fluidBuild.config.cjs and _buildProject.config.cjs import/derive their specific shapes from it.
    • Estimated effort: Medium
    • Benefits: Eliminates drift risk; a single edit updates both configs.
  2. Add a lightweight consistency check

    • Add a build/policy check that validates both configs resolve to the same set of directories/workspaces.
    • Estimated effort: Low–Medium
    • Benefits: Prevents future divergence even if full refactor is deferred.

Implementation Checklist

  • Confirm which config is intended to be the source-of-truth (comments suggest _buildProject.config.cjs may be renamed to repoLayout.config.cjs in the future)
  • Extract shared layout data into a single module
  • Update both configs to consume shared layout
  • Add a validation check (optional but recommended)
  • Run build-tool validation (e.g. tasks relying on repo/workspace enumeration)

Analysis Metadata

  • Analyzed Files: 5 (only .cjs/.mjs present in this checkout)
  • Detection Method: Serena semantic code analysis + manual verification
  • Commit: 58a9758
  • Analysis Date: 2026-03-12T08:00:19.626Z

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions