zegl / kube-score

Kubernetes object analysis with recommendations for improved reliability and security. kube-score actively prevents downtime and bugs in your Kubernetes YAML and Charts. Static code analysis for Kubernetes.
https://kube-score.com
MIT License
2.72k stars 174 forks source link

Simplified boolean checks and case-insensitive string comparison. #424

Closed atombrella closed 2 years ago

atombrella commented 2 years ago

I experimented a bit with various linters from https://golangci-lint.run/ and found a couple of fairly trivial things to fix/optimize.

strings.EqualFold is quite a bit faster compared than using toLower() https://hackernoon.com/optimizing-string-comparisons-in-go-7h1b3udm

I'm not sure how you feel about sorting go imports.

In score/score_test.go this bit is marked as dead code.

type unnamedReader struct {
    io.Reader
}

func (unnamedReader) Name() string {
    return ""
}

Thanks for a neat tool :tada:

atombrella commented 2 years ago

I had a look at https://goreportcard.com/report/github.com/zegl/kube-score and don't really understand why go vet doesn't find anything. There are several of this kind:

parser/parse.go:236:8: composites: `github.com/zegl/kube-score/parser/internal/pod.Pod` composite literal uses unkeyed fields (govet)
        p := internalpod.Pod{pod, fileLocation}
             ^
bors[bot] commented 2 years ago

Build succeeded: