refactor: modularize mtlog-analyzer into focused single-responsibility modules#28
Merged
willibrandon merged 3 commits intomainfrom Aug 8, 2025
Merged
Conversation
Split monolithic analyzer.go (1,777 lines) into 12 focused modules: - ast_walker.go (161 lines) - AST traversal utilities - cache.go (94 lines) - template caching - config.go (32 lines) - configuration types - context_checks.go (94 lines) - context usage validation - coordinator.go (53 lines) - check orchestration - diagnostics.go (60 lines) - diagnostic constants - error_checks.go (290 lines) - error logging validation - property_checks.go (228 lines) - property naming/capturing - quickfix.go (407 lines) - suggested fix generation - template_checks.go (258 lines) - template argument validation - validation.go (105 lines) - helper validation functions - analyzer.go reduced to 128 lines
There was a problem hiding this comment.
Pull Request Overview
This refactoring modularizes the monolithic analyzer.go file (1,777 lines) into 12 focused, single-responsibility modules, improving code organization, maintainability, and testability while keeping all files under 410 lines for better readability.
- Modularized analysis functionality into focused files with clear responsibilities
- Maintained all existing functionality while improving code organization
- Added proper error handling in test files for flag setting operations
Reviewed Changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| analyzer.go | Main entry point, reduced from 1,777 lines to 128 lines by extracting functionality |
| validation.go | Property extraction and format specifier validation logic |
| template_checks.go | Template argument validation and suggested fixes generation |
| suppression_test.go | Fixed unchecked error from flag setting operations |
| quickfix.go | Type checking helpers and context key constant generation utilities |
| property_checks.go | Property naming and capturing usage validation logic |
| killswitch_test.go | Fixed unchecked error from flag setting operations |
| error_checks.go | Error logging validation with scope-based error variable detection |
| diagnostics.go | Centralized diagnostic reporting with ID and severity management |
| coordinator.go | Main coordination logic for running all applicable checks |
| context_checks.go | Context usage pattern validation for ForContext and PushProperty |
| config.go | Configuration management with flag extraction helpers |
| cache.go | Template caching and source file reading utilities |
| ast_walker.go | AST traversal and mtlog call detection logic |
- Fix comment in context_checks.go to clarify package vs method calls - Create templateMismatchContext struct to reduce function parameters from 6 to 1 - Document uniqueConstNameMaxAttempts constant with rationale for value 100
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.
Description
Refactored the monolithic
analyzer.gofile (1,777 lines) into 12 focused, single-responsibility modules to improve code organization, maintainability, and test-ability. Each module now handles a specific aspect of the analysis, with all files kept under 410 lines for better readability.Type of change
Checklist
go test ./...)golangci-lint run)Additional notes