Skip to content

Commit c4a1293

Browse files
authored
Merge pull request #365 from mbaldessari/new-golangci-lint
Fix linting issues from new golangci-lint 2.2.2
2 parents 04a5080 + 231c9bf commit c4a1293

9 files changed

Lines changed: 161 additions & 164 deletions

File tree

.github/workflows/lint.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ jobs:
2222
echo '' > "${APIFILE}"
2323
2424
- name: Run golangci-lint
25-
uses: golangci/golangci-lint-action@v6
25+
uses: golangci/golangci-lint-action@v8
2626
with:
27-
version: v1.64.5
27+
version: v2.2.2
2828
args: --timeout 5m -v
2929

3030
#--exclude SA5011

.golangci.yml

Lines changed: 131 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -1,171 +1,168 @@
1-
linters-settings:
2-
depguard:
3-
# new configuration
4-
rules:
5-
logger:
6-
deny:
7-
# logging is allowed only by logutils.Log,
8-
# logrus is allowed to use only in logutils package.
9-
- pkg: "github.com/sirupsen/logrus"
10-
desc: logging is allowed only by logutils.Log
11-
dupl:
12-
threshold: 100
13-
funlen:
14-
lines: -1 # the number of lines (code + empty lines) is not a right metric and leads to code without empty line or one-liner.
15-
statements: 80
16-
goconst:
17-
min-len: 2
18-
min-occurrences: 3
19-
gocritic:
20-
enabled-tags:
21-
- diagnostic
22-
- experimental
23-
- opinionated
24-
- performance
25-
- style
26-
disabled-checks:
27-
- dupImport # https://github.com/go-critic/go-critic/issues/845
28-
- ifElseChain
29-
- octalLiteral
30-
- whyNoLint
31-
gocyclo:
32-
min-complexity: 45
33-
gofmt:
34-
rewrite-rules:
35-
- pattern: 'interface{}'
36-
replacement: 'any'
37-
goimports:
38-
local-prefixes: github.com/golangci/golangci-lint
39-
mnd:
40-
# don't include the "operation" and "assign"
41-
checks:
42-
- argument
43-
- case
44-
- condition
45-
- return
46-
ignored-numbers:
47-
- '0'
48-
- '1'
49-
- '2'
50-
- '3'
51-
ignored-functions:
52-
- strings.SplitN
53-
govet:
54-
settings:
55-
printf:
56-
funcs:
57-
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
58-
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
59-
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
60-
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
61-
lll:
62-
line-length: 215
63-
misspell:
64-
locale: US
65-
nolintlint:
66-
# https://www.github.com/golangci/golangci-lint/issues/3228
67-
allow-unused: true # report any unused nolint directives
68-
require-explanation: false # don't require an explanation for nolint directives
69-
require-specific: false # don't require nolint directives to be specific about which linter is being skipped
70-
revive:
71-
rules:
72-
- name: unexported-return
73-
disabled: true
74-
- name: unused-parameter
75-
1+
version: "2"
762
linters:
77-
disable-all: true
3+
default: none
784
enable:
795
- asasalint
806
- asciicheck
817
- bidichk
828
- bodyclose
839
- containedctx
84-
#- contextcheck
8510
- depguard
8611
- dogsled
8712
- dupl
8813
- durationcheck
8914
- errcheck
90-
# - exportloopref deprecated by go1.22 and with 1.60.2
9115
- funlen
9216
- ginkgolinter
9317
- gocheckcompilerdirectives
94-
# - gochecknoinits
9518
- goconst
9619
- gocritic
9720
- gocyclo
98-
- gofmt
99-
- goimports
100-
- mnd
10121
- gomodguard
10222
- goprintffuncname
10323
- gosec
104-
- gosimple
10524
- govet
10625
- importas
10726
- ineffassign
10827
- lll
10928
- misspell
29+
- mnd
11030
- nakedret
11131
- noctx
11232
- nolintlint
11333
- revive
11434
- sloglint
11535
- staticcheck
116-
# - stylecheck
117-
- typecheck
11836
- unconvert
11937
- unparam
12038
- unused
12139
- whitespace
122-
#- wsl
12340
- zerologlint
124-
125-
# don't enable:
126-
# - asciicheck
127-
# - scopelint
128-
# - gochecknoglobals
129-
# - gocognit
130-
# - godot
131-
# - godox
132-
# - goerr113
133-
# - interfacer
134-
# - maligned
135-
# - nestif
136-
# - prealloc
137-
# - testpackage
138-
# - wsl
139-
140-
issues:
141-
# Excluding configuration per-path, per-linter, per-text and per-source
142-
exclude-rules:
143-
- path: _test\.go
144-
linters:
145-
- mnd
146-
147-
- path: pkg/golinters/errcheck.go
148-
text: "SA1019: errCfg.Exclude is deprecated: use ExcludeFunctions instead"
149-
- path: pkg/commands/run.go
150-
text: "SA1019: lsc.Errcheck.Exclude is deprecated: use ExcludeFunctions instead"
151-
- path: pkg/commands/run.go
152-
text: "SA1019: e.cfg.Run.Deadline is deprecated: Deadline exists for historical compatibility and should not be used."
153-
154-
- path: pkg/golinters/gofumpt.go
155-
text: "SA1019: settings.LangVersion is deprecated: use the global `run.go` instead."
156-
- path: pkg/golinters/staticcheck_common.go
157-
text: "SA1019: settings.GoVersion is deprecated: use the global `run.go` instead."
158-
- path: pkg/lint/lintersdb/manager.go
159-
text: "SA1019: (.+).(GoVersion|LangVersion) is deprecated: use the global `run.go` instead."
160-
- path: pkg/golinters/unused.go
161-
text: "rangeValCopy: each iteration copies 160 bytes \\(consider pointers or indexing\\)"
162-
- path: test/(fix|linters)_test.go
163-
text: "string `gocritic.go` has 3 occurrences, make it a constant"
164-
exclude-dirs:
165-
- test/testdata_etc # test files
166-
- internal/cache # extracted from Go code
167-
- internal/renameio # extracted from Go code
168-
- internal/robustio # extracted from Go code
169-
170-
run:
171-
timeout: 5m
41+
settings:
42+
depguard:
43+
rules:
44+
logger:
45+
deny:
46+
- pkg: github.com/sirupsen/logrus
47+
desc: logging is allowed only by logutils.Log
48+
dupl:
49+
threshold: 100
50+
funlen:
51+
lines: -1
52+
statements: 80
53+
goconst:
54+
min-len: 2
55+
min-occurrences: 3
56+
gocritic:
57+
disabled-checks:
58+
- dupImport
59+
- ifElseChain
60+
- octalLiteral
61+
- whyNoLint
62+
enabled-tags:
63+
- diagnostic
64+
- experimental
65+
- opinionated
66+
- performance
67+
- style
68+
gocyclo:
69+
min-complexity: 45
70+
govet:
71+
settings:
72+
printf:
73+
funcs:
74+
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
75+
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
76+
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
77+
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
78+
lll:
79+
line-length: 215
80+
misspell:
81+
locale: US
82+
mnd:
83+
checks:
84+
- argument
85+
- case
86+
- condition
87+
- return
88+
ignored-numbers:
89+
- "0"
90+
- "1"
91+
- "2"
92+
- "3"
93+
ignored-functions:
94+
- strings.SplitN
95+
nolintlint:
96+
require-explanation: false
97+
require-specific: false
98+
allow-unused: true
99+
revive:
100+
rules:
101+
- name: unexported-return
102+
disabled: true
103+
- name: unused-parameter
104+
exclusions:
105+
generated: lax
106+
presets:
107+
- comments
108+
- common-false-positives
109+
- legacy
110+
- std-error-handling
111+
rules:
112+
- linters:
113+
- lll
114+
source: ".*operator-sdk:csv:customresourcedefinitions"
115+
- linters:
116+
- goconst
117+
- gocritic
118+
- ineffassign
119+
- mnd
120+
- revive
121+
- staticcheck
122+
path: _test\.go
123+
- path: pkg/golinters/errcheck.go
124+
text: 'SA1019: errCfg.Exclude is deprecated: use ExcludeFunctions instead'
125+
- path: pkg/commands/run.go
126+
text: 'SA1019: lsc.Errcheck.Exclude is deprecated: use ExcludeFunctions instead'
127+
- path: pkg/commands/run.go
128+
text: 'SA1019: e.cfg.Run.Deadline is deprecated: Deadline exists for historical compatibility and should not be used.'
129+
- path: pkg/golinters/gofumpt.go
130+
text: 'SA1019: settings.LangVersion is deprecated: use the global `run.go` instead.'
131+
- path: pkg/golinters/staticcheck_common.go
132+
text: 'SA1019: settings.GoVersion is deprecated: use the global `run.go` instead.'
133+
- path: pkg/lint/lintersdb/manager.go
134+
text: 'SA1019: (.+).(GoVersion|LangVersion) is deprecated: use the global `run.go` instead.'
135+
- path: pkg/golinters/unused.go
136+
text: 'rangeValCopy: each iteration copies 160 bytes \(consider pointers or indexing\)'
137+
- path: test/(fix|linters)_test.go
138+
text: string `gocritic.go` has 3 occurrences, make it a constant
139+
paths:
140+
- test/testdata_etc
141+
- internal/cache
142+
- internal/renameio
143+
- internal/robustio
144+
- third_party$
145+
- builtin$
146+
- examples$
147+
formatters:
148+
enable:
149+
- gofmt
150+
- goimports
151+
settings:
152+
gofmt:
153+
rewrite-rules:
154+
- pattern: interface{}
155+
replacement: any
156+
goimports:
157+
local-prefixes:
158+
- github.com/golangci/golangci-lint
159+
exclusions:
160+
generated: lax
161+
paths:
162+
- test/testdata_etc
163+
- internal/cache
164+
- internal/renameio
165+
- internal/robustio
166+
- third_party$
167+
- builtin$
168+
- examples$

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
VERSION ?= 0.0.4
77
OPERATOR_NAME ?= patterns
88
GOFLAGS=-mod=vendor
9-
GOLANGCI_VERSION ?= 1.64.5
9+
GOLANGCI_VERSION ?= 2.2.2
1010

1111
# CI uses a non-writable home dir, make sure .cache is writable
1212
ifeq ("${HOME}", "/")

cmd/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,11 @@ func printVersion() {
144144
func createGitOpsConfigMap() error {
145145
config, err := ctrl.GetConfig()
146146
if err != nil {
147-
return fmt.Errorf("Failed to get config: %s", err)
147+
return fmt.Errorf("failed to get config: %s", err)
148148
}
149149
clientset, err := kubernetes.NewForConfig(config)
150150
if err != nil {
151-
return fmt.Errorf("Failed to call NewForConfig: %s", err)
151+
return fmt.Errorf("failed to call NewForConfig: %s", err)
152152
}
153153

154154
configMap := corev1.ConfigMap{

internal/controller/argo.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ func newApplicationParameters(p *api.Pattern) []argoapi.HelmParameter {
424424
})
425425
}
426426
}
427-
if !p.ObjectMeta.DeletionTimestamp.IsZero() {
427+
if !p.DeletionTimestamp.IsZero() {
428428
parameters = append(parameters, argoapi.HelmParameter{
429429
Name: "global.deletePattern",
430430
Value: "1",
@@ -541,7 +541,7 @@ func getSharedValueFiles(p *api.Pattern, prefix string) ([]string, error) {
541541

542542
func commonSyncPolicy(p *api.Pattern) *argoapi.SyncPolicy {
543543
var syncPolicy *argoapi.SyncPolicy
544-
if !p.ObjectMeta.DeletionTimestamp.IsZero() {
544+
if !p.DeletionTimestamp.IsZero() {
545545
syncPolicy = &argoapi.SyncPolicy{
546546
// Automated will keep an application synced to the target revision
547547
Automated: &argoapi.SyncPolicyAutomated{

0 commit comments

Comments
 (0)