cluster-api: gci linter no longer autofixing import orders

gci linter is no longer fixing import order with make lint-fix. This issue was noted in #6348. The errors from the linter are opaque making fixing import order a manual and time consuming process for maintainers - and very discouraging for all contributors.

It seems from here that the autofix was disabled in a recent version c/f https://github.com/golangci/golangci-lint/issues/2604. I’m still researching why this occurred and will update with any information here.

We can either

  • remove gci from our golangci-lint.
  • or downgrade to an older version, i.e. roll back #6335

Until the linter’s behaviour in autofixing comes back in line with expectations. I’m in favour of doing a downgrade - gci was really useful when make lint-fix was working.

/kind bug [One or more /area label. See https://github.com/kubernetes-sigs/cluster-api/labels?q=area for the list of labels]

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 23 (21 by maintainers)

Most upvoted comments

Sorry for this, https://github.com/golangci/golangci-lint/pull/2892 has fixed it, let’s wait for the next patch release.

I think we should close this in favor of #6737. This no longer represents the issue with golangci-lint as of version 1.47.

This is also being tracked broadly as a part of #release task https://github.com/kubernetes-sigs/cluster-api/issues/5968

/close

My idea was:

  • keep go 1.17 in go.mod for the v1.2.x release to avoid forcing all CAPI consumers to use Go 1.18
  • bump to go 1.18 in go.mod files on main (we can do that today, golangci-lint still works)
    • bump golangci-lint later on. If it takes too long, bump golangci-lint and find another solution for gci

Yep. We’ve also asked for a release. One of the maintainers wants to get a few more fixes in before a release, but it seems like they can’t find time to implement them unfortunately. See here

https://github.com/golangci/golangci-lint/pull/2892

This PR fixes the issue in golangci-lint. We should try to bump the version as soon as there’s a new release.