-
Notifications
You must be signed in to change notification settings - Fork 0
Add golangci-lint v2 support and new flags #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds golangci-lint v2 module plugin support and introduces several new flags to enhance the positionless analyzer's functionality. The changes enable better control over analysis behavior and improve integration with golangci-lint workflows.
Changes:
- Added
New()function for golangci-lint v2 module plugin support - Introduced four new flags:
-unexported(include structs with unexported fields),-internal(auto-allow unexported in internal/ packages),-ignore=PATTERN(skip matching struct types), and-output=json(golangci-lint compatible JSON output) - Changed behavior to report (rather than silently skip) structs with unexported fields, with optional fix generation based on flags
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 16 comments.
Show a summary per file
| File | Description |
|---|---|
| main.go | Core implementation: added New() function, flag definitions, internal/unexported detection logic, pattern matching, JSON output, and modified fix generation to handle unexported fields |
| main_test.go | Added test cases for new -unexported, -internal, and -ignore flags |
| testdata/src/unexported/unexported.go | Test data for -unexported flag validation |
| testdata/src/internal/config/config.go | Test data for -internal flag validation with internal packages |
| testdata/src/ignore/ignore.go | Test data for -ignore pattern matching |
| testdata/src/edge/edge.go | Updated test expectations to reflect new behavior of reporting unexported field structs |
| README.md | Added golangci-lint v2 setup instructions and flag documentation |
| CLAUDE.md | Added documentation for new architecture components and verification steps |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // singlechecker.Main() calls os.Exit() and deferred functions don't run. | ||
| func printJSONIssue(issue JSONIssue) { | ||
| data, err := json.Marshal(issue) | ||
| if err != nil { |
Copilot
AI
Jan 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The printJSONIssue function silently swallows JSON marshalling errors. While marshalling a JSONIssue struct should rarely fail, consider logging the error to help diagnose issues in production. Silent failures in output formatting can be difficult to debug.
| if err != nil { | |
| if err != nil { | |
| fmt.Fprintln(os.Stderr, "failed to marshal JSON issue:", err) |
testdata/src/edge/edge.go
Outdated
| // Should trigger but without fix: struct with anonymous fields (unexported) | ||
| anon := Anonymous{"text", 42} // want "positional struct literal initialization is fragile \\(cannot auto-fix: contains unexported fields\\)" |
Copilot
AI
Jan 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test comment states "struct with anonymous fields (unexported)" but the Anonymous struct has anonymous fields of built-in types (string, int) which are actually exported types. Anonymous/embedded fields of exported types (like string, int) are considered exported. The analyzer may not correctly identify these as unexported, leading to test failures. Please verify the expected behavior and update either the test or the implementation accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 10 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
New()function-unexported- include structs with unexported fields-internal- auto-allow unexported in internal/ packages-ignore=PATTERN- skip matching struct types-output=json|text- output format (json is golangci-lint compatible)Test plan
-unexported,-internal,-ignoreflags-output=jsonformat