Skip to content

refactor: establish Single Source of Truth (SSOT) for hardcoded values #18

@ryota-kishimoto

Description

@ryota-kishimoto

概要

コードベース全体でハードコードされた値や重複した定義が散在しており、変更時に複数箇所の修正が必要になっている。Constants.swift等で一元管理すべき。

対象

優先度: 高

  • デフォルト設定値の重複: refreshInterval(30.0), gitCommandTimeout(30.0), defaultTerminal("Terminal"), defaultEditor("Cursor") が SettingsView, ViewModel, GitCommand 等に散在
  • UserDefaultsキーが文字列リテラル: "refreshInterval", "defaultTerminal" 等がタイポリスク
  • コピーライト年の不一致: Info.plist(2024) vs SettingsView(2025)
  • repositories.jsonパスが2箇所: RepositoryStore.swift と SettingsView.swift で別々に定義

優先度: 中

  • GitHub URL が12箇所以上に散在: https://github.com/ryota-kishimoto/gitpeek を定数化
  • Sparkle設定がInfo.plist + build.shで重複: SUFeedURL, SUPublicEDKey, SUScheduledCheckInterval → build.shはInfo.plistから読むべき
  • アプリパス・URL schemeのハードコード: SourceTree, Xcode, Warp, Hyper等のパス/スキーム

優先度: 低

  • バージョンフォールバック "1.0.0": Bundle読めれば表示されないが統一すべき
  • macOS最小バージョン "13.0" の散在: ドキュメント含む11箇所以上

提案する対応

// Constants.swift
enum AppConstants {
    static let repositoryURL = "https://github.com/ryota-kishimoto/gitpeek"
    
    enum Defaults {
        static let refreshInterval: Double = 30.0
        static let gitCommandTimeout: Double = 30.0
        static let defaultTerminal = "Terminal"
        static let defaultEditor = "Cursor"
    }
    
    enum UserDefaultsKey {
        static let refreshInterval = "refreshInterval"
        static let showNotifications = "showNotifications"
        static let defaultTerminal = "defaultTerminal"
        static let defaultEditor = "defaultEditor"
        static let gitCommandTimeout = "gitCommandTimeout"
        static let debugLogging = "debugLogging"
    }
}

build.shではInfo.plistから動的に値を読み取る。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions