gocritic (1/2) (#3836)

Add gocritic as a linter

    The linting is not complete, but should i complete in this PR or in a following.

    23 files have been touched so it may be better to do in a following PR


Commits:

* Add gocritic to linting

- Added gocritic to linting

Signed-off-by: Marko Baricevic <marbar3778@yahoo.com>

* gocritic

* pr comments

* remove switch in cmdBatch
This commit is contained in:
Marko
2019-07-30 18:13:35 +04:00
committed by Anton Kaliaev
parent 88e0973f7d
commit 41bf54a906
23 changed files with 89 additions and 123 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ import (
func WriteConfigVals(dir string, vals map[string]string) error {
data := ""
for k, v := range vals {
data = data + fmt.Sprintf("%s = \"%s\"\n", k, v)
data += fmt.Sprintf("%s = \"%s\"\n", k, v)
}
cfile := filepath.Join(dir, "config.toml")
return ioutil.WriteFile(cfile, []byte(data), 0666)
+3 -5
View File
@@ -45,11 +45,9 @@ func TestDeterminism(t *testing.T) {
output := testThemAll()
if i == 0 {
firstOutput = output
} else {
if firstOutput != output {
t.Errorf("Run #%d's output was different from first run.\nfirst: %v\nlast: %v",
i, firstOutput, output)
}
} else if firstOutput != output {
t.Errorf("Run #%d's output was different from first run.\nfirst: %v\nlast: %v",
i, firstOutput, output)
}
}
}
+4 -3
View File
@@ -51,11 +51,12 @@ func IsASCIIText(s string) bool {
func ASCIITrim(s string) string {
r := make([]byte, 0, len(s))
for _, b := range []byte(s) {
if b == 32 {
switch {
case b == 32:
continue // skip space
} else if 32 < b && b <= 126 {
case 32 < b && b <= 126:
r = append(r, b)
} else {
default:
panic(fmt.Sprintf("non-ASCII (non-tab) char 0x%X", b))
}
}