Back to all reviewers

Centralize configuration management

ghostty-org/ghostty
Based on 3 comments
Swift

Avoid hardcoded or duplicated configuration values by centralizing them in a dedicated location. When configurations are needed across multiple components, extract the logic for accessing and applying them so it can be reused. This prevents inconsistencies when configurations change and makes the codebase more maintainable.

Configurations Swift

Reviewer Prompt

Avoid hardcoded or duplicated configuration values by centralizing them in a dedicated location. When configurations are needed across multiple components, extract the logic for accessing and applying them so it can be reused. This prevents inconsistencies when configurations change and makes the codebase more maintainable.

Instead of this:

private enum WindowConfig {
    static let defaultSize = CGSize(width: 800, height: 600)
}

Do this:

// In a centralized configuration file/class
struct WindowConfigManager {
    func getDefaultSize(from config: AppConfig) -> CGSize {
        // Extract from config or fallback to default
        return CGSize(
            width: config.windowWidth ?? 800,
            height: config.windowHeight ?? 600
        )
    }
}

// When using the configuration
let windowSize = windowConfigManager.getDefaultSize(from: appConfig)

This approach ensures configurations are managed consistently, prevents duplicate values across the codebase, and makes it easier to update configuration behavior in one place.

3
Comments Analyzed
Swift
Primary Language
Configurations
Category

Source Discussions