-
Notifications
You must be signed in to change notification settings - Fork 637
[Chore] Upgrade golangci-lint to v2.4.0 and adjust linting configurations #4007
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,14 @@ | ||
linters-settings: | ||
gofmt: | ||
simplify: true | ||
gosec: | ||
excludes: | ||
- G601 | ||
ginkgolinter: | ||
forbid-focus-container: true | ||
goimports: | ||
local-prefixes: github.com/ray-project/kuberay | ||
misspell: | ||
locale: US | ||
nolintlint: | ||
require-explanation: true | ||
require-specific: true | ||
revive: | ||
ignore-generated-header: true | ||
rules: | ||
- name: blank-imports | ||
- name: context-as-argument | ||
- name: context-keys-type | ||
- name: empty-block | ||
- name: error-naming | ||
- name: error-return | ||
- name: error-strings | ||
- name: errorf | ||
- name: exported | ||
disabled: true | ||
- name: if-return | ||
- name: increment-decrement | ||
- name: indent-error-flow | ||
- name: package-comments | ||
- name: range | ||
- name: receiver-naming | ||
- name: redefines-builtin-id | ||
- name: superfluous-else | ||
- name: time-naming | ||
- name: unexported-return | ||
- name: unreachable-code | ||
- name: unused-parameter | ||
- name: var-declaration | ||
- name: var-naming | ||
exclude: | ||
- "**/ray-operator/apis/config/v1alpha1/*.go" | ||
- "**/ray-operator/apis/ray/v1alpha1/*.go" | ||
- "**/ray-operator/apis/ray/v1/*.go" | ||
arguments: | ||
- ["ID", "JSON", "HTTP", "IP"] # AllowList | ||
- [] # DenyList | ||
- - upperCaseConst: true | ||
gocyclo: | ||
min-complexity: 15 | ||
govet: | ||
enable: | ||
- fieldalignment | ||
lll: | ||
line-length: 120 | ||
gci: # Splits all import blocks into different sections and sorts them. | ||
sections: | ||
- standard # Go official imports, like "fmt" | ||
- default # Third-party libraries (anything not in standard or prefix) | ||
- prefix(github.com/ray-project/kuberay) # kuberay packages | ||
skip-generated: true | ||
version: "2" | ||
linters: | ||
default: none | ||
enable: | ||
- asciicheck | ||
- errcheck | ||
- errorlint | ||
- gci | ||
- ginkgolinter | ||
# - gocyclo | ||
- gofmt | ||
- gofumpt | ||
- goimports | ||
- gosec | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
# - lll | ||
- makezero | ||
- misspell | ||
- nilerr | ||
|
@@ -85,15 +17,106 @@ linters: | |
- predeclared | ||
- revive | ||
- staticcheck | ||
- typecheck | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
- testifylint | ||
- unconvert | ||
- unparam | ||
- unused | ||
- wastedassign | ||
- testifylint | ||
disable-all: true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change
according to https://golangci-lint.run/docs/product/migration-guide/#lintersdisable-all. |
||
settings: | ||
staticcheck: | ||
checks: | ||
- all | ||
# Exclude the SA1019 check which checks the usage of deprecated fields. | ||
- "-SA1019" | ||
ginkgolinter: | ||
forbid-focus-container: true | ||
gocyclo: | ||
min-complexity: 15 | ||
gosec: | ||
excludes: | ||
- G601 | ||
govet: | ||
enable: | ||
- fieldalignment | ||
lll: | ||
line-length: 120 | ||
misspell: | ||
locale: US | ||
nolintlint: | ||
require-explanation: true | ||
require-specific: true | ||
revive: | ||
rules: | ||
- name: blank-imports | ||
- name: context-as-argument | ||
- name: context-keys-type | ||
- name: empty-block | ||
- name: error-naming | ||
- name: error-return | ||
- name: error-strings | ||
- name: errorf | ||
- name: exported | ||
disabled: true | ||
- name: if-return | ||
- name: increment-decrement | ||
- name: indent-error-flow | ||
- name: package-comments | ||
- name: range | ||
- name: receiver-naming | ||
- name: redefines-builtin-id | ||
- name: superfluous-else | ||
- name: time-naming | ||
- name: unexported-return | ||
- name: unreachable-code | ||
- name: unused-parameter | ||
- name: var-declaration | ||
- name: var-naming | ||
arguments: | ||
- ["ID", "JSON", "HTTP", "IP"] # AllowList | ||
- [] # DenyList | ||
- - upperCaseConst: true | ||
exclude: | ||
- '**/ray-operator/apis/config/v1alpha1/*.go' | ||
- '**/ray-operator/apis/ray/v1alpha1/*.go' | ||
- '**/ray-operator/apis/ray/v1/*.go' | ||
exclusions: | ||
generated: strict | ||
presets: | ||
- comments | ||
- common-false-positives | ||
- legacy | ||
- std-error-handling | ||
paths: | ||
- third_party$ | ||
- builtin$ | ||
- examples$ | ||
- _generated.go | ||
issues: | ||
max-issues-per-linter: 0 | ||
max-same-issues: 0 | ||
formatters: | ||
enable: | ||
- gci | ||
- gofmt | ||
- gofumpt | ||
- goimports | ||
settings: | ||
gci: # Splits all import blocks into different sections and sorts them. | ||
sections: | ||
- standard # Go official imports, like "fmt" | ||
- default # Third-party libraries (anything not in standard or prefix) | ||
- prefix(github.com/ray-project/kuberay) # kuberay packages | ||
gofmt: | ||
simplify: true | ||
goimports: | ||
local-prefixes: | ||
- github.com/ray-project/kuberay | ||
exclusions: | ||
generated: lax | ||
paths: | ||
- third_party$ | ||
- builtin$ | ||
- examples$ | ||
run: | ||
timeout: 3m | ||
# timeout for analysis, e.g. 30s, 5m, default timeout is disabled | ||
timeout: 10m |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ Typing `make dev-tools` will download and install all of them. The `make clean-d | |
| Software | Version | Link | | ||
| :------- | :------: | -----------------------------------------------------------------------:| | ||
| kind | v0.19.0 | [Install](https://kind.sigs.k8s.io/docs/user/quick-start/#installation) | | ||
| golangci-lint | v1.64.8 | [Install](https://golangci-lint.run/usage/install/) | | ||
| golangci-lint | v2.4.0 | [Install](https://golangci-lint.run/usage/install/) | | ||
| kustomize | v3.8.7 | [install](https://kubectl.docs.kubernetes.io/installation/kustomize/) | | ||
| gofumpt | v0.3.1 | To install `go install mvdan.cc/[email protected]` | | ||
| goimports | latest | To install `go install golang.org/x/tools/cmd/goimports@latest` | | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,7 +87,7 @@ imports: goimports ## Run goimports against code. | |
.PHONY: lint | ||
lint: golangci-lint fmt vet fumpt imports ## Run the linter. | ||
# exclude the SA1019 check which checks the usage of deprecated fields. | ||
test -s $(GOLANGCI_LINT) || ($(GOLANGCI_LINT) run --timeout=3m --exclude='SA1019' --no-config --allow-parallel-runners) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
test -s $(GOLANGCI_LINT) || ($(GOLANGCI_LINT) run --timeout=3m --no-config --allow-parallel-runners) | ||
|
||
build: fmt vet fumpt imports ## Build api server binary. | ||
go build -o ${REPO_ROOT_BIN}/kuberay-apiserver cmd/main.go | ||
|
@@ -248,7 +248,7 @@ MOCKGEN = $(REPO_ROOT_BIN)/mockgen | |
KUSTOMIZE_VERSION ?= v5.4.3 | ||
GOFUMPT_VERSION ?= v0.3.1 | ||
GOIMPORTS_VERSION ?= v0.14.0 | ||
GOLANGCI_LINT_VERSION ?= v1.64.8 | ||
GOLANGCI_LINT_VERSION ?= v2.4.0 | ||
KIND_VERSION ?= v0.19.0 | ||
GOBINDATA_VERSION ?= v4.0.2 | ||
MOCKGEN_VERSION ?= v1.6.0 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,6 @@ dirs_to_lint="ray-operator kubectl-plugin apiserver apiserversdk" | |
for dir in $dirs_to_lint; do | ||
pushd "$dir" | ||
# exclude the SA1019 check which checks the usage of deprecated fields. | ||
golangci-lint run --fix --exclude-files _generated.go --exclude='SA1019' --timeout 10m0s | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added it via |
||
golangci-lint run --fix --timeout 10m0s | ||
popd | ||
done |
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.
According to https://golangci-lint.run/docs/product/migration-guide/#linters-settingsreviveignore-generated-header, change it to: