Skip to content

Commit 3f53a09

Browse files
author
Ben Moss
committed
Update golangci-lint
1 parent 84203f5 commit 3f53a09

File tree

12 files changed

+77
-19
lines changed

12 files changed

+77
-19
lines changed

.golangci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ linters:
1212
- gocognit
1313
- gomnd
1414
- interfacer
15+
- godot
16+
- goerr113
17+
- nestif
1518
# Run with --fast=false for more extensive checks
1619
fast: true
1720
issues:

cmd/clusterctl/client/cluster/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ type Proxy interface {
215215
}
216216

217217
// retryWithExponentialBackoff repeats an operation until it passes or the exponential backoff times out.
218-
func retryWithExponentialBackoff(opts wait.Backoff, operation func() error) error { //nolint:unparam
218+
func retryWithExponentialBackoff(opts wait.Backoff, operation func() error) error {
219219
log := logf.Log
220220

221221
i := 0

cmd/clusterctl/client/cluster/objectgraph_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ func getDetachedObjectGraphWihObjs(objs []runtime.Object) (*objectGraph, error)
858858
graph := newObjectGraph(nil) // detached from any cluster
859859
for _, o := range objs {
860860
u := &unstructured.Unstructured{}
861-
if err := test.FakeScheme.Convert(o, u, nil); err != nil { //nolint
861+
if err := test.FakeScheme.Convert(o, u, nil); err != nil {
862862
return nil, errors.Wrap(err, "failed to convert object in unstructured")
863863
}
864864
graph.addObj(u)

cmd/clusterctl/client/repository/repository_github.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ func (g *gitHubRepository) downloadFilesFromRelease(release *github.RepositoryRe
304304
return nil, g.handleGithubErr(err, "failed to download file %q from %q release", *release.TagName, fileName)
305305
}
306306
if redirect != "" {
307-
response, err := http.Get(redirect) //nolint:bodyclose (NB: The reader is actually closed in a defer)
307+
response, err := http.Get(redirect) //nolint:bodyclose // (NB: The reader is actually closed in a defer)
308308
if err != nil {
309309
return nil, errors.Wrapf(err, "failed to download file %q from %q release via redirect location %q", *release.TagName, fileName, redirect)
310310
}

cmd/clusterctl/cmd/upgrade_plan.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func runUpgradePlan() error {
105105
if upgradeAvailable {
106106
fmt.Println("You can now apply the upgrade by executing the following command:")
107107
fmt.Println("")
108-
fmt.Println(fmt.Sprintf(" upgrade apply --management-group %s --contract %s", plan.CoreProvider.InstanceName(), plan.Contract))
108+
fmt.Printf(" upgrade apply --management-group %s --contract %s\n", plan.CoreProvider.InstanceName(), plan.Contract)
109109
} else {
110110
fmt.Println("You are already up to date!")
111111
}

cmd/clusterctl/internal/util/yaml.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func JoinYaml(yamls ...[]byte) []byte {
5555

5656
// ToUnstructured takes a YAML and converts it to a list of Unstructured objects
5757
func ToUnstructured(rawyaml []byte) ([]unstructured.Unstructured, error) {
58-
var ret []unstructured.Unstructured //nolint
58+
var ret []unstructured.Unstructured
5959

6060
reader := utilyaml.NewYAMLReader(bufio.NewReader(bytes.NewReader(rawyaml)))
6161
count := 1

controllers/mdutil/util.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ func getIntFromAnnotation(ms *clusterv1.MachineSet, annotationKey string, logger
193193
if !ok {
194194
return int32(0), false
195195
}
196-
intValue, err := strconv.Atoi(annotationValue)
196+
intValue, err := strconv.ParseInt(annotationValue, 10, 64)
197197
if err != nil {
198198
logger.V(2).Info("Cannot convert the value to integer", "annotationValue", annotationValue)
199199
return int32(0), false
@@ -563,7 +563,7 @@ func IsSaturated(deployment *clusterv1.MachineDeployment, ms *clusterv1.MachineS
563563
return false
564564
}
565565
desiredString := ms.Annotations[clusterv1.DesiredReplicasAnnotation]
566-
desired, err := strconv.Atoi(desiredString)
566+
desired, err := strconv.ParseInt(desiredString, 10, 64)
567567
if err != nil {
568568
return false
569569
}

controlplane/kubeadm/controllers/controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ func TestKubeadmControlPlaneReconciler_adoption(t *testing.T) {
554554
"test0": &clusterv1.Machine{
555555
ObjectMeta: metav1.ObjectMeta{
556556
Namespace: cluster.Namespace,
557-
Name: fmt.Sprintf("test0"),
557+
Name: "test0",
558558
Labels: internal.ControlPlaneLabelsForCluster(cluster.Name),
559559
},
560560
Spec: clusterv1.MachineSpec{

controlplane/kubeadm/internal/machine_collection.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,12 @@ func NewFilterableMachineCollection(machines ...*clusterv1.Machine) FilterableMa
4747

4848
// NewFilterableMachineCollectionFromMachineList creates a FilterableMachineCollection from the given MachineList
4949
func NewFilterableMachineCollectionFromMachineList(machineList *clusterv1.MachineList) FilterableMachineCollection {
50+
if machineList == nil {
51+
return nil
52+
}
5053
ss := make(FilterableMachineCollection, len(machineList.Items))
51-
if machineList != nil {
52-
for i := range machineList.Items {
53-
ss.Insert(&machineList.Items[i])
54-
}
54+
for i := range machineList.Items {
55+
ss.Insert(&machineList.Items[i])
5556
}
5657
return ss
5758
}

hack/tools/go.mod

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ go 1.13
55
require (
66
github.com/blang/semver v3.5.1+incompatible
77
github.com/go-bindata/go-bindata v3.1.2+incompatible
8-
github.com/golangci/golangci-lint v1.23.8
8+
github.com/golangci/golangci-lint v1.27.0
99
github.com/joelanford/go-apidiff v0.0.0-20191206194835-106bcff5f060
10-
github.com/onsi/ginkgo v1.11.0
10+
github.com/onsi/ginkgo v1.12.0
1111
github.com/raviqqe/liche v0.0.0-20200229003944-f57a5d1c5be4
12-
golang.org/x/tools v0.0.0-20200204192400-7124308813f3
12+
golang.org/x/tools v0.0.0-20200502202811-ed308ab3e770
13+
honnef.co/go/tools v0.0.1-2020.1.4 // indirect
1314
k8s.io/code-generator v0.18.0
1415
sigs.k8s.io/controller-tools v0.2.9
1516
sigs.k8s.io/kubebuilder/docs/book/utils v0.0.0-20200226075303-ed8438ec10a4

0 commit comments

Comments
 (0)