Merge pull request #36 from cmertz/remove-gosimple-warnings

remove gosimple offences
This commit is contained in:
Yann Hamon 2021-02-27 15:05:02 +01:00 committed by GitHub
commit 171d894752
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 7 additions and 7 deletions

View file

@ -29,7 +29,7 @@ func processResults(cancel context.CancelFunc, o output.Output, validationResult
fmt.Fprint(os.Stderr, "failed writing log\n")
}
}
if success == false && exitOnError {
if !success && exitOnError {
cancel() // early exit - signal to stop searching for resources
break
}

View file

@ -31,7 +31,7 @@ func (c *inMemory) Get(resourceKind, resourceAPIVersion, k8sVersion string) (int
defer c.RUnlock()
schema, ok := c.schemas[k]
if ok == false {
if !ok {
return nil, fmt.Errorf("schema not found in in-memory cache")
}

View file

@ -93,7 +93,7 @@ func TestDownloadSchema(t *testing.T) {
t.Errorf("during test '%s': expected error, got:\n%s\n%s\n", testCase.name, testCase.expectErr, err)
}
if bytes.Compare(res, testCase.expect) != 0 {
if !bytes.Equal(res, testCase.expect) {
t.Errorf("during test '%s': expected %s, got %s", testCase.name, testCase.expect, res)
}
}

View file

@ -92,7 +92,7 @@ func findResourcesInReader(p string, f io.Reader, resources chan<- Resource, err
scanner.Buffer(buf, len(buf))
scanner.Split(SplitYAMLDocument)
nRes := 0
for res := scanner.Scan(); res != false; res = scanner.Scan() {
for scanner.Scan() {
if len(scanner.Text()) > 0 {
resources <- Resource{Path: p, Bytes: []byte(scanner.Text())}
nRes++

View file

@ -54,7 +54,7 @@ func FromStream(ctx context.Context, path string, r io.Reader) (<-chan Resource,
scanner.Split(SplitYAMLDocument)
SCAN:
for res := scanner.Scan(); res != false; res = scanner.Scan() {
for scanner.Scan() {
select {
case <-ctx.Done():
break SCAN

View file

@ -151,7 +151,7 @@ kind: Deployment
t.Errorf("test %d - expected %d resources, got %d", testi, len(testCase.Want.Resources), len(res))
}
for i, v := range res {
if bytes.Compare(v.Bytes, testCase.Want.Resources[i].Bytes) != 0 {
if !bytes.Equal(v.Bytes, testCase.Want.Resources[i].Bytes) {
t.Errorf("test %d - for resource %d, got '%s', expected '%s'", testi, i, string(res[i].Bytes), string(testCase.Want.Resources[i].Bytes))
}
}

View file

@ -55,7 +55,7 @@ type Opts struct {
func New(schemaLocations []string, opts Opts) (Validator, error) {
// Default to our kubernetes-json-schema fork
// raw.githubusercontent.com is frontend by Fastly and very fast
if schemaLocations == nil || len(schemaLocations) == 0 {
if len(schemaLocations) == 0 {
schemaLocations = []string{"https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/{{ .NormalizedKubernetesVersion }}-standalone{{ .StrictSuffix }}/{{ .ResourceKind }}{{ .KindSuffix }}.json"}
}