Skip to content
Draft
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
171 changes: 97 additions & 74 deletions .golangci.yml
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
Copy link
Contributor Author

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:

linters:
  exclusions:
    generated: strict

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
Expand All @@ -85,15 +17,106 @@ linters:
- predeclared
- revive
- staticcheck
- typecheck
Copy link
Contributor Author

@seanlaii seanlaii Aug 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typecheck is now enabled by default and cannot be disabled: https://golangci-lint.run/docs/product/migration-guide/#typecheck

- testifylint
- unconvert
- unparam
- unused
- wastedassign
- testifylint
disable-all: true
Copy link
Contributor Author

@seanlaii seanlaii Aug 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change disable-all to

linters:
  default: none

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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ repos:
always_run: true
pass_filenames: false
additional_dependencies:
- github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.8
- github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.4.0
- id: generate-crd-schema
name: generate CRD schemas for use of kubeconform
entry: ./scripts/generate-crd-schema.sh
Expand Down
2 changes: 1 addition & 1 deletion apiserver/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` |
Expand Down
4 changes: 2 additions & 2 deletions apiserver/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--exclude is removed according to https://golangci-lint.run/docs/product/migration-guide/#command-line-flags; therefore, I add it in the golangci.yml.

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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion apiserversdk/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ golangci-lint: ## Download golangci_lint locally if necessary.
.PHONY: lint
lint: golangci-lint fmt vet ## 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)
test -s $(GOLANGCI_LINT) || ($(GOLANGCI_LINT) run --timeout=3m --no-config --allow-parallel-runners)

test: WHAT ?= $(shell go list ./... | grep -v /test/)
test: ENVTEST_K8S_VERSION ?= 1.24.2
Expand Down
2 changes: 1 addition & 1 deletion experimental/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ GOBINDATA ?= $(REPO_ROOT_BIN)/go-bindata
## Tool Versions
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

Expand Down
2 changes: 1 addition & 1 deletion scripts/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added it via linters.exclusions.paths in golangci.yml.

golangci-lint run --fix --timeout 10m0s
popd
done
Loading