Skip to content

[duplicate-code] Duplicate Code: project config parsing scaffold repeated across project handlers #40009

@github-actions

Description

@github-actions

🔍 Duplicate Code Detected: Project config parsing scaffold

Analysis of commit f7374e8

Summary

The create/update project handlers repeat the same config-parsing skeleton: log start, allocate config, set default max, read github-token, read project-specific overrides, and emit a summary log. The repeated scaffold spans 3 handlers and is large enough to justify extraction.

Duplication Details

Pattern: Project config parsing scaffold

  • Severity: Medium
  • Occurrences: 3
  • Locations:
    • pkg/workflow/create_project.go (lines 17-64)
    • pkg/workflow/update_project.go (lines 35-84)
    • pkg/workflow/create_project_status_update.go (lines 16-48)
  • Shared logic:
    • check for the config key
    • initialize a config struct
    • set a default max value
    • parse github-token
    • parse a project identifier/URL override
    • log a final summary

Impact Analysis

  • Maintainability: fixes to defaults or token parsing need to be repeated in multiple handlers.
  • Bug Risk: drift between the three parsers can create inconsistent behavior for project-related workflows.
  • Code Bloat: the same parsing skeleton is copy-pasted instead of centralized.

Refactoring Recommendations

  1. Extract a shared project-config helper for the common scaffold.

    • Suggested target: pkg/workflow/project_config_helpers.go
    • Scope: default max, token override, project override, and summary logging.
  2. Keep handler-specific parsing in small callbacks.

    • create-project can keep views and field-definitions logic.
    • update-project can keep target-repo, allowed-repos, and validation logic.
    • create-project-status-update can keep its status-update-specific fields.

Analysis Metadata

  • Analyzed Files: 3
  • Detection Method: Serena semantic code analysis
  • Commit: f7374e8
  • Analysis Date: 2026-06-18

Generated by 🔍 Duplicate Code Detector ·

  • expires on Jun 19, 2026, 10:56 PM UTC-08:00

Metadata

Metadata

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions