Skip to content

Refactor safety_check() - Separate validation from enforcement #109

@flyingrobots

Description

@flyingrobots

Part of SRP Refactoring (Priority 2: CLI Layer)

Current Problem

safety_check() in src/cli/main.c combines path checking, git config, error display, and enforcement in one function.

Refactoring Plan

Split into focused functions:

  • validate_working_directory() - Path validation only
  • check_remote_safety() - Remote URL validation
  • enforce_safety_policy() - Decision logic only
  • report_safety_violation() - Error formatting/display

Acceptance Criteria

  • Each validation step isolated
  • Policy decisions separated from checks
  • Error reporting extracted
  • Easier to test each validation
  • Clear separation of concerns
  • Improved error messages

Technical Notes

  • Consider policy configuration
  • Make validators reusable
  • Return structured error information

Related to SRP_REFACTORING_PLAN.md Priority 2.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    refactoringCode refactoring without changing functionalitytech-debtTechnical debt that needs addressing

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions