- Notifications
You must be signed in to change notification settings - Fork 636
Update golangci-lint #2717
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
Update golangci-lint #2717
Conversation
2d74bab to ec69dd3 Compare | "gotest.tools/v3/assert" | ||
| appsv1 "k8s.io/api/apps/v1" | ||
| corev1 "k8s.io/api/core/v1" | ||
| v1 "k8s.io/api/core/v1" |
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.
💯 corev1 What a doozie! 👏🏻
❓ We can enforce it with importas. What do you think of adding these rules?
diff --git .golangci.yaml .golangci.yaml index fca0785dc..09a82f418 100644 --- .golangci.yaml +++ .golangci.yaml @@ -7,6 +7,7 @@ linters: enable: - gomodguard - gosimple + - importas - misspell presets: - bugs @@ -28,6 +29,14 @@ linters-settings: reason: > k8s.io/kubernetes is for managing dependencies of the Kubernetes project, i.e. building kubelet and kubeadm. + importas: + alias: + - pkg: k8s.io/api/(\w+)/(v[\w\d]+) + alias: $1$2 + - pkg: k8s.io/apimachinery/pkg/apis/(\w+)/(v[\w\d]+) + alias: $1$2 + - pkg: k8s.io/apimachinery/pkg/api/errors + alias: apierrors run: build-tags:I think we already comply with the first two rules. The last one requires a couple of changes in internal/controller/postgrescluster/controller_ref_manager.go and internal/controller/postgrescluster/pgbackrest_test.go.
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.
Yeah figured it would be good to go ahead and get that out of the way!
I like importas 👍 i'll add that in. Are there any other rules we can add?
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.
None that I know of right off. Very open to adding more later.
df3d5a8 to 6d41f5a Compare 4ff7f04 to 9887d2f Compare Makezero checks to prevent bugs caused by initializing a slice with non-constant length and later appending to it. internal/patroni/config.go:257:11: append to slice `hba` with non-zero initialized length (makezero) hba = append(hba, value) ^ internal/patroni/config.go:264:10: append to slice `hba` with non-zero initialized length (makezero) hba = append(hba, pgHBAs.Default[i].String())
internal/controller/postgrescluster/pki_test.go:303:21: ineffectual assignment to err (ineffassign) intent, existing, err := createInstanceSecrets(ctx, tClient, instance, initialRoot) internal/controller/postgrescluster/patroni_test.go:363:2: ineffectual assignment to ctx (ineffassign) ctx := context.Background()
internal/controller/postgrescluster/patroni.go:274:4: error is nil but it returns error (nilerr) return custom, err ^ internal/controller/postgrescluster/patroni.go:334:3: error is nil but it returns error (nilerr) return intent, err
Runs `golangci-lint run --fix` to re-order package imports. Fix is wrongly removing some packages so they had to be manually fixed. Link: golangci/golangci-lint#2161
9887d2f to 985ff42 Compare The linter was pinned to 1.42.0 until we update to go1.17 Issue: [sc12565] See: CrunchyData#2717
The linter was pinned to 1.42.0 until we update to go1.17 Issue: [sc12565] See: #2717
The following changes fix linter errors and warnings that appear for golangci-lint version v1.42.0.
Other information:
[sc-11398]