Skip to content

Commit 63b2832

Browse files
committed
Lint updates
Signed-off-by: James Taylor <[email protected]>
1 parent 91107c9 commit 63b2832

File tree

4 files changed

+51
-38
lines changed

4 files changed

+51
-38
lines changed

.github/workflows/golangci-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ jobs:
2929
- name: golangci-lint
3030
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
3131
with:
32-
version: v1.62
32+
version: v2.1

.golangci.yml

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
run:
2-
timeout: 5m
1+
version: "2"
32
linters:
4-
disable-all: true
3+
default: none
54
enable:
65
- asciicheck
76
- bidichk
@@ -22,23 +21,18 @@ linters:
2221
- forbidigo
2322
- forcetypeassert
2423
- funlen
25-
- gci
2624
- gochecknoglobals
2725
- gochecknoinits
2826
- gocognit
2927
- goconst
3028
- gocritic
3129
- gocyclo
3230
- godot
33-
- gofmt
34-
- gofumpt
3531
- goheader
36-
- goimports
3732
- gomoddirectives
3833
- gomodguard
3934
- goprintffuncname
4035
- gosec
41-
- gosimple
4236
- govet
4337
- grouper
4438
- importas
@@ -64,30 +58,49 @@ linters:
6458
- rowserrcheck
6559
- sqlclosecheck
6660
- staticcheck
67-
- stylecheck
68-
- tenv
6961
- testpackage
7062
- thelper
7163
- tparallel
72-
- typecheck
7364
- unconvert
7465
- unparam
7566
- unused
7667
- varnamelen
7768
- wastedassign
7869
- whitespace
7970
- wsl
80-
linters-settings:
81-
errorlint:
82-
errorf: true
83-
funlen:
84-
lines: 100
85-
nolintlint:
86-
require-explanation: true
87-
require-specific: true
88-
issues:
89-
exclude-rules:
90-
- path: _test\.go
91-
text: "dot-imports"
92-
linters:
93-
- revive
71+
settings:
72+
errorlint:
73+
errorf: true
74+
funlen:
75+
lines: 100
76+
nolintlint:
77+
require-explanation: true
78+
require-specific: true
79+
exclusions:
80+
generated: lax
81+
presets:
82+
- comments
83+
- common-false-positives
84+
- legacy
85+
- std-error-handling
86+
rules:
87+
- linters:
88+
- revive
89+
path: _test\.go
90+
text: dot-imports
91+
paths:
92+
- third_party$
93+
- builtin$
94+
- examples$
95+
formatters:
96+
enable:
97+
- gci
98+
- gofmt
99+
- gofumpt
100+
- goimports
101+
exclusions:
102+
generated: lax
103+
paths:
104+
- third_party$
105+
- builtin$
106+
- examples$

internal/util/k8s.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ func CreateChaincodeJob(
480480
}
481481
}
482482

483-
jobName := jobDefinition.ObjectMeta.Name
483+
jobName := jobDefinition.Name
484484

485485
logger.Debugf(
486486
"Creating chaincode job for chaincode ID %s: %s/%s",

test/testscript_helpers.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -130,19 +130,19 @@ func jobInfoCmd(script *testscript.TestScript, _ bool, args []string) {
130130
job := waitForChaincodeJob(script, cfg, cclabel, cchash)
131131

132132
var err error
133-
_, err = script.Stdout().Write([]byte(fmt.Sprintf("Job name: %s\n", job.GetName())))
133+
_, err = script.Stdout().Write(fmt.Appendf(nil, "Job name: %s\n", job.GetName()))
134134
script.Check(err)
135135

136-
_, err = script.Stdout().Write([]byte(fmt.Sprintf("Job namespace: %s\n", job.GetNamespace())))
136+
_, err = script.Stdout().Write(fmt.Appendf(nil, "Job namespace: %s\n", job.GetNamespace()))
137137
script.Check(err)
138138

139139
for k, v := range job.GetLabels() {
140-
_, err = script.Stdout().Write([]byte(fmt.Sprintf("Job label: %s=%s\n", k, v)))
140+
_, err = script.Stdout().Write(fmt.Appendf(nil, "Job label: %s=%s\n", k, v))
141141
script.Check(err)
142142
}
143143

144144
for k, v := range job.GetAnnotations() {
145-
_, err = script.Stdout().Write([]byte(fmt.Sprintf("Job annotation: %s=%s\n", k, v)))
145+
_, err = script.Stdout().Write(fmt.Appendf(nil, "Job annotation: %s=%s\n", k, v))
146146
script.Check(err)
147147
}
148148
}
@@ -163,36 +163,36 @@ func podInfoCmd(script *testscript.TestScript, _ bool, args []string) {
163163
podname := pod.GetName()
164164

165165
var err error
166-
_, err = script.Stdout().Write([]byte(fmt.Sprintf("Pod name: %s\n", podname)))
166+
_, err = script.Stdout().Write(fmt.Appendf(nil, "Pod name: %s\n", podname))
167167
script.Check(err)
168168

169-
_, err = script.Stdout().Write([]byte(fmt.Sprintf("Pod namespace: %s\n", pod.GetNamespace())))
169+
_, err = script.Stdout().Write(fmt.Appendf(nil, "Pod namespace: %s\n", pod.GetNamespace()))
170170
script.Check(err)
171171

172-
_, err = script.Stdout().Write([]byte(fmt.Sprintf("Pod service account: %s\n", pod.Spec.ServiceAccountName)))
172+
_, err = script.Stdout().Write(fmt.Appendf(nil, "Pod service account: %s\n", pod.Spec.ServiceAccountName))
173173
script.Check(err)
174174

175175
for k, v := range pod.GetLabels() {
176-
_, err = script.Stdout().Write([]byte(fmt.Sprintf("Pod label: %s=%s\n", k, v)))
176+
_, err = script.Stdout().Write(fmt.Appendf(nil, "Pod label: %s=%s\n", k, v))
177177
script.Check(err)
178178
}
179179

180180
for k, v := range pod.GetAnnotations() {
181-
_, err = script.Stdout().Write([]byte(fmt.Sprintf("Pod annotation: %s=%s\n", k, v)))
181+
_, err = script.Stdout().Write(fmt.Appendf(nil, "Pod annotation: %s=%s\n", k, v))
182182
script.Check(err)
183183
}
184184

185185
if pod.Spec.Affinity != nil && pod.Spec.Affinity.NodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution != nil {
186186
for _, t := range pod.Spec.Affinity.NodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms {
187187
for _, e := range t.MatchExpressions {
188-
_, err = script.Stdout().Write([]byte(fmt.Sprintf("Pod affinity: %v=%v op=%v\n", e.Key, e.Values, e.Operator)))
188+
_, err = script.Stdout().Write(fmt.Appendf(nil, "Pod affinity: %v=%v op=%v\n", e.Key, e.Values, e.Operator))
189189
script.Check(err)
190190
}
191191
}
192192
}
193193

194194
for _, t := range pod.Spec.Tolerations {
195-
_, err = script.Stdout().Write([]byte(fmt.Sprintf("Pod toleration: %v=%v:%v op=%v for %vs\n", t.Key, t.Value, t.Effect, t.Operator, t.TolerationSeconds)))
195+
_, err = script.Stdout().Write(fmt.Appendf(nil, "Pod toleration: %v=%v:%v op=%v for %vs\n", t.Key, t.Value, t.Effect, t.Operator, t.TolerationSeconds))
196196
script.Check(err)
197197
}
198198
}

0 commit comments

Comments
 (0)