Skip to content

Commit 55dbf7b

Browse files
committed
chore: fix golangci-lint issues
1 parent ed20838 commit 55dbf7b

File tree

5 files changed

+42
-40
lines changed

5 files changed

+42
-40
lines changed

.golangci.yml

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,16 @@
11
---
2+
version: "2"
23
run:
3-
timeout: 5m
44
allow-parallel-runners: true
5-
6-
issues:
7-
# don't skip warning about doc comments
8-
# don't exclude the default set of lint
9-
exclude-use-default: false
10-
# restore some of the defaults
11-
# (fill in the rest as needed)
12-
exclude-rules:
13-
- path: "api/*"
14-
linters:
15-
- lll
16-
- path: "internal/*"
17-
linters:
18-
- dupl
19-
- lll
205
linters:
21-
disable-all: true
6+
default: none
227
enable:
238
- copyloopvar
249
- dupl
2510
- errcheck
2611
- ginkgolinter
2712
- goconst
2813
- gocyclo
29-
- gofmt
30-
- goimports
31-
- gosimple
3214
- govet
3315
- ineffassign
3416
- lll
@@ -37,12 +19,34 @@ linters:
3719
- prealloc
3820
- revive
3921
- staticcheck
40-
- typecheck
4122
- unconvert
4223
- unparam
4324
- unused
44-
45-
linters-settings:
46-
revive:
25+
settings:
26+
revive:
27+
rules:
28+
- name: comment-spacings
29+
exclusions:
30+
generated: lax
4731
rules:
48-
- name: comment-spacings
32+
- linters:
33+
- lll
34+
path: api/*
35+
- linters:
36+
- dupl
37+
- lll
38+
path: internal/*
39+
paths:
40+
- third_party$
41+
- builtin$
42+
- examples$
43+
formatters:
44+
enable:
45+
- gofmt
46+
- goimports
47+
exclusions:
48+
generated: lax
49+
paths:
50+
- third_party$
51+
- builtin$
52+
- examples$

internal/controller/account_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func (r *AccountReconciler) reconcileAccount(ctx context.Context, account *cloud
111111

112112
cloudflareAPIToken := string(secret.Data["apiToken"])
113113
if cloudflareAPIToken == "" {
114-
intconditions.MarkFalse(account, errors.New("Secret has no key named \"apiToken\""))
114+
intconditions.MarkFalse(account, errors.New("secret has no key named \"apiToken\""))
115115
return ctrl.Result{RequeueAfter: r.RetryInterval}
116116
}
117117

internal/controller/dnsrecord_controller.go

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func (r *DNSRecordReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
129129
}
130130

131131
if len(zones.Items) == 0 {
132-
intconditions.MarkFalse(dnsrecord, fmt.Errorf("Zone %q not found", zoneName))
132+
intconditions.MarkFalse(dnsrecord, fmt.Errorf("zone %q not found", zoneName))
133133
return ctrl.Result{}, nil
134134
}
135135

@@ -239,33 +239,31 @@ func (r *DNSRecordReconciler) reconcileDNSRecord(ctx context.Context, dnsrecord
239239

240240
// compareDNSRecord compares the DNS record to the DNSRecord object
241241
func (r *DNSRecordReconciler) compareDNSRecord(dnsRecordSpec cloudflareoperatoriov1.DNSRecordSpec, existingRecord cloudflare.DNSRecord) bool {
242-
var isEqual bool = true
243-
244242
if dnsRecordSpec.Name != existingRecord.Name {
245-
isEqual = false
243+
return false
246244
}
247245
if dnsRecordSpec.Type != existingRecord.Type {
248-
isEqual = false
246+
return false
249247
}
250248
if dnsRecordSpec.Type != "SRV" && dnsRecordSpec.Type != "LOC" && dnsRecordSpec.Type != "CAA" {
251249
if dnsRecordSpec.Content != existingRecord.Content {
252-
isEqual = false
250+
return false
253251
}
254252
}
255253
if dnsRecordSpec.TTL != existingRecord.TTL {
256-
isEqual = false
254+
return false
257255
}
258256
if *dnsRecordSpec.Proxied != *existingRecord.Proxied {
259-
isEqual = false
257+
return false
260258
}
261259
if !comparePriority(dnsRecordSpec.Priority, existingRecord.Priority) {
262-
isEqual = false
260+
return false
263261
}
264262
if !compareData(existingRecord.Data, dnsRecordSpec.Data) {
265-
isEqual = false
263+
return false
266264
}
267265

268-
return isEqual
266+
return true
269267
}
270268

271269
// comparePriority compares the priority nil safe

internal/controller/ip_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func (r *IPReconciler) reconcileIP(ctx context.Context, ip *cloudflareoperatorio
136136
// handleStatic handles the static ip
137137
func (r *IPReconciler) handleStatic(ip *cloudflareoperatoriov1.IP) error {
138138
if ip.Spec.Address == "" {
139-
return errors.New("Address is required for static IPs")
139+
return errors.New("address is required for static IPs")
140140
}
141141
if net.ParseIP(ip.Spec.Address) == nil {
142142
return fmt.Errorf("IP address %q is not valid", ip.Spec.Address)

test/utils/utils.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"os/exec"
2323
"strings"
2424

25-
. "github.com/onsi/ginkgo/v2" //nolint:golint,revive
25+
. "github.com/onsi/ginkgo/v2" //nolint:revive,staticcheck
2626
)
2727

2828
const (
@@ -103,7 +103,7 @@ func GetProjectDir() (string, error) {
103103
if err != nil {
104104
return wd, err
105105
}
106-
wd = strings.Replace(wd, "/test/e2e", "", -1)
106+
wd = strings.ReplaceAll(wd, "/test/e2e", "")
107107
return wd, nil
108108
}
109109

0 commit comments

Comments
 (0)