Skip to content
Merged
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
6 changes: 3 additions & 3 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ jobs:
with:
go-version: ${{ steps.vars.outputs.go_version }}
- name: golangci-lint
uses: golangci/golangci-lint-action@55c2c1448f86e01eaae002a5a3a9624417608d84 # tag=v6.5.2
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # tag=v8.0.0
with:
version: v1.64.8
args: --out-format=colored-line-number
version: v2.1.6
args: --output.text.print-linter-name=true --output.text.colors=true --timeout 10m
working-directory: ${{matrix.working-directory}}
166 changes: 91 additions & 75 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
version: "2"
run:
allow-parallel-runners: true
modules-download-mode: readonly
# Increase the default deadline from 1m as some module operations can take a
# while if uncached!
timeout: 10m
go: "1.24"

timeout: 10m
modules-download-mode: readonly
allow-parallel-runners: true
linters:
# sync from https://github.com/kubernetes-sigs/controller-runtime/blob/main/.golangci.yml
disable-all: true
default: none
enable:
- asasalint
- asciicheck
Expand All @@ -25,10 +23,7 @@ linters:
- goconst
- gocritic
- gocyclo
- gofmt
- goimports
- goprintffuncname
- gosimple
- govet
- importas
- ineffassign
Expand All @@ -40,74 +35,95 @@ linters:
- prealloc
- revive
- staticcheck
- stylecheck
- tagliatelle
- typecheck
- unconvert
- unparam
- unused
- whitespace

issues:
exclude-rules:
# Dot imports for gomega and ginkgo are allowed
# within test files.
- path: _test\.go
text: should not use dot imports
# Ignore error type switch case
- path: "pkg/loader/loader.go"
linters:
- errorlint
# Ignore test files
- linters:
- dupl
- ginkgolinter
path: _test\.go
- linters:
- gocritic
path: "pkg/markers/help.go"
- linters:
- exhaustive
path: "pkg/markers/parse.go|pkg/deepcopy/traverse.go|pkg/genall/help/types.go|pkg/crd/schema.go|pkg/crd/flatten.go"
# Ignore consider pre-allocating variables
- linters:
- prealloc
text: Consider pre-allocating
linters-settings:
govet:
enable-all: true
disable:
- fieldalignment
- shadow
importas:
no-unaliased: true
revive:
# By default, revive will enable only the linting rules that are named in the configuration file.
# So, it's needed to explicitly enable all required rules here.
settings:
govet:
disable:
- fieldalignment
- shadow
enable-all: true
importas:
no-unaliased: true
revive:
# By default, revive will enable only the linting rules that are named in the configuration file.
# So, it's needed to explicitly enable all required rules here.
rules:
# The following rules are recommended https://github.com/mgechev/revive#recommended-configuration
- name: blank-imports
- name: context-as-argument
- name: context-keys-type
- name: dot-imports
- name: error-return
- name: error-strings
- name: error-naming
- name: if-return
- name: increment-decrement
- name: var-naming
- name: var-declaration
- name: range
- name: receiver-naming
- name: time-naming
- name: unexported-return
- name: indent-error-flow
- name: errorf
- name: superfluous-else
- name: unreachable-code
- name: redefines-builtin-id
#
# Rules in addition to the recommended configuration above.
#
- name: bool-literal-in-expr
- name: constant-logical-expr
exclusions:
generated: strict
paths:
- zz_generated.*\.go$
- .*conversion.*\.go$
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
# The following rules are recommended https://github.com/mgechev/revive#recommended-configuration
- name: blank-imports
- name: context-as-argument
- name: context-keys-type
- name: dot-imports
- name: error-return
- name: error-strings
- name: error-naming
- name: if-return
- name: increment-decrement
- name: var-naming
- name: var-declaration
- name: range
- name: receiver-naming
- name: time-naming
- name: unexported-return
- name: indent-error-flow
- name: errorf
- name: superfluous-else
- name: unreachable-code
- name: redefines-builtin-id
#
# Rules in addition to the recommended configuration above.
#
- name: bool-literal-in-expr
- name: constant-logical-expr
# Dot imports for gomega and ginkgo are allowed
# within test files.
- linters:
- revive
path: _test\.go
text: should not use dot imports
# Ignore error type switch case
- linters:
- errorlint
path: pkg/loader/loader.go
# Ignore test files
- linters:
- dupl
- ginkgolinter
path: _test\.go
- linters:
- gocritic
path: pkg/markers/help.go
- linters:
- exhaustive
path: pkg/markers/parse.go|pkg/deepcopy/traverse.go|pkg/genall/help/types.go|pkg/crd/schema.go|pkg/crd/flatten.go
# Ignore consider pre-allocating variables
- linters:
- prealloc
text: Consider pre-allocating
- linters:
- staticcheck
path: (.+)\.go$
text: (QF1008)
formatters:
enable:
- gofmt
- goimports
exclusions:
generated: strict
paths:
- zz_generated.*\.go$
- .*conversion.*\.go$
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ GO_INSTALL := ./hack/go-install.sh
GOLANGCI_LINT_BIN := golangci-lint
GOLANGCI_LINT_VER := $(shell cat .github/workflows/golangci-lint.yml | grep [[:space:]]version: | sed 's/.*version: //')
GOLANGCI_LINT := $(abspath $(TOOLS_BIN_DIR)/$(GOLANGCI_LINT_BIN)-$(GOLANGCI_LINT_VER))
GOLANGCI_LINT_PKG := github.com/golangci/golangci-lint/cmd/golangci-lint
GOLANGCI_LINT_PKG := github.com/golangci/golangci-lint/v2/cmd/golangci-lint

$(GOLANGCI_LINT): # Build golangci-lint from tools folder.
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) $(GOLANGCI_LINT_PKG) $(GOLANGCI_LINT_BIN) $(GOLANGCI_LINT_VER)
Expand Down
7 changes: 2 additions & 5 deletions pkg/markers/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -868,11 +868,8 @@ func (d *Definition) Parse(rawMarker string) (interface{}, error) {
seen[""] = struct{}{} // mark as seen for strict definitions
} else if !d.Empty() && scanner.Peek() != sc.EOF {
// if we expect *and* actually have arguments passed
for {
// parse the argument name
if !expect(scanner, sc.Ident, "argument name") {
break
}
// parse the argument name
for expect(scanner, sc.Ident, "argument name") {
argName := scanner.TokenText()
if !expect(scanner, '=', "equals") {
break
Expand Down