feat: add LogValue() method stub generation to MTLOG005 quick fixes#30
Merged
willibrandon merged 2 commits intomainfrom Aug 9, 2025
Merged
feat: add LogValue() method stub generation to MTLOG005 quick fixes#30willibrandon merged 2 commits intomainfrom
willibrandon merged 2 commits intomainfrom
Conversation
Enhanced MTLOG005 diagnostic to provide dual quick fixes: - Add @ prefix for complex type capturing - Generate LogValue() method stub with sensitive field detection The LogValue() stub generator automatically: - Detects common sensitive fields (password, token, apikey, etc.) - Comments out sensitive fields with TODO markers - Generates proper receiver names and method signatures - Ensures consistent formatting across VS Code and GoLand Added test coverage for both analyzer and GoLand plugin.
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the MTLOG005 diagnostic to automatically generate LogValue() method stubs for complex types, helping developers implement safe logging practices by detecting and commenting out potentially sensitive fields.
- Adds LogValue() method stub generation to MTLOG005 quick fixes
- Implements sensitive field detection and automatic commenting
- Includes comprehensive test coverage for both analyzer and GoLand plugin
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| cmd/mtlog-analyzer/analyzer/quickfix.go | Implements LogValue() method stub generation with sensitive field detection |
| cmd/mtlog-analyzer/analyzer/property_checks.go | Integrates LogValue() stub generation into MTLOG005 diagnostic |
| cmd/mtlog-analyzer/analyzer/suggestedfix_test.go | Adds test case for MTLOG005 suggested fixes |
| cmd/mtlog-analyzer/analyzer/testdata/src/suggestedfix/mtlog005/mtlog005.go | Test data for LogValue() stub generation |
| cmd/mtlog-analyzer/analyzer/testdata/src/suggestedfix/mtlog005/mtlog005.go.golden | Expected output after applying LogValue() stub generation |
| goland-plugin/src/test/kotlin/com/mtlog/analyzer/quickfix/LogValueStubQuickFixTest.kt | Comprehensive test coverage for GoLand plugin quick fixes |
goland-plugin/src/test/kotlin/com/mtlog/analyzer/quickfix/LogValueStubQuickFixTest.kt
Outdated
Show resolved
Hide resolved
goland-plugin/src/test/kotlin/com/mtlog/analyzer/quickfix/LogValueStubQuickFixTest.kt
Outdated
Show resolved
Hide resolved
- Rename 'inCurrentFile' to 'typeInCurrentFile' for better clarity - Remove debug println statements from GoLand plugin tests - Keep hardcoded newlines and TODO format unchanged (working as intended)
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
Enhanced the MTLOG005 diagnostic to generate LogValue() method stubs for complex types, helping developers implement safe logging practices by automatically detecting and commenting out sensitive fields.
Type of change
Checklist
go test ./...)golangci-lint run)Additional notes
Example generated code: