Skip to content

Refactor: extract shared CodeSource interface — duplicated in 7 analytics components #2238

@mrveiss

Description

@mrveiss

Problem

The CodeSource interface is copy-pasted identically in 7 files:

  1. components/analytics/AnalyticsHeader.vue
  2. components/analytics/SourceManager.vue
  3. components/analytics/CodebaseAnalytics.vue
  4. components/analytics/AddSourceModal.vue
  5. components/analytics/ShareSourceModal.vue
  6. components/analytics/panels/CodebaseAnalyticsHeader.vue
  7. components/analytics/CodebaseAnalyticsLanding.vue

Each file defines:

interface CodeSource {
  id: string
  name: string
  source_type: 'github' | 'local'
  repo: string | null
  branch: string
  status: string
  clone_path: string | null
  [key: string]: unknown
}

This violates DRY and makes it easy for definitions to drift out of sync.

Discovered During

Code review of PR #2225 (refactor/issue-1469 — decompose CodebaseAnalytics.vue).

Impact

Severity: low — No runtime impact today, but any field addition/change must be repeated in 7 places.

Suggested Fix

Extract to a shared types file (e.g., types/analytics.ts or types/codeSource.ts) and import from all 7 components.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions