Refactor codebase for testability and clean architecture#15
Merged
ChrisJBurns merged 1 commit intomainfrom Jan 15, 2026
Merged
Conversation
This commit addresses critical architecture and code quality issues identified in the comprehensive code review: **Critical Architecture Changes:** - Add PRCreator interface for GitHub client abstraction - Add FileReader interface for file operation abstraction - Add VersionReader, VersionWriter, YAMLUpdater interfaces for file operations - Implement dependency injection in main.go via Dependencies struct **High Priority Code Quality Fixes:** - Fix silent error handling in updateAllFiles - now returns UpdateResult with collected errors - Remove fmt.Printf side effects from library code (internal/github/pr.go) - Add proper error-returning IsGreaterE function, remove deprecated IsGreater **Medium Priority Improvements:** - Consolidate regex patterns in yaml.go using replacementRule struct - Add comprehensive unit tests for main.go orchestration functions - Add tests for WithFileReader option and interface compliance **New Files:** - internal/files/interfaces.go - File operation interfaces and default implementations - internal/github/interfaces.go - FileReader interface for DI - main_test.go - Unit tests for Dependencies, UpdateResult, and orchestration **Test Coverage:** - internal/version: 100% - internal/files: 80.3% - internal/github: 42.6% (up from 35%) - main: 36.1% (up from 0%) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses critical architecture and code quality issues identified in a comprehensive code review. The changes improve testability, error handling, and code maintainability.
Critical Architecture Changes
Dependenciesstruct inmain.goto enable testing of orchestration logicPRCreatorinterface for GitHub clientFileReaderinterface for file operations in GitHub clientVersionReader,VersionWriter,YAMLUpdaterinterfaces for file operationsHigh Priority Code Quality Fixes
updateAllFilesnow returnsUpdateResultwith collected errors instead of silently printing warningsfmt.Printfstatements frominternal/github/pr.goIsGreaterE(a, b string) (bool, error)and removed deprecatedIsGreaterfunctionMedium Priority Improvements
yaml.gousingreplacementRulestructNew Files
internal/files/interfaces.gointernal/github/interfaces.goFileReaderinterface for dependency injectionmain_test.goDependencies,UpdateResult, and orchestration functionsTest Coverage
internal/versioninternal/filesinternal/githubmainTest plan
go build ./...succeedsgolangci-lint run ./...reports 0 issues🤖 Generated with Claude Code