Skip to content

Enable medium/low-effort golangci-lint linters#13017

Draft
Copilot wants to merge 4 commits intotrunkfrom
copilot/enable-medium-low-effort-linters
Draft

Enable medium/low-effort golangci-lint linters#13017
Copilot wants to merge 4 commits intotrunkfrom
copilot/enable-medium-low-effort-linters

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 24, 2026

Enables the 20 medium/low-effort linters tracked in #12438 and fixes all resulting violations across the codebase.

Linters enabled

Added to .golangci.yml with appropriate settings:

  • canonicalheader, embeddedstructfieldcheck, errname, exhaustive, forbidigo, gochecknoinits, gocyclo, iface, intrange, iotamixing, makezero, mirror, protogetter, recvcheck, testableexamples, tparallel, unconvert, usetesting, wastedassign, whitespace

Key config choices:

  • exhaustive: default-signifies-exhaustive: true — switches over external enums (e.g. tcell.Key, reflect.Kind) with a default: branch are considered exhaustive
  • forbidigo: bans fmt.Print* with message directing to IOStreams; script/ excluded
  • gocyclo: threshold 30 with //nolint:gocyclo on inherently complex functions (dispatch tables, large interactive flows)

Code fixes (~350 violations resolved)

  • errname: Renamed error types and sentinels to follow Go conventions (SilentErrorErrSilent, CancelErrorErrCancel, PendingErrorErrPending, ErrClosedPagerPipeClosedPagerPipeError, NotInstalledNotInstalledError, etc.) across ~105 files
  • recvcheck: Standardized receiver types — Issue, PullRequest, Repository value-receiver methods promoted to pointer receivers; Client.HTTP() and Editable.Clone() demoted to value receivers
  • forbidigo: CLI commands using fmt.Print* migrated to IOStreams (trustedroot, issue delete, repo garden); iostreams_test.go helper process exempted via //nolint
  • gochecknoinits: lock.go and surveyext/editor.go init() replaced with IIFEs; test-only init() functions annotated with //nolint:gochecknoinits
  • embeddedstructfieldcheck: Embedded fields moved before regular fields with required blank-line separator
  • iotamixing, makezero, wastedassign, usetesting, tparallel, iface: Mechanical fixes throughout
  • Auto-fixed via golangci-lint run --fix: whitespace, mirror, protogetter, intrange, unconvert

⌨️ Start Copilot coding agent tasks without leaving your editor — available in VS Code, Visual Studio, JetBrains IDEs and Eclipse.

Copilot AI and others added 3 commits March 24, 2026 11:05
…xing, makezero, testableexamples, wastedassign, usetesting, tparallel, unconvert, intrange, iface

- canonicalheader: fix cacheTTL header value to canonical form
- embeddedstructfieldcheck: move embedded fields before regular fields in 4 structs
- iotamixing: split const blocks mixing iota with non-iota constants
- makezero: use make([]T, 0, n) instead of make([]T, n) before appending
- testableexamples: add missing Output: comment to ExampleOption_UnwrapOrZero
- wastedassign: remove wasted initial assignments in 4 locations
- usetesting: replace os.MkdirTemp/os.Setenv with t.TempDir/t.Setenv in tests
- tparallel: add t.Parallel() to 8 top-level test functions
- unconvert: remove 16 unnecessary type conversions
- intrange: convert 3 for loops to use integer range syntax
- iface: consolidate identical EditPrompter and Prompt interfaces via type alias

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Rename error variables and types to follow errname linter conventions:
- Exported sentinels: ErrXxx
- Unexported sentinels: errXxx
- Exported error types: XxxError
- Unexported error types: xxxError

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

Enable medium/low-effort linters

3 participants