From 77a6c090d3caf634936f9ef5c74ccce0d39c63a5 Mon Sep 17 00:00:00 2001 From: Kingdon Barrett Date: Tue, 7 Jan 2020 15:35:38 -0500 Subject: [PATCH] chore(linter): Make the mandatory linters happy There are some new linting rules in the updated go-dev from upstream deis/docker-go-dev. --- pkg/gitreceive/build.go | 2 +- pkg/gitreceive/k8s_util.go | 11 +++++++---- pkg/sshd/server_test.go | 4 ++-- pkg/storage/object_test.go | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/pkg/gitreceive/build.go b/pkg/gitreceive/build.go index 04c71c7..6114fcd 100644 --- a/pkg/gitreceive/build.go +++ b/pkg/gitreceive/build.go @@ -354,7 +354,7 @@ func prettyPrintJSON(data interface{}) (string, error) { if err := json.Indent(formatted, output.Bytes(), "", " "); err != nil { return "", err } - return string(formatted.Bytes()), nil + return formatted.String(), nil } func getProcFile(getter storage.ObjectGetter, dirName, procfileKey string, bType buildType) (deisAPI.ProcessType, error) { diff --git a/pkg/gitreceive/k8s_util.go b/pkg/gitreceive/k8s_util.go index b8b6142..f61da4a 100644 --- a/pkg/gitreceive/k8s_util.go +++ b/pkg/gitreceive/k8s_util.go @@ -326,10 +326,13 @@ func createAppEnvConfigSecret(secretsClient client.SecretsInterface, secretName } if _, err := secretsClient.Create(newSecret); err != nil { if apierrors.IsAlreadyExists(err) { - if _, err = secretsClient.Update(newSecret); err != nil { - return err - } - return nil + _, err = secretsClient.Update(newSecret) + // I simplified according to linter, err is either "err" or nil + // So no need for an if-statement here, as before with the redundant if + // statement, it was either returning err or nil just the same... + return err + // KPB: I actually don't agree with this simplification, but I don't know + // how to make the linter ignore it yet... } return err } diff --git a/pkg/sshd/server_test.go b/pkg/sshd/server_test.go index b8ec71e..f40b178 100644 --- a/pkg/sshd/server_test.go +++ b/pkg/sshd/server_test.go @@ -22,7 +22,7 @@ func TestGitPktLine(t *testing.T) { err := gitPktLine(b, str) assert.NoErr(t, err) - outStr := string(b.Bytes()) + outStr := b.String() assert.True(t, len(outStr) > 4, "output string <= 4 chars") assert.Equal(t, outStr[:4], fmt.Sprintf("%04x", len(str)+4), "hex prefix") assert.Equal(t, outStr[4:], str, "remainder of string") @@ -279,7 +279,7 @@ func gitPktLineStr(str string) (string, error) { if err := gitPktLine(&buf, str); err != nil { return "", err } - return string(buf.Bytes()), nil + return buf.String(), nil } // connMetadata mocks ssh.ConnMetadata for authentication. diff --git a/pkg/storage/object_test.go b/pkg/storage/object_test.go index 8fe4a19..1b1d1cb 100644 --- a/pkg/storage/object_test.go +++ b/pkg/storage/object_test.go @@ -15,7 +15,7 @@ const ( ) func TestObjectExistsSuccess(t *testing.T) { - objInfo := storagedriver.FileInfoInternal{storagedriver.FileInfoFields{Path: objPath, Size: 1234}} + objInfo := storagedriver.FileInfoInternal{FileInfoFields: storagedriver.FileInfoFields{Path: objPath, Size: 1234}} statter := &FakeObjectStatter{ Fn: func(context.Context, string) (storagedriver.FileInfo, error) { return objInfo, nil