From 33f6773a43f6e7f29cbe61624e5b0448c53db8e8 Mon Sep 17 00:00:00 2001
From: Satya Pawan <66307160+chsatyap@users.noreply.github.com>
Date: Tue, 1 Sep 2020 19:20:04 +0530
Subject: [PATCH] Code quality improvements (#677)

* Code quality improvements such -

1. Improves empty string test (len vs str == "")
2. Converts fmt.Sprintf to string literal and Printf to Print where possible (as the dynamic args are missing!)

* Delete .deepsource.toml

Co-authored-by: DeepSource Bot <bot@deepsource.io>
Co-authored-by: Liz Rice <liz@lizrice.com>
---
 check/check.go             | 2 +-
 cmd/common.go              | 2 +-
 cmd/kubernetes_version.go  | 4 ++--
 cmd/util.go                | 2 +-
 integration/integration.go | 2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/check/check.go b/check/check.go
index a5f3793..f000be0 100644
--- a/check/check.go
+++ b/check/check.go
@@ -105,7 +105,7 @@ func (c *Check) run() State {
 	// Since this is an Scored check
 	// without tests return a 'WARN' to alert
 	// the user that this check needs attention
-	if c.Scored && len(strings.TrimSpace(c.Type)) == 0 && c.Tests == nil {
+	if c.Scored && strings.TrimSpace(c.Type) == "" && c.Tests == nil {
 		c.Reason = "There are no tests"
 		c.State = WARN
 		return c.State
diff --git a/cmd/common.go b/cmd/common.go
index b36205e..d9674fc 100644
--- a/cmd/common.go
+++ b/cmd/common.go
@@ -411,7 +411,7 @@ func writeOutputToFile(output string, outputFile string) error {
 }
 
 func printOutput(output string, outputFile string) {
-	if len(outputFile) == 0 {
+	if outputFile == "" {
 		fmt.Println(output)
 	} else {
 		err := writeOutputToFile(output, outputFile)
diff --git a/cmd/kubernetes_version.go b/cmd/kubernetes_version.go
index 2c55ed1..b72729e 100644
--- a/cmd/kubernetes_version.go
+++ b/cmd/kubernetes_version.go
@@ -136,7 +136,7 @@ func loadCertficate(certFile string) (*tls.Certificate, error) {
 		return nil, fmt.Errorf("unable to Decode certificate")
 	}
 
-	glog.V(2).Info(fmt.Sprintf("Loading CA certificate"))
+	glog.V(2).Info("Loading CA certificate")
 	tlsCert.Certificate = append(tlsCert.Certificate, block.Bytes)
 	return &tlsCert, nil
 }
@@ -154,7 +154,7 @@ func getKubernetesURL() string {
 			return fmt.Sprintf("https://%s:%s/version", k8sHost, k8sPort)
 		}
 
-		glog.V(2).Info(fmt.Sprintf("KUBE_BENCH_K8S_ENV is set, but environment variables KUBERNETES_SERVICE_HOST or KUBERNETES_SERVICE_PORT_HTTPS are not set"))
+		glog.V(2).Info("KUBE_BENCH_K8S_ENV is set, but environment variables KUBERNETES_SERVICE_HOST or KUBERNETES_SERVICE_PORT_HTTPS are not set")
 	}
 
 	return k8sVersionURL
diff --git a/cmd/util.go b/cmd/util.go
index 82b2928..62f7d81 100644
--- a/cmd/util.go
+++ b/cmd/util.go
@@ -368,7 +368,7 @@ func makeSubstitutions(s string, ext string, m map[string]string) string {
 }
 
 func isEmpty(str string) bool {
-	return len(strings.TrimSpace(str)) == 0
+	return strings.TrimSpace(str) == ""
 
 }
 
diff --git a/integration/integration.go b/integration/integration.go
index abd310d..8dc306b 100644
--- a/integration/integration.go
+++ b/integration/integration.go
@@ -113,7 +113,7 @@ func findPodForJob(clientset *kubernetes.Clientset, jobName string, duration tim
 
 					if cp.Status.Phase == apiv1.PodFailed {
 						fmt.Printf("pod (%s) - %s - retrying...\n", cp.Name, cp.Status.Phase)
-						fmt.Printf(getPodLogs(clientset, &cp))
+						fmt.Print(getPodLogs(clientset, &cp))
 						failedPods[cp.Name] = struct{}{}
 						break podfailed
 					}
-- 
GitLab