all: fix lint issues

staticcheck updated, and it requires inline fixes as well as dropping
support for 1.9 and 1.10.
This commit is contained in:
Kevin Burke
2019-06-29 20:57:51 -07:00
parent f648cfb84b
commit 2e50c44127
3 changed files with 12 additions and 10 deletions

View File

@@ -3,9 +3,8 @@ go_import_path: github.com/kevinburke/ssh_config
language: go
go:
- 1.9.x
- 1.10.x
- 1.11.x
- 1.12.x
- master
before_script:

View File

@@ -1,15 +1,13 @@
BUMP_VERSION := $(GOPATH)/bin/bump_version
MEGACHECK := $(GOPATH)/bin/megacheck
STATICCHECK := $(GOPATH)/bin/staticcheck
WRITE_MAILMAP := $(GOPATH)/bin/write_mailmap
IGNORES := 'github.com/kevinburke/ssh_config/config.go:U1000 github.com/kevinburke/ssh_config/config.go:S1002 github.com/kevinburke/ssh_config/token.go:U1000'
$(STATICCHECK):
go get honnef.co/go/tools/cmd/staticcheck
$(MEGACHECK):
go get honnef.co/go/tools/cmd/megacheck
lint: $(MEGACHECK)
lint: $(STATICCHECK)
go vet ./...
$(MEGACHECK) --ignore=$(IGNORES) ./...
$(STATICCHECK)
test: lint
@# the timeout helps guard against infinite recursion

View File

@@ -158,6 +158,7 @@ func (u *UserSettings) GetStrict(alias, key string) (string, error) {
}
var err error
u.userConfig, err = parseFile(filename)
//lint:ignore S1002 I prefer it this way
if err != nil && os.IsNotExist(err) == false {
u.onceErr = err
return
@@ -168,11 +169,13 @@ func (u *UserSettings) GetStrict(alias, key string) (string, error) {
filename = u.systemConfigFinder()
}
u.systemConfig, err = parseFile(filename)
//lint:ignore S1002 I prefer it this way
if err != nil && os.IsNotExist(err) == false {
u.onceErr = err
return
}
})
//lint:ignore S1002 I prefer it this way
if u.onceErr != nil && u.IgnoreErrors == false {
return "", u.onceErr
}
@@ -381,7 +384,7 @@ func (h *Host) Matches(alias string) bool {
found := false
for i := range h.Patterns {
if h.Patterns[i].regex.MatchString(alias) {
if h.Patterns[i].not == true {
if h.Patterns[i].not {
// Negated match. "A pattern entry may be negated by prefixing
// it with an exclamation mark (`!'). If a negated entry is
// matched, then the Host entry is ignored, regardless of
@@ -400,6 +403,7 @@ func (h *Host) Matches(alias string) bool {
// present in the whitespace in the printed file.
func (h *Host) String() string {
var buf bytes.Buffer
//lint:ignore S1002 I prefer to write it this way
if h.implicit == false {
buf.WriteString(strings.Repeat(" ", int(h.leadingSpace)))
buf.WriteString("Host")
@@ -524,6 +528,7 @@ func removeDups(arr []string) []string {
result := make([]string, 0)
for v := range arr {
//lint:ignore S1002 I prefer it this way
if encountered[arr[v]] == false {
encountered[arr[v]] = true
result = append(result, arr[v])