kuberay icon indicating copy to clipboard operation
kuberay copied to clipboard

[Chore] Upgrade golangci-lint to v2.7.2 and adjust linting configurations

Open seanlaii opened this issue 3 months ago • 4 comments

Why are these changes needed?

golangci-lint v1 is no longer maintained and has reached end-of-life. To ensure code robustness and continue following Go best practices, we need to upgrade to golangci-lint v2.

This PR focuses on the configuration migration to unblock the upgrade

  1. Migrate golangci-lint to v2.7.2 format - Update the configuration file to be compatible with golangci-lint v2 syntax and structure.
  2. Temporarily disable problematic linters/formatters - Some linters and formatters produce new lint errors under v2. These are disabled in this PR to unblock the migration:
  • errorlint
  • gosec
  • govet
  • noctx
  • revive
  • staticcheck
  • testifylint
  • errcheck
  • gci

Follow-up work - The lint errors surfaced by these disabled linters will be addressed in subsequent PRs. These follow-up tasks are well-scoped and can be picked up by other contributors to parallelize the effort. The tasks are created in #4008.

Key changes include

Separation of Linters and Formatters: gofmt, goimports, and gci have been moved from the linters.enable list to the new top-level formatters.enable section, reflecting their primary role. Their settings are now under formatters.settings. Merge of the Linters: staticcheck, stylecheck, and gosimple are merged into one linter, staticcheck.

Crucially, all custom configurations (gocyclo, gci, goimports) and specific path exclusions have been preserved and migrated to the new v2.0 schema. This upgrade ensures we leverage the latest improvements and features of golangci-lint while maintaining our established code quality standards.

For more details on the changes in v2.0, please refer to the official migration guide: https://golangci-lint.run/product/migration-guide/

Related issue number

Part of #4008

Checks

  • [ ] I've made sure the tests are passing.
  • Testing Strategy
    • [ ] Unit tests
    • [ ] Manual tests
    • [ ] This PR is not tested :(

seanlaii avatar Aug 29 '25 01:08 seanlaii

Hi @seanlaii , I'm wondering if there's any updates on this PR? I think it's required for golang version bump up, thanks!

dentiny avatar Dec 14 '25 12:12 dentiny

Hi @seanlaii , I'm wondering if there's any updates on this PR? I think it's required for golang version bump up, thanks!

Got it. Thanks for the info! Will work on it today.

seanlaii avatar Dec 14 '25 15:12 seanlaii

Hi @Future-Outlier @rueian , please help take a look at this PR when you have a chance to unblock the golang version bump and the lint/format issue fix. Thanks!

seanlaii avatar Dec 14 '25 19:12 seanlaii

Hi @Future-Outlier @rueian , please help take a look at this PR when you have a chance to unblock the golang version bump and the lint/format issue fix. Thanks!

thank you for pinging me, will make this PR this week's priority.

Future-Outlier avatar Dec 15 '25 07:12 Future-Outlier