fix lint failures with 1.31 (#5489)

This commit is contained in:
Marko
2020-10-22 13:36:08 +02:00
committed by Erik Grinaker
parent 51b8d3a153
commit 9379bc92fd
58 changed files with 98 additions and 144 deletions
+4 -3
View File
@@ -22,7 +22,7 @@ func ExampleHTTP_simple() {
rpcAddr := rpctest.GetConfig().RPC.ListenAddress
c, err := rpchttp.New(rpcAddr, "/websocket")
if err != nil {
log.Fatal(err)
log.Fatal(err) //nolint:gocritic
}
// Create a transaction
@@ -69,7 +69,6 @@ func ExampleHTTP_batching() {
// Start a tendermint node (and kvstore) in the background to test against
app := kvstore.NewApplication()
node := rpctest.StartTendermint(app, rpctest.SuppressStdout, rpctest.RecreateConfig)
defer rpctest.StopTendermint(node)
// Create our RPC client
rpcAddr := rpctest.GetConfig().RPC.ListenAddress
@@ -78,6 +77,8 @@ func ExampleHTTP_batching() {
log.Fatal(err)
}
defer rpctest.StopTendermint(node)
// Create our two transactions
k1 := []byte("firstName")
v1 := []byte("satoshi")
@@ -97,7 +98,7 @@ func ExampleHTTP_batching() {
// Broadcast the transaction and wait for it to commit (rather use
// c.BroadcastTxSync though in production).
if _, err := batch.BroadcastTxCommit(context.Background(), tx); err != nil {
log.Fatal(err)
log.Fatal(err) //nolint:gocritic
}
}
+1 -1
View File
@@ -82,7 +82,7 @@ func TestCustomHTTPClient(t *testing.T) {
func TestCorsEnabled(t *testing.T) {
origin := rpctest.GetConfig().RPC.CORSAllowedOrigins[0]
remote := strings.Replace(rpctest.GetConfig().RPC.ListenAddress, "tcp", "http", -1)
remote := strings.ReplaceAll(rpctest.GetConfig().RPC.ListenAddress, "tcp", "http")
req, err := http.NewRequest("GET", remote, nil)
require.Nil(t, err, "%+v", err)
+1 -1
View File
@@ -66,7 +66,7 @@ func (u parsedURL) GetHostWithPath() string {
// Get a trimmed address - useful for WS connections
func (u parsedURL) GetTrimmedHostWithPath() string {
// replace / with . for http requests (kvstore domain)
return strings.Replace(u.GetHostWithPath(), "/", ".", -1)
return strings.ReplaceAll(u.GetHostWithPath(), "/", ".")
}
// Get a trimmed address with protocol - useful as address in RPC connections
-2
View File
@@ -248,7 +248,6 @@ func (c *WSClient) CallWithArrayParams(ctx context.Context, method string, param
return c.Send(ctx, request)
}
///////////////////////////////////////////////////////////////////////////////
// Private methods
func (c *WSClient) nextRequestID() types.JSONRPCIntID {
@@ -521,7 +520,6 @@ func (c *WSClient) readRoutine() {
}
}
///////////////////////////////////////////////////////////////////////////////
// Predefined methods
// Subscribe to a query. Note the server must have a "subscribe" route
+1 -1
View File
@@ -404,5 +404,5 @@ func randBytes(t *testing.T) []byte {
buf := make([]byte, n)
_, err := crand.Read(buf)
require.Nil(t, err)
return bytes.Replace(buf, []byte("="), []byte{100}, -1)
return bytes.ReplaceAll(buf, []byte("="), []byte{100})
}
-2
View File
@@ -14,9 +14,7 @@ import (
types "github.com/tendermint/tendermint/rpc/jsonrpc/types"
)
///////////////////////////////////////////////////////////////////////////////
// HTTP + JSON handler
///////////////////////////////////////////////////////////////////////////////
// jsonrpc calls grab the given method's function info and runs reflect.Call
func makeJSONRPCHandler(funcMap map[string]*RPCFunc, logger log.Logger) http.HandlerFunc {
-2
View File
@@ -13,9 +13,7 @@ import (
types "github.com/tendermint/tendermint/rpc/jsonrpc/types"
)
///////////////////////////////////////////////////////////////////////////////
// HTTP + URI handler
///////////////////////////////////////////////////////////////////////////////
var reInt = regexp.MustCompile(`^-?[0-9]+$`)
-2
View File
@@ -23,9 +23,7 @@ func RegisterRPCFuncs(mux *http.ServeMux, funcMap map[string]*RPCFunc, logger lo
mux.HandleFunc("/", handleInvalidJSONRPCPaths(makeJSONRPCHandler(funcMap, logger)))
}
///////////////////////////////////////////////////////////////////////////////
// Function introspection
///////////////////////////////////////////////////////////////////////////////
// RPCFunc contains the introspected type information for a function
type RPCFunc struct {
-4
View File
@@ -17,9 +17,7 @@ import (
types "github.com/tendermint/tendermint/rpc/jsonrpc/types"
)
///////////////////////////////////////////////////////////////////////////////
// WebSocket handler
///////////////////////////////////////////////////////////////////////////////
const (
defaultWSWriteChanCapacity = 100
@@ -100,9 +98,7 @@ func (wm *WebsocketManager) WebsocketHandler(w http.ResponseWriter, r *http.Requ
}
}
///////////////////////////////////////////////////////////////////////////////
// WebSocket connection
///////////////////////////////////////////////////////////////////////////////
// A single websocket connection contains listener id, underlying ws
// connection, and the event switch for subscribing to events.
+1 -1
View File
@@ -72,7 +72,7 @@ func makePathname() string {
}
// fmt.Println(p)
sep := string(filepath.Separator)
return strings.Replace(p, sep, "_", -1)
return strings.ReplaceAll(p, sep, "_")
}
func randPort() int {