Skip to content

Commit 2a63885

Browse files
authored
Merge pull request #64 from kcp-dev/bump-linter
update golangci-lint to 2.1.6
2 parents f89160c + 38f405e commit 2a63885

File tree

4 files changed

+68
-51
lines changed

4 files changed

+68
-51
lines changed

.gimps.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# This is the configuration for https://github.com/xrstf/gimps.
15+
# This is the configuration for https://codeberg.org/xrstf/gimps.
1616

1717
importOrder: [std, external, project, kcp, kubernetes]
1818
sets:

.golangci.yml

Lines changed: 60 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
version: "2"
1516
run:
1617
modules-download-mode: readonly
17-
timeout: 20m
18-
1918
linters:
19+
default: none
2020
enable:
2121
- asciicheck
2222
- bidichk
@@ -31,8 +31,6 @@ linters:
3131
- gocritic
3232
- gocyclo
3333
- godot
34-
- gofmt
35-
- gosimple
3634
- govet
3735
- importas
3836
- ineffassign
@@ -48,47 +46,65 @@ linters:
4846
- usetesting
4947
- wastedassign
5048
- whitespace
51-
disable-all: true
52-
49+
settings:
50+
depguard:
51+
rules:
52+
main:
53+
deny:
54+
- pkg: io/ioutil
55+
desc: https://go.dev/doc/go1.16#ioutil
56+
- pkg: github.com/ghodss/yaml
57+
desc: use sigs.k8s.io/yaml instead
58+
importas:
59+
alias:
60+
# Sync Agent APIs
61+
- pkg: github.com/kcp-dev/api-syncagent/sdk/apis/(\w+)/(v[\w\d]+)
62+
alias: $1$2
63+
# Kubernetes
64+
- pkg: k8s.io/api/(\w+)/(v[\w\d]+)
65+
alias: $1$2
66+
- pkg: k8s.io/apimachinery/pkg/apis/meta/v1
67+
alias: metav1
68+
- pkg: k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1
69+
alias: apiextensionsv1
70+
- pkg: k8s.io/apimachinery/pkg/api/errors
71+
alias: apierrors
72+
- pkg: k8s.io/apimachinery/pkg/util/errors
73+
alias: utilerrors
74+
# Controller Runtime
75+
- pkg: sigs.k8s.io/controller-runtime/pkg/client
76+
alias: ctrlruntimeclient
77+
no-unaliased: true
78+
exclusions:
79+
generated: lax
80+
presets:
81+
- comments
82+
- common-false-positives
83+
- legacy
84+
- std-error-handling
85+
rules:
86+
# gocritic
87+
- path: (.+)\.go$
88+
text: singleCaseSwitch # in most cases this is the beginning of a lookup table and should be kept an obvious table
89+
# staticcheck
90+
- path: (.+)\.go$
91+
text: QF1008 # embedded field names in selectors often make the code more readable, though more verbose
92+
paths:
93+
- zz_generated.*.go
94+
- third_party$
95+
- builtin$
96+
- examples$
5397
issues:
5498
# defaults to 3, which often needlessly hides issues and forces
5599
# to re-run the linter across the entire repo many times
56100
max-same-issues: 0
57-
58-
exclude-files:
59-
- zz_generated.*.go
60-
61-
# NOTE: Do not use commas in the exclude patterns, or else the regex will be
62-
# split and you will be sad: https://github.com/golangci/golangci-lint/issues/665
63-
exclude:
64-
# gocritic
65-
- singleCaseSwitch # in most cases this is the beginning of a lookup table and should be kept an obvious table
66-
67-
linters-settings:
68-
depguard:
69-
rules:
70-
main:
71-
deny:
72-
- { pkg: io/ioutil, desc: https://go.dev/doc/go1.16#ioutil }
73-
- { pkg: github.com/ghodss/yaml, desc: use sigs.k8s.io/yaml instead }
74-
75-
importas:
76-
no-unaliased: true
77-
alias:
78-
# Sync Agent APIs
79-
- pkg: github.com/kcp-dev/api-syncagent/sdk/apis/(\w+)/(v[\w\d]+)
80-
alias: $1$2
81-
# Kubernetes
82-
- pkg: k8s.io/api/(\w+)/(v[\w\d]+)
83-
alias: $1$2
84-
- pkg: k8s.io/apimachinery/pkg/apis/meta/v1
85-
alias: metav1
86-
- pkg: k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1
87-
alias: apiextensionsv1
88-
- pkg: k8s.io/apimachinery/pkg/api/errors
89-
alias: apierrors
90-
- pkg: k8s.io/apimachinery/pkg/util/errors
91-
alias: utilerrors
92-
# Controller Runtime
93-
- pkg: sigs.k8s.io/controller-runtime/pkg/client
94-
alias: ctrlruntimeclient
101+
formatters:
102+
enable:
103+
- gofmt
104+
exclusions:
105+
generated: lax
106+
paths:
107+
- zz_generated.*.go
108+
- third_party$
109+
- builtin$
110+
- examples$

Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ $(BUILD_DEST)/%: cmd/%
4343
go build $(GOTOOLFLAGS) -o $@ ./cmd/$*
4444

4545
GOLANGCI_LINT = _tools/golangci-lint
46-
GOLANGCI_LINT_VERSION = 1.64.2
46+
GOLANGCI_LINT_VERSION = 2.1.6
4747

4848
.PHONY: $(GOLANGCI_LINT)
4949
$(GOLANGCI_LINT):
@@ -53,17 +53,18 @@ $(GOLANGCI_LINT):
5353
${GOLANGCI_LINT_VERSION}
5454

5555
GIMPS = _tools/gimps
56-
GIMPS_VERSION = 0.6.0
56+
GIMPS_VERSION = 0.6.3
5757

5858
.PHONY: $(GIMPS)
5959
$(GIMPS):
6060
@hack/download-tool.sh \
61-
https://github.com/xrstf/gimps/releases/download/v${GIMPS_VERSION}/gimps_${GIMPS_VERSION}_${GOOS}_${GOARCH}.tar.gz \
61+
https://codeberg.org/xrstf/gimps/releases/download/v${GIMPS_VERSION}/gimps_${GIMPS_VERSION}_${GOOS}_${GOARCH}.tar.gz \
6262
gimps \
6363
${GIMPS_VERSION}
6464

6565
# wwhrd is installed as a Go module rather than from the provided
6666
# binaries because there is no arm64 binary available from the author.
67+
# See https://github.com/frapposelli/wwhrd/issues/141
6768

6869
WWHRD = _tools/wwhrd
6970
WWHRD_VERSION = 06b99400ca6db678386ba5dc39bbbdcdadb664ff
@@ -135,6 +136,7 @@ clean:
135136
lint: $(GOLANGCI_LINT)
136137
$(GOLANGCI_LINT) run \
137138
--verbose \
139+
--timeout 20m \
138140
--print-resources-usage \
139141
./...
140142

@@ -147,7 +149,6 @@ verify:
147149
./hack/verify-boilerplate.sh
148150
./hack/verify-licenses.sh
149151

150-
151152
### docs
152153

153154
VENVDIR=$(abspath docs/venv)

internal/discovery/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func (c *Client) RetrieveCRD(ctx context.Context, gk schema.GroupKind) (*apiexte
8484
// parse and check GroupVersion of the entire list.
8585
gv, err := schema.ParseGroupVersion(resList.GroupVersion)
8686
if err != nil {
87-
return nil, fmt.Errorf("Kubernetes reported invalid API group version %q: %w", resList.GroupVersion, err)
87+
return nil, fmt.Errorf("invalid API group version %q reported by Kubernetes: %w", resList.GroupVersion, err)
8888
}
8989

9090
if gv.Group != gk.Group {
@@ -315,7 +315,7 @@ func (c *Client) getPreferredVersion(resource *metav1.APIResource) (string, erro
315315
// parse and check GroupVersion of the entire list.
316316
gv, err := schema.ParseGroupVersion(resList.GroupVersion)
317317
if err != nil {
318-
return "", fmt.Errorf("Kubernetes reported invalid API group version %q: %w", resList.GroupVersion, err)
318+
return "", fmt.Errorf("invalid API group version %q reported by Kubernetes: %w", resList.GroupVersion, err)
319319
}
320320

321321
if gv.Group != resource.Group {

0 commit comments

Comments
 (0)