Merge PR #5159: Remove unused nolints from baseapp & format the rest of them

* baseapp: Remove unused nolints & format the rest of them

* Export queryRouter type

* Export router type
This commit is contained in:
Vladimir Evgrafov 2019-10-15 01:05:10 +03:00 committed by Jack Zampolin
parent 2af4622bb6
commit ce52f8ff73
6 changed files with 14 additions and 21 deletions

View File

@ -391,8 +391,8 @@ func handleQueryCustom(app *BaseApp, path []string, req abci.RequestQuery) (res
// path[0] should be "custom" because "/custom" prefix is required for keeper
// queries.
//
// The queryRouter routes using path[1]. For example, in the path
// "custom/gov/proposal", queryRouter routes using "gov".
// The QueryRouter routes using path[1]. For example, in the path
// "custom/gov/proposal", QueryRouter routes using "gov".
if len(path) < 2 || path[1] == "" {
return sdk.ErrUnknownRequest("No route for custom query specified").QueryResult()
}

View File

@ -358,7 +358,7 @@ func (app *BaseApp) setInterBlockCache(cache sdk.MultiStorePersistentCache) {
// Router returns the router of the BaseApp.
func (app *BaseApp) Router() sdk.Router {
if app.sealed {
// We cannot return a router when the app is sealed because we can't have
// We cannot return a Router when the app is sealed because we can't have
// any routes modified which would cause unexpected routing behavior.
panic("Router() on sealed BaseApp")
}

View File

@ -10,12 +10,10 @@ import (
var isAlphaNumeric = regexp.MustCompile(`^[a-zA-Z0-9]+$`).MatchString
// Mostly for testing
func (app *BaseApp) Check(tx sdk.Tx) (result sdk.Result) {
return app.runTx(runTxModeCheck, nil, tx)
}
// full tx execution
func (app *BaseApp) Simulate(txBytes []byte, tx sdk.Tx) (result sdk.Result) {
return app.runTx(runTxModeSimulate, txBytes, tx)
}

View File

@ -1,4 +1,3 @@
// nolint: golint
package baseapp
import (

View File

@ -6,24 +6,22 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
)
type queryRouter struct {
type QueryRouter struct {
routes map[string]sdk.Querier
}
var _ sdk.QueryRouter = NewQueryRouter()
// NewQueryRouter returns a reference to a new queryRouter.
//
// TODO: Either make the function private or make return type (queryRouter) public.
func NewQueryRouter() *queryRouter { // nolint: golint
return &queryRouter{
// NewQueryRouter returns a reference to a new QueryRouter.
func NewQueryRouter() *QueryRouter {
return &QueryRouter{
routes: map[string]sdk.Querier{},
}
}
// AddRoute adds a query path to the router with a given Querier. It will panic
// if a duplicate route is given. The route must be alphanumeric.
func (qrt *queryRouter) AddRoute(path string, q sdk.Querier) sdk.QueryRouter {
func (qrt *QueryRouter) AddRoute(path string, q sdk.Querier) sdk.QueryRouter {
if !isAlphaNumeric(path) {
panic("route expressions can only contain alphanumeric characters")
}
@ -36,6 +34,6 @@ func (qrt *queryRouter) AddRoute(path string, q sdk.Querier) sdk.QueryRouter {
}
// Route returns the Querier for a given query route path.
func (qrt *queryRouter) Route(path string) sdk.Querier {
func (qrt *QueryRouter) Route(path string) sdk.Querier {
return qrt.routes[path]
}

View File

@ -6,24 +6,22 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
)
type router struct {
type Router struct {
routes map[string]sdk.Handler
}
var _ sdk.Router = NewRouter()
// NewRouter returns a reference to a new router.
//
// TODO: Either make the function private or make return type (router) public.
func NewRouter() *router { // nolint: golint
return &router{
func NewRouter() *Router {
return &Router{
routes: make(map[string]sdk.Handler),
}
}
// AddRoute adds a route path to the router with a given handler. The route must
// be alphanumeric.
func (rtr *router) AddRoute(path string, h sdk.Handler) sdk.Router {
func (rtr *Router) AddRoute(path string, h sdk.Handler) sdk.Router {
if !isAlphaNumeric(path) {
panic("route expressions can only contain alphanumeric characters")
}
@ -38,6 +36,6 @@ func (rtr *router) AddRoute(path string, h sdk.Handler) sdk.Router {
// Route returns a handler for a given route path.
//
// TODO: Handle expressive matches.
func (rtr *router) Route(path string) sdk.Handler {
func (rtr *Router) Route(path string) sdk.Handler {
return rtr.routes[path]
}