Skip to content
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
183 changes: 79 additions & 104 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,127 +1,102 @@
# Documentation reference https://github.com/golangci/golangci-lint/blob/v1.55.2/.golangci.reference.yml
version: "2"
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

The 'version: "2"' configuration format does not exist for golangci-lint. The golangci-lint configuration file does not use a version field in this manner. This line should be removed as it's not a valid configuration option for golangci-lint v1.x.

Suggested change
version: "2"

Copilot uses AI. Check for mistakes.
run:
skip-dirs-use-default: false
modules-download-mode: readonly
allow-parallel-runners: false

output:
format: colored-line-number
print-issued-lines: true
print-linter-name: true
uniq-by-line: true
sort-results: true

linters-settings:
dogsled:
max-blank-identifiers: 2
errcheck:
check-type-assertions: true
check-blank: true
gci:
sections:
- standard
- default
- prefix(github.com/openshift/oadp-operator)
goconst:
min-len: 3
min-occurrences: 5
gofmt:
simplify: true
goheader:
# copy from ./hack/boilerplate.go.txt
template: |-
Copyright 2021.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
govet:
enable-all: true
misspell:
locale: US
nakedret:
max-func-lines: 30
nolintlint:
allow-unused: false
allow-no-explanation: []
require-explanation: true
require-specific: true
revive:
# TODO enable!
# enable-all-rules: true
rules:
- name: line-length-limit
disabled: true
# TODO delete after
- name: blank-imports
- name: dot-imports
- name: duplicated-imports
- name: import-alias-naming
- name: import-shadowing
- name: redundant-import-alias
unparam:
check-exported: true

linters:
disable-all: true
# TODO enable commented ones
default: none
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

The 'linters.default' field is set to 'none', which is not a standard configuration option in golangci-lint v1.x. To disable all linters by default and only enable specific ones, use 'linters.disable-all: true' instead. The current configuration may not work as expected.

Suggested change
default: none
disable-all: true

Copilot uses AI. Check for mistakes.
enable:
- asasalint
- asciicheck
- bidichk
# - bodyclose
- dogsled
# - dupword
# - durationcheck
# - errcheck
- errchkjson
- exportloopref
- gci
# - ginkgolinter
# - goconst
- gofmt
# - goheader
- goprintffuncname
# - gosec
# - gosimple
# - govet
# - ineffassign
- loggercheck
# - misspell
- nakedret
# - nilerr
# - noctx
- nolintlint
- nosprintfhostport
- revive
# - staticcheck
# - stylecheck
# - unconvert
- unparam
# - unused
- usestdlibvars
Comment on lines 7 to 20
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

Critical linters have been removed from the enabled list that were previously active. Important linters like 'errcheck' (checks for unchecked errors), 'gosimple' (simplification suggestions), 'govet' (Go's built-in vet tool), 'ineffassign' (detects ineffectual assignments), 'staticcheck' (comprehensive static analysis), 'unused' (finds unused code), 'gosec' (security checks), 'misspell' (spelling), 'gofmt' (formatting), and 'gci' (import ordering) are no longer enabled. These linters provide essential code quality and security checks. Consider re-enabling these linters unless there is a specific reason to disable them.

Copilot uses AI. Check for mistakes.
fast: false
settings:
dogsled:
max-blank-identifiers: 2
errcheck:
check-type-assertions: true
check-blank: true
goconst:
min-len: 3
min-occurrences: 5
goheader:
template: |-
Copyright 2021.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
govet:
enable-all: true
misspell:
locale: US
Comment on lines +24 to +48
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

Settings for 'errcheck', 'goconst', 'goheader', 'govet', and 'misspell' linters are configured, but these linters are not enabled in the 'linters.enable' list. These settings will have no effect unless the corresponding linters are also enabled. Either remove these unused settings or add the linters to the enabled list.

Copilot uses AI. Check for mistakes.
nakedret:
max-func-lines: 30
nolintlint:
require-explanation: true
require-specific: true
allow-unused: false
revive:
rules:
- name: line-length-limit
disabled: true
- name: blank-imports
- name: dot-imports
- name: duplicated-imports
- name: import-alias-naming
- name: import-shadowing
- name: redundant-import-alias
unparam:
check-exported: true
Comment on lines +21 to +66
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

The configuration structure has been changed incorrectly. In golangci-lint v1.x, linter settings should be under a top-level 'linters-settings' section, not nested under 'linters.settings'. The current structure 'linters.settings' is not valid for golangci-lint v1.x and will likely cause configuration parsing errors.

Copilot uses AI. Check for mistakes.
exclusions:
generated: lax
rules:
- linters:
- revive
text: '^struct-tag: unknown option ''inline'' in JSON tag$'
- linters:
- staticcheck
text: 'ST1000:|ST1020:|ST1021:|ST1022:'
paths:
- third_party$
- builtin$
- examples$
Comment on lines +67 to +79
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

The 'linters.exclusions' section is not a valid configuration structure in golangci-lint v1.x. Exclusion rules should be under 'issues.exclude-rules' or 'issues.exclude-dirs' at the top level, not nested under 'linters.exclusions'. This configuration will not work as intended.

Copilot uses AI. Check for mistakes.
issues:
exclude-use-default: false
exclude-rules:
- linters:
- revive
text: "^struct-tag: unknown option 'inline' in JSON tag$"
- linters:
- stylecheck
text: "ST1000:|ST1020:|ST1021:|ST1022:"
max-issues-per-linter: 0
max-same-issues: 0

severity:
default-severity: error
case-sensitive: false
default: error
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

The 'severity.default' field uses 'error' instead of 'default-severity: error'. In golangci-lint v1.x configuration, the correct field name is 'default-severity', not 'default'. This should be corrected to match the v1.x configuration format.

Suggested change
default: error
default-severity: error

Copilot uses AI. Check for mistakes.
formatters:
enable:
- gci
- gofmt
settings:
gci:
sections:
- standard
- default
- prefix(github.com/openshift/oadp-operator)
gofmt:
simplify: true
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
Comment on lines +85 to +102
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

The 'formatters' section is not a standard golangci-lint configuration section in v1.x. Formatters like 'gci' and 'gofmt' should be enabled as linters in the 'linters.enable' list, not in a separate 'formatters' section. This configuration structure will not be recognized by golangci-lint v1.x.

Copilot uses AI. Check for mistakes.
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ DEFAULT_VERSION := 1.5.4
VERSION ?= $(DEFAULT_VERSION)
OPERATOR_SDK_VERSION ?= v1.34.2
ENVTEST_K8S_VERSION = 1.32 #refers to the version of kubebuilder assets to be downloaded by envtest binary # Kubernetes version from OpenShift 4.19.x
GOLANGCI_LINT_VERSION ?= v1.55.2
GOLANGCI_LINT_VERSION ?= v2.1.2
KUSTOMIZE_VERSION ?= v5.2.1
CONTROLLER_TOOLS_VERSION ?= v0.16.5
OPM_VERSION ?= v1.23.0
Expand Down Expand Up @@ -193,11 +193,17 @@ test: check-go vet envtest ## Run unit tests; run Go linters checks; check if ap
@make bundle-isupdated
@make check-go-dependencies

# Lint CLI needs to be built from the same toolchain version
GOLANGCI_LINT = $(LOCALBIN)/$(BRANCH_VERSION)/golangci-lint
.PHONY: golangci-lint
golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
$(GOLANGCI_LINT): $(LOCALBIN)
$(call go-install-tool-branch,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION))
@if [ -f $(GOLANGCI_LINT) ] && $(GOLANGCI_LINT) --version | grep -q $(GOLANGCI_LINT_VERSION); then \
echo "golangci-lint $(GOLANGCI_LINT_VERSION) is already installed"; \
else \
echo "Installing golangci-lint $(GOLANGCI_LINT_VERSION)"; \
$(call go-install-tool-branch,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)); \
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

The module path 'github.com/golangci/golangci-lint/v2/cmd/golangci-lint' is incorrect as golangci-lint does not have a v2 major version. The correct module path for golangci-lint v1.x is 'github.com/golangci/golangci-lint/cmd/golangci-lint'. Please update this to use the correct module path.

Suggested change
$(call go-install-tool-branch,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)); \
$(call go-install-tool-branch,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)); \

Copilot uses AI. Check for mistakes.
fi
@if [ -L "$(LOCALBIN)/golangci-lint" ]; then \
unlink "$(LOCALBIN)/golangci-lint"; \
fi
Expand Down