gometalinter -> golangci-lint migration (#3933)
{,scripts/}Makefile:
- Remove gometalinter, install golangci-lint.
- Remove distinction between tools and devtools.
Just tools is enough.
- test_lint -> lint
Migrating away from underscore separated names.
- Remove unnecessary targets.
- Drop tendermint/lint. Incompatbile with golangci-lint
and no longer necessary anyway.
- Fix misleading message in go-mod-cache.
- New ci-target to avoid download tools twice.
- Run tests with -mod=readonly.
Port tools/gometalinter.json to .golangci.yml
Update CircleCI config accordingly.
Closes: #3896
This commit is contained in:
+7
-10
@@ -115,20 +115,19 @@ func BlockRequestHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
|
||||
vars := mux.Vars(r)
|
||||
height, err := strconv.ParseInt(vars["height"], 10, 64)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
w.Write([]byte("ERROR: Couldn't parse block height. Assumed format is '/block/{height}'."))
|
||||
rest.WriteErrorResponse(w, http.StatusBadRequest,
|
||||
"ERROR: Couldn't parse block height. Assumed format is '/block/{height}'.")
|
||||
return
|
||||
}
|
||||
chainHeight, err := GetChainHeight(cliCtx)
|
||||
if height > chainHeight {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
w.Write([]byte("ERROR: Requested block height is bigger then the chain length."))
|
||||
rest.WriteErrorResponse(w, http.StatusNotFound,
|
||||
"ERROR: Requested block height is bigger then the chain length.")
|
||||
return
|
||||
}
|
||||
output, err := getBlock(cliCtx, &height)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
w.Write([]byte(err.Error()))
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
rest.PostProcessResponse(w, cdc, output, cliCtx.Indent)
|
||||
@@ -140,14 +139,12 @@ func LatestBlockRequestHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
height, err := GetChainHeight(cliCtx)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
w.Write([]byte(err.Error()))
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
output, err := getBlock(cliCtx, &height)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
w.Write([]byte(err.Error()))
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
rest.PostProcessResponse(w, cdc, output, cliCtx.Indent)
|
||||
|
||||
+7
-2
@@ -2,6 +2,7 @@ package rpc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
@@ -26,7 +27,9 @@ func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router) {
|
||||
// cli version REST handler endpoint
|
||||
func CLIVersionRequestHandler(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.Write([]byte(fmt.Sprintf("{\"version\": \"%s\"}", version.Version)))
|
||||
if _, err := w.Write([]byte(fmt.Sprintf("{\"version\": \"%s\"}", version.Version))); err != nil {
|
||||
log.Printf("could not write response: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// connected node version REST handler endpoint
|
||||
@@ -39,6 +42,8 @@ func NodeVersionRequestHandler(cliCtx context.CLIContext) http.HandlerFunc {
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.Write(version)
|
||||
if _, err := w.Write(version); err != nil {
|
||||
log.Printf("could not write response: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package rpc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -71,8 +72,7 @@ func NodeInfoRequestHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
status, err := getNodeStatus(cliCtx)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
w.Write([]byte(err.Error()))
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
@@ -86,18 +86,18 @@ func NodeSyncingRequestHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
status, err := getNodeStatus(cliCtx)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
w.Write([]byte(err.Error()))
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
syncing := status.SyncInfo.CatchingUp
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
w.Write([]byte(err.Error()))
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
w.Write([]byte(strconv.FormatBool(syncing)))
|
||||
if _, err := w.Write([]byte(strconv.FormatBool(syncing))); err != nil {
|
||||
log.Printf("could not write response: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,22 +160,19 @@ func ValidatorSetRequestHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
|
||||
|
||||
height, err := strconv.ParseInt(vars["height"], 10, 64)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
w.Write([]byte("ERROR: Couldn't parse block height. Assumed format is '/validatorsets/{height}'."))
|
||||
rest.WriteErrorResponse(w, http.StatusBadRequest, "ERROR: Couldn't parse block height. Assumed format is '/validatorsets/{height}'.")
|
||||
return
|
||||
}
|
||||
|
||||
chainHeight, err := GetChainHeight(cliCtx)
|
||||
if height > chainHeight {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
w.Write([]byte("ERROR: Requested block height is bigger then the chain length."))
|
||||
rest.WriteErrorResponse(w, http.StatusNotFound, "ERROR: Requested block height is bigger then the chain length.")
|
||||
return
|
||||
}
|
||||
|
||||
output, err := getValidators(cliCtx, &height)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
w.Write([]byte(err.Error()))
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
rest.PostProcessResponse(w, cdc, output, cliCtx.Indent)
|
||||
@@ -187,15 +184,13 @@ func LatestValidatorSetRequestHandlerFn(cliCtx context.CLIContext) http.HandlerF
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
height, err := GetChainHeight(cliCtx)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
w.Write([]byte(err.Error()))
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
output, err := getValidators(cliCtx, &height)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
w.Write([]byte(err.Error()))
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
rest.PostProcessResponse(w, cdc, output, cliCtx.Indent)
|
||||
|
||||
Reference in New Issue
Block a user