Skip to content

Commit

Permalink
Merge PR cosmos#5159: Remove unused nolints from baseapp & format the…
Browse files Browse the repository at this point in the history
… rest of them

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

* Export queryRouter type

* Export router type
vovapi authored and jackzampolin committed Oct 14, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 2af4622 commit ce52f8f
Showing 6 changed files with 14 additions and 21 deletions.
4 changes: 2 additions & 2 deletions baseapp/abci.go
Original file line number Diff line number Diff line change
@@ -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()
}
2 changes: 1 addition & 1 deletion baseapp/baseapp.go
Original file line number Diff line number Diff line change
@@ -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")
}
2 changes: 0 additions & 2 deletions baseapp/helpers.go
Original file line number Diff line number Diff line change
@@ -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)
}
1 change: 0 additions & 1 deletion baseapp/options.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// nolint: golint
package baseapp

import (
14 changes: 6 additions & 8 deletions baseapp/queryrouter.go
Original file line number Diff line number Diff line change
@@ -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]
}
12 changes: 5 additions & 7 deletions baseapp/router.go
Original file line number Diff line number Diff line change
@@ -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]
}

0 comments on commit ce52f8f

Please sign in to comment.