Skip to content

Commit 702fbe4

Browse files
committed
golangci-lint enable most recommended revive checks and fix findings
1 parent a37644c commit 702fbe4

File tree

5 files changed

+37
-6
lines changed

5 files changed

+37
-6
lines changed

.golangci.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,38 @@ linters-settings:
152152
allow-unused: false
153153
allow-leading-space: false
154154
require-specific: true
155+
revive:
156+
rules:
157+
# The following rules are recommended https://github.com/mgechev/revive#recommended-configuration
158+
- name: blank-imports
159+
- name: context-as-argument
160+
- name: context-keys-type
161+
- name: dot-imports
162+
- name: error-return
163+
- name: error-strings
164+
- name: error-naming
165+
- name: exported
166+
#- name: if-return # TODO This is a recommended rule with many findings which may require it's own pr.
167+
- name: increment-decrement
168+
- name: var-naming
169+
- name: var-declaration
170+
- name: package-comments
171+
- name: range
172+
- name: receiver-naming
173+
- name: time-naming
174+
- name: unexported-return
175+
- name: indent-error-flow
176+
- name: errorf
177+
- name: empty-block
178+
- name: superfluous-else
179+
#- name: unused-parameter # TODO This is a recommended rule with many findings which may require it's own pr.
180+
- name: unreachable-code
181+
- name: redefines-builtin-id
182+
#
183+
# Rules in addition to the recommended configuration above.
184+
#
185+
- name: bool-literal-in-expr
186+
- name: constant-logical-expr
155187
gosec:
156188
excludes:
157189
- G307 # Deferring unsafe method "Close" on type "\*os.File"

exp/addons/internal/controllers/clusterresourceset_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ metadata:
188188
return false
189189
}
190190

191-
if binding.Spec.Bindings[0].Resources[0].Applied != true || binding.Spec.Bindings[0].Resources[1].Applied != true {
191+
if !binding.Spec.Bindings[0].Resources[0].Applied || !binding.Spec.Bindings[0].Resources[1].Applied {
192192
return false
193193
}
194194

internal/controllers/machine/machine_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ func TestMachine_Reconcile(t *testing.T) {
282282
if err := env.Get(ctx, key, machine); err != nil {
283283
return false
284284
}
285-
if conditions.Has(machine, clusterv1.InfrastructureReadyCondition) != true {
285+
if !conditions.Has(machine, clusterv1.InfrastructureReadyCondition) {
286286
return false
287287
}
288288
readyCondition := conditions.Get(machine, clusterv1.ReadyCondition)

util/patch/patch_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ func TestPatchHelper(t *testing.T) {
627627
return false
628628
}
629629

630-
return objAfter.Spec.Paused == true &&
630+
return objAfter.Spec.Paused &&
631631
reflect.DeepEqual(obj.Spec.InfrastructureRef, objAfter.Spec.InfrastructureRef)
632632
}, timeout).Should(BeTrue())
633633
})

util/version/version.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,8 @@ func newBuildIdentifiers(ids []string) buildIdentifiers {
104104
func (v buildIdentifiers) compare(o buildIdentifiers) int {
105105
i := 0
106106
for ; i < len(v) && i < len(o); i++ {
107-
if comp := v[i].compare(o[i]); comp == 0 {
108-
continue
109-
} else {
107+
comp := v[i].compare(o[i])
108+
if comp != 0 {
110109
return comp
111110
}
112111
}

0 commit comments

Comments
 (0)