mirror of
https://github.com/ivuorinen/gh-action-readme.git
synced 2026-03-12 07:00:00 +00:00
refactor: major codebase improvements and test framework overhaul
This commit represents a comprehensive refactoring of the codebase focused on improving code quality, testability, and maintainability. Key improvements: - Implement dependency injection and interface-based architecture - Add comprehensive test framework with fixtures and test suites - Fix all linting issues (errcheck, gosec, staticcheck, goconst, etc.) - Achieve full EditorConfig compliance across all files - Replace hardcoded test data with proper fixture files - Add configuration loader with hierarchical config support - Improve error handling with contextual information - Add progress indicators for better user feedback - Enhance Makefile with help system and improved editorconfig commands - Consolidate constants and remove deprecated code - Strengthen validation logic for GitHub Actions - Add focused consumer interfaces for better separation of concerns Testing improvements: - Add comprehensive integration tests - Implement test executor pattern for better test organization - Create extensive YAML fixture library for testing - Fix all failing tests and improve test coverage - Add validation test fixtures to avoid embedded YAML in Go files Build and tooling: - Update Makefile to show help by default - Fix editorconfig commands to use eclint properly - Add comprehensive help documentation to all make targets - Improve file selection patterns to avoid glob errors This refactoring maintains backward compatibility while significantly improving the internal architecture and developer experience.
This commit is contained in:
80
internal/interfaces.go
Normal file
80
internal/interfaces.go
Normal file
@@ -0,0 +1,80 @@
|
||||
// Package internal defines focused interfaces following Interface Segregation Principle.
|
||||
package internal
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/schollz/progressbar/v3"
|
||||
|
||||
"github.com/ivuorinen/gh-action-readme/internal/errors"
|
||||
)
|
||||
|
||||
// MessageLogger handles informational output messages.
|
||||
type MessageLogger interface {
|
||||
Info(format string, args ...any)
|
||||
Success(format string, args ...any)
|
||||
Warning(format string, args ...any)
|
||||
Bold(format string, args ...any)
|
||||
Printf(format string, args ...any)
|
||||
Fprintf(w *os.File, format string, args ...any)
|
||||
}
|
||||
|
||||
// ErrorReporter handles error output and reporting.
|
||||
type ErrorReporter interface {
|
||||
Error(format string, args ...any)
|
||||
ErrorWithSuggestions(err *errors.ContextualError)
|
||||
ErrorWithContext(code errors.ErrorCode, message string, context map[string]string)
|
||||
ErrorWithSimpleFix(message, suggestion string)
|
||||
}
|
||||
|
||||
// ErrorFormatter handles formatting of contextual errors.
|
||||
type ErrorFormatter interface {
|
||||
FormatContextualError(err *errors.ContextualError) string
|
||||
}
|
||||
|
||||
// ProgressReporter handles progress indication and status updates.
|
||||
type ProgressReporter interface {
|
||||
Progress(format string, args ...any)
|
||||
}
|
||||
|
||||
// OutputConfig provides configuration queries for output behavior.
|
||||
type OutputConfig interface {
|
||||
IsQuiet() bool
|
||||
}
|
||||
|
||||
// ProgressManager handles progress bar creation and management.
|
||||
type ProgressManager interface {
|
||||
CreateProgressBar(description string, total int) *progressbar.ProgressBar
|
||||
CreateProgressBarForFiles(description string, files []string) *progressbar.ProgressBar
|
||||
FinishProgressBar(bar *progressbar.ProgressBar)
|
||||
FinishProgressBarWithNewline(bar *progressbar.ProgressBar)
|
||||
UpdateProgressBar(bar *progressbar.ProgressBar)
|
||||
ProcessWithProgressBar(
|
||||
description string,
|
||||
items []string,
|
||||
processFunc func(item string, bar *progressbar.ProgressBar),
|
||||
)
|
||||
}
|
||||
|
||||
// OutputWriter combines message logging and progress reporting for general output needs.
|
||||
type OutputWriter interface {
|
||||
MessageLogger
|
||||
ProgressReporter
|
||||
OutputConfig
|
||||
}
|
||||
|
||||
// ErrorManager combines error reporting and formatting for comprehensive error handling.
|
||||
type ErrorManager interface {
|
||||
ErrorReporter
|
||||
ErrorFormatter
|
||||
}
|
||||
|
||||
// CompleteOutput combines all output interfaces for backward compatibility.
|
||||
// This should be used sparingly and only where all capabilities are truly needed.
|
||||
type CompleteOutput interface {
|
||||
MessageLogger
|
||||
ErrorReporter
|
||||
ErrorFormatter
|
||||
ProgressReporter
|
||||
OutputConfig
|
||||
}
|
||||
Reference in New Issue
Block a user