mirror of
https://github.com/aquasecurity/kube-bench.git
synced 2024-11-22 08:08:07 +00:00
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>
This commit is contained in:
parent
772839fc92
commit
33f6773a43
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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) == ""
|
||||
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user