Skip to content

[duplicate-code] Duplicate Code: Declarative constraint builders repeated in tool_description_enhancer #52154

Description

@github-actions

🔍 Duplicate Code Detected: Declarative Constraint Builders

Analysis of commit c993af6

Assignee: @copilot

Summary

contains a large family of per-tool constraint builders that all follow the same skeleton: nil guard, slice setup, , a handful of field gates, and . The differences are mostly declarative strings and field selectors, but the control flow is duplicated 33 times in one file.

📊 Duplication Details - 2026-08-11

Duplication Details

Pattern: Per-tool constraint builders

  • Severity: Medium
  • Occurrences: 33 builders ( appears 33 times)
  • Locations:
    • ()
    • ()
    • ()
    • ()
  • Code Sample:

Impact Analysis

  • Maintainability: Adding or rewording a constraint pattern requires touching many near-identical functions by hand.
  • Bug Risk: Gating rules and phrasing can drift between tools when only one copy is updated.
  • Code Bloat: The duplication obscures the actual catalog of constraints behind repeated plumbing.

Refactoring Recommendations

  1. Move simple constraint builders to a descriptor table

    • Extract common rendering into a shared helper in .
    • Estimated effort: medium.
    • Benefits: new tools become data additions instead of new boilerplate functions.
  2. Keep bespoke functions only for complex tools

    • Reserve hand-written builders for cases with genuinely unique branching.
    • Estimated effort: low to medium.
    • Benefits: keeps flexibility while removing the repeated skeleton.

Implementation Checklist

  • Group the 33 builders by repeated sentence shapes
  • Introduce a shared constraint-rendering descriptor/helper
  • Migrate the simplest builders first
  • Leave only genuinely bespoke builders as code
  • Update tool-description tests

Analysis Metadata

  • Analyzed Files: 1220 changed non-test Go files, with semantic focus on
  • Detection Method: Serena semantic code analysis plus targeted pattern search
  • Commit:
  • Analysis Date: 2026-08-11T22:09:51Z

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • proxy.golang.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "proxy.golang.org"

See Network Configuration for more information.

Generated by 🔍 Duplicate Code Detector · gpt54 · 118.3 AIC · ⊞ 12.8K ·

  • expires on Aug 13, 2026, 2:13 PM UTC-08:00

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions