From 60ac9cda9525121c0bd85ef1363e805b8c9bda02 Mon Sep 17 00:00:00 2001 From: Jack Wilsdon Date: Tue, 11 Feb 2020 22:55:56 +0000 Subject: [PATCH] Upgrade golangci-lint and enable new rules --- .golangci.yml | 8 ++++++++ .travis.yml | 2 +- handler.go | 5 +++++ handler_test.go | 1 + 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.golangci.yml b/.golangci.yml index 8a45d0c..49eea99 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -2,14 +2,19 @@ linters: enable: - deadcode - depguard + - dogsled - dupl - errcheck + - gochecknoinits + - gocognit - goconst - gocritic - gocyclo + - godox - gofmt - goimports - golint + - goprintffuncname - gosec - gosimple - govet @@ -20,6 +25,7 @@ linters: - misspell - nakedret - prealloc + - rowserrcheck - scopelint - staticcheck - structcheck @@ -29,3 +35,5 @@ linters: - unparam - unused - varcheck + - whitespace + - wsl diff --git a/.travis.yml b/.travis.yml index 1e735d8..a7f8f7b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ go: env: - GO111MODULE=on before_install: - - curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $GOPATH/bin v1.18.0 + - curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $GOPATH/bin v1.23.6 script: - golangci-lint run - go test ./... diff --git a/handler.go b/handler.go index 6b6fe8c..b1b4ca9 100644 --- a/handler.go +++ b/handler.go @@ -64,6 +64,7 @@ func Handler(res http.ResponseWriter, req *http.Request) { if req.Method != http.MethodGet { res.Header().Set("Allow", http.MethodGet) res.WriteHeader(http.StatusMethodNotAllowed) + return } @@ -73,6 +74,7 @@ func Handler(res http.ResponseWriter, req *http.Request) { if writer == nil { res.WriteHeader(http.StatusNotFound) fmt.Fprintf(res, "error: unsupported file format") + return } @@ -84,6 +86,7 @@ func Handler(res http.ResponseWriter, req *http.Request) { if err != nil { res.WriteHeader(http.StatusBadRequest) fmt.Fprintf(res, "error: invalid size") + return } @@ -107,6 +110,7 @@ func Handler(res http.ResponseWriter, req *http.Request) { if err == ErrInvalidSize { res.WriteHeader(http.StatusBadRequest) fmt.Fprintf(res, "error: %s", err) + return } @@ -114,6 +118,7 @@ func Handler(res http.ResponseWriter, req *http.Request) { if err != nil { res.WriteHeader(http.StatusInternalServerError) fmt.Fprintf(res, "error: %s", err) + return } diff --git a/handler_test.go b/handler_test.go index bc62312..5f3dc22 100644 --- a/handler_test.go +++ b/handler_test.go @@ -24,6 +24,7 @@ func isPrintable(s string) bool { return false } } + return true }