Skip to content

update golangci-lint to 2.1.6 #64

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gimps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

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

importOrder: [std, external, project, kcp, kubernetes]
sets:
Expand Down
104 changes: 60 additions & 44 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

version: "2"
run:
modules-download-mode: readonly
timeout: 20m

linters:
default: none
enable:
- asciicheck
- bidichk
Expand All @@ -31,8 +31,6 @@ linters:
- gocritic
- gocyclo
- godot
- gofmt
- gosimple
- govet
- importas
- ineffassign
Expand All @@ -48,47 +46,65 @@ linters:
- usetesting
- wastedassign
- whitespace
disable-all: true

settings:
depguard:
rules:
main:
deny:
- pkg: io/ioutil
desc: https://go.dev/doc/go1.16#ioutil
- pkg: github.com/ghodss/yaml
desc: use sigs.k8s.io/yaml instead
importas:
alias:
# Sync Agent APIs
- pkg: github.com/kcp-dev/api-syncagent/sdk/apis/(\w+)/(v[\w\d]+)
alias: $1$2
# Kubernetes
- pkg: k8s.io/api/(\w+)/(v[\w\d]+)
alias: $1$2
- pkg: k8s.io/apimachinery/pkg/apis/meta/v1
alias: metav1
- pkg: k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1
alias: apiextensionsv1
- pkg: k8s.io/apimachinery/pkg/api/errors
alias: apierrors
- pkg: k8s.io/apimachinery/pkg/util/errors
alias: utilerrors
# Controller Runtime
- pkg: sigs.k8s.io/controller-runtime/pkg/client
alias: ctrlruntimeclient
no-unaliased: true
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
# gocritic
- path: (.+)\.go$
text: singleCaseSwitch # in most cases this is the beginning of a lookup table and should be kept an obvious table
# staticcheck
- path: (.+)\.go$
text: QF1008 # embedded field names in selectors often make the code more readable, though more verbose
paths:
- zz_generated.*.go
- third_party$
- builtin$
- examples$
issues:
# defaults to 3, which often needlessly hides issues and forces
# to re-run the linter across the entire repo many times
max-same-issues: 0

exclude-files:
- zz_generated.*.go

# NOTE: Do not use commas in the exclude patterns, or else the regex will be
# split and you will be sad: https://github.com/golangci/golangci-lint/issues/665
exclude:
# gocritic
- singleCaseSwitch # in most cases this is the beginning of a lookup table and should be kept an obvious table

linters-settings:
depguard:
rules:
main:
deny:
- { pkg: io/ioutil, desc: https://go.dev/doc/go1.16#ioutil }
- { pkg: github.com/ghodss/yaml, desc: use sigs.k8s.io/yaml instead }

importas:
no-unaliased: true
alias:
# Sync Agent APIs
- pkg: github.com/kcp-dev/api-syncagent/sdk/apis/(\w+)/(v[\w\d]+)
alias: $1$2
# Kubernetes
- pkg: k8s.io/api/(\w+)/(v[\w\d]+)
alias: $1$2
- pkg: k8s.io/apimachinery/pkg/apis/meta/v1
alias: metav1
- pkg: k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1
alias: apiextensionsv1
- pkg: k8s.io/apimachinery/pkg/api/errors
alias: apierrors
- pkg: k8s.io/apimachinery/pkg/util/errors
alias: utilerrors
# Controller Runtime
- pkg: sigs.k8s.io/controller-runtime/pkg/client
alias: ctrlruntimeclient
formatters:
enable:
- gofmt
exclusions:
generated: lax
paths:
- zz_generated.*.go
- third_party$
- builtin$
- examples$
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ $(BUILD_DEST)/%: cmd/%
go build $(GOTOOLFLAGS) -o $@ ./cmd/$*

GOLANGCI_LINT = _tools/golangci-lint
GOLANGCI_LINT_VERSION = 1.64.2
GOLANGCI_LINT_VERSION = 2.1.6

.PHONY: $(GOLANGCI_LINT)
$(GOLANGCI_LINT):
Expand All @@ -53,17 +53,18 @@ $(GOLANGCI_LINT):
${GOLANGCI_LINT_VERSION}

GIMPS = _tools/gimps
GIMPS_VERSION = 0.6.0
GIMPS_VERSION = 0.6.3

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

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

WWHRD = _tools/wwhrd
WWHRD_VERSION = 06b99400ca6db678386ba5dc39bbbdcdadb664ff
Expand Down Expand Up @@ -135,6 +136,7 @@ clean:
lint: $(GOLANGCI_LINT)
$(GOLANGCI_LINT) run \
--verbose \
--timeout 20m \
--print-resources-usage \
./...

Expand All @@ -147,7 +149,6 @@ verify:
./hack/verify-boilerplate.sh
./hack/verify-licenses.sh


### docs

VENVDIR=$(abspath docs/venv)
Expand Down