diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml index b9c94410..02624bd8 100644 --- a/.github/workflows/linters.yml +++ b/.github/workflows/linters.yml @@ -27,6 +27,11 @@ jobs: - uses: actions/setup-go@v5 with: go-version: "1.22" + - run: "go vet ./..." - uses: golangci/golangci-lint-action@v4 with: args: --timeout 10m --skip-dirs tests --disable errcheck --enable sqlclosecheck --enable misspell --enable gofmt --enable goimports --enable whitespace + - uses: dominikh/staticcheck-action@v1.3.0 + with: + version: "2023.1.7" + install-go: false diff --git a/Makefile b/Makefile index 6a611c28..2a0d20f8 100644 --- a/Makefile +++ b/Makefile @@ -110,7 +110,9 @@ test: go test -cover -race -count=1 ./... lint: - golint -set_exit_status ${PKG_LIST} + go vet ./... + staticcheck ./... + golangci-lint run --disable errcheck --enable sqlclosecheck --enable misspell --enable gofmt --enable goimports --enable whitespace integration-test: psql -U postgres -c 'drop database if exists miniflux_test;' diff --git a/internal/api/user.go b/internal/api/user.go index 36d4b8e0..8c660a57 100644 --- a/internal/api/user.go +++ b/internal/api/user.go @@ -77,7 +77,7 @@ func (h *handler) updateUser(w http.ResponseWriter, r *http.Request) { } if userModificationRequest.IsAdmin != nil && *userModificationRequest.IsAdmin { - json.BadRequest(w, r, errors.New("Only administrators can change permissions of standard users")) + json.BadRequest(w, r, errors.New("only administrators can change permissions of standard users")) return } } @@ -141,7 +141,7 @@ func (h *handler) userByID(w http.ResponseWriter, r *http.Request) { userID := request.RouteInt64Param(r, "userID") user, err := h.store.UserByID(userID) if err != nil { - json.BadRequest(w, r, errors.New("Unable to fetch this user from the database")) + json.BadRequest(w, r, errors.New("unable to fetch this user from the database")) return } @@ -163,7 +163,7 @@ func (h *handler) userByUsername(w http.ResponseWriter, r *http.Request) { username := request.RouteStringParam(r, "username") user, err := h.store.UserByUsername(username) if err != nil { - json.BadRequest(w, r, errors.New("Unable to fetch this user from the database")) + json.BadRequest(w, r, errors.New("unable to fetch this user from the database")) return } @@ -194,7 +194,7 @@ func (h *handler) removeUser(w http.ResponseWriter, r *http.Request) { } if user.ID == request.UserID(r) { - json.BadRequest(w, r, errors.New("You cannot remove yourself")) + json.BadRequest(w, r, errors.New("you cannot remove yourself")) return } diff --git a/internal/validator/validator.go b/internal/validator/validator.go index 9cedc5cd..63fe75f0 100644 --- a/internal/validator/validator.go +++ b/internal/validator/validator.go @@ -12,11 +12,11 @@ import ( // ValidateRange makes sure the offset/limit values are valid. func ValidateRange(offset, limit int) error { if offset < 0 { - return fmt.Errorf(`Offset value should be >= 0`) + return fmt.Errorf(`offset value should be >= 0`) } if limit < 0 { - return fmt.Errorf(`Limit value should be >= 0`) + return fmt.Errorf(`limit value should be >= 0`) } return nil @@ -29,7 +29,7 @@ func ValidateDirection(direction string) error { return nil } - return fmt.Errorf(`Invalid direction, valid direction values are: "asc" or "desc"`) + return fmt.Errorf(`invalid direction, valid direction values are: "asc" or "desc"`) } // IsValidRegex verifies if the regex can be compiled.