Skip to content

Commit

Permalink
Upgrade golangci-lint and enable new rules
Browse files Browse the repository at this point in the history
  • Loading branch information
jackwilsdon committed Feb 11, 2020
1 parent 9408004 commit 60ac9cd
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@ linters:
enable:
- deadcode
- depguard
- dogsled
- dupl
- errcheck
- gochecknoinits
- gocognit
- goconst
- gocritic
- gocyclo
- godox
- gofmt
- goimports
- golint
- goprintffuncname
- gosec
- gosimple
- govet
Expand All @@ -20,6 +25,7 @@ linters:
- misspell
- nakedret
- prealloc
- rowserrcheck
- scopelint
- staticcheck
- structcheck
Expand All @@ -29,3 +35,5 @@ linters:
- unparam
- unused
- varcheck
- whitespace
- wsl
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ./...
5 changes: 5 additions & 0 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
}

Expand All @@ -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
}

Expand All @@ -107,13 +110,15 @@ func Handler(res http.ResponseWriter, req *http.Request) {
if err == ErrInvalidSize {
res.WriteHeader(http.StatusBadRequest)
fmt.Fprintf(res, "error: %s", err)

return
}

// Check if something else bad happened during generation.
if err != nil {
res.WriteHeader(http.StatusInternalServerError)
fmt.Fprintf(res, "error: %s", err)

return
}

Expand Down
1 change: 1 addition & 0 deletions handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func isPrintable(s string) bool {
return false
}
}

return true
}

Expand Down

0 comments on commit 60ac9cd

Please sign in to comment.