Commit 708d88f
committed
refactor: consolidate Tool interface and eliminate SOLID principle violations
This comprehensive refactoring addresses multiple SOLID principle violations and consolidates the tool architecture:
**SOLID Principle Fixes:**
- **Single Responsibility**: Eliminate hardcoded values by extracting constants and configuration providers
- **Open/Closed**: Remove switch statements in favor of polymorphic tool implementations
- **Interface Segregation**: Consolidate URLProvider and ChecksumProvider into cohesive Tool interface
- **Dependency Inversion**: Abstract configuration access through provider interfaces
**Key Architectural Changes:**
- **Tool Interface Consolidation**: Merge URL generation and checksum verification methods directly into Tool interface, eliminating interface proliferation anti-pattern
- **Constants Extraction**: Centralize magic numbers, timeouts, and URLs in constants.go
- **Configuration Providers**: Abstract environment variable access through ConfigProvider interfaces
- **Platform Abstraction**: Add PlatformMapper for cross-platform binary handling
- **Path Resolution**: Implement PathResolver utilities for consistent tool path management
- **Error Handling**: Standardize error types and wrapping across all tools
**Tool Implementation Updates:**
- **Maven/Mvnd**: Add GetChecksum methods with Apache archive SHA512 verification
- **Node.js**: Enhance SHASUMS256.txt parsing with better error handling
- **Java**: Integrate Foojay Disco API checksum verification
- **Go**: Maintain existing go.dev API integration
- **All Tools**: Implement unified URL generation and checksum verification methods
**Command System Simplification:**
- Replace tool-specific switch statements with polymorphic manager methods
- Consolidate search, validation, and info commands through unified Tool interface
- Eliminate 300+ lines of duplicated tool-specific command handling code
**Download System Integration:**
- Update DownloadConfig to use Tool interface directly for checksum verification
- Remove dependency on separate ChecksumRegistry and URLProvider registrations
- Simplify verification flow through direct tool method calls
**Benefits:**
- **Maintainability**: Related functionality stays together in cohesive interfaces
- **Extensibility**: New tools require zero changes to existing command/download code
- **Testability**: Each tool's functionality can be tested independently
- **Consistency**: Standardized patterns across all tool implementations
- **Simplicity**: Fewer abstractions, clearer design, easier to understand
This refactoring transforms the codebase from an anti-pattern heavy design with interface proliferation and switch statement violations into a clean, SOLID-compliant architecture with proper separation of concerns.1 parent acc1fd4 commit 708d88f
File tree
20 files changed
+2140
-1212
lines changed- cmd
- pkg/tools
20 files changed
+2140
-1212
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
59 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
| |||
0 commit comments