Skip to content

Commit

Permalink
Add EarlyReturn linter (ava-labs#2232)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenButtolph authored Nov 14, 2022
1 parent c4c5444 commit dcbc064
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ linters-settings:
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#bool-literal-in-expr
- name: bool-literal-in-expr
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#early-return
- name: early-return
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#struct-tag
- name: struct-tag
disabled: false
Expand Down
7 changes: 4 additions & 3 deletions api/server/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,13 @@ func (r *router) forceAddRouter(base, endpoint string, handler http.Handler) err

endpoints[endpoint] = handler
r.routes[base] = endpoints

// Name routes based on their URL for easy retrieval in the future
if route := r.router.Handle(url, handler); route != nil {
route.Name(url)
} else {
route := r.router.Handle(url, handler)
if route == nil {
return fmt.Errorf("failed to create new route for %s", url)
}
route.Name(url)

var err error
if aliases, exists := r.aliases[base]; exists {
Expand Down
6 changes: 3 additions & 3 deletions snow/networking/router/chain_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,13 +433,13 @@ func (cr *ChainRouter) Unbenched(chainID ids.ID, nodeID ids.NodeID) {

benchedChains := cr.benched[nodeID]
benchedChains.Remove(chainID)
if benchedChains.Len() == 0 {
delete(cr.benched, nodeID)
} else {
if benchedChains.Len() != 0 {
cr.benched[nodeID] = benchedChains
return // This node is still benched
}

delete(cr.benched, nodeID)

peer, found := cr.peers[nodeID]
if !found {
return
Expand Down

0 comments on commit dcbc064

Please sign in to comment.