Skip to content

Conversation

@flaticols
Copy link
Owner

Summary

  • Add golangci-lint v2 module plugin support via New() function
  • Add new flags for better control over analysis:
    • -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)
  • Structs with unexported fields now report instead of being silently skipped

Test plan

  • All existing tests pass
  • New tests for -unexported, -internal, -ignore flags
  • Manual verification of -output=json format

Copilot AI review requested due to automatic review settings January 11, 2026 18:20
@flaticols flaticols self-assigned this Jan 11, 2026
Copy link

Copilot AI left a 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 {
Copy link

Copilot AI Jan 11, 2026

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.

Suggested change
if err != nil {
if err != nil {
fmt.Fprintln(os.Stderr, "failed to marshal JSON issue:", err)

Copilot uses AI. Check for mistakes.
Comment on lines 44 to 45
// 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\\)"
Copy link

Copilot AI Jan 11, 2026

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.

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI left a 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.

@flaticols flaticols merged commit 403d1a2 into main Jan 11, 2026
2 checks passed
@flaticols flaticols deleted the feature/golangci-lint-v2 branch January 11, 2026 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant