Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions app/client/keybase/keystore.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ func (keybase *badgerKeybase) GetAll() (addresses []string, keyPairs []crypto.Ke
defer it.Close()
for it.Rewind(); it.Valid(); it.Next() {
item := it.Item()
err := item.Value(func(val []byte) error {
if err := item.Value(func(val []byte) error {
b := make([]byte, len(val))
copy(b, val)

Expand All @@ -235,8 +235,7 @@ func (keybase *badgerKeybase) GetAll() (addresses []string, keyPairs []crypto.Ke
addresses = append(addresses, kp.GetAddressString())
keyPairs = append(keyPairs, kp)
return nil
})
if err != nil {
}); err != nil {
return err
}
}
Expand Down
20 changes: 20 additions & 0 deletions build/linters/errs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//nolint // it's not a Go code file
//go:build !codeanalysis
// +build !codeanalysis

// This file includes our custom linters.
// If you want to add/modify an existing linter, please check out ruleguard's documentation: https://github.com/quasilyte/go-ruleguard#documentation

package gorules

import (
"github.com/quasilyte/go-ruleguard/dsl"
)

// This is a custom linter that checks ensures a use of inline error checks
func InlineErrCheck(m dsl.Matcher) {
m.Match(`$err := $x; if $err != nil { $*_ }`).
Where(m["err"].Type.Is(`error`)).
Report(`consider using inline error check: if err := $x; err != nil { $*_ }`).
Suggest(`if err := $x; err != nil { $*_ }`)
}
3 changes: 1 addition & 2 deletions consensus/hotstuff_replica.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,7 @@ func (m *consensusModule) applyBlock(block *coreTypes.Block) error {
}

// Apply all the transactions in the block
err := utilityUnitOfWork.ApplyBlock()
if err != nil {
if err := utilityUnitOfWork.ApplyBlock(); err != nil {
return err
}

Expand Down
6 changes: 2 additions & 4 deletions persistence/gov.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@ func (p *PostgresContext) getParamsUpdated(height int64) ([]*coreTypes.Param, er
// Loop over all rows returned and load them into the ParamOrFlag struct array
for rows.Next() {
param := new(coreTypes.Param)
err := rows.Scan(&param.Name, &param.Value)
if err != nil {
if err := rows.Scan(&param.Name, &param.Value); err != nil {
return nil, err
}
param.Height = height
Expand All @@ -190,8 +189,7 @@ func (p *PostgresContext) getFlagsUpdated(height int64) ([]*coreTypes.Flag, erro
// Loop over all rows returned and load them into the ParamOrFlag struct array
for rows.Next() {
flag := new(coreTypes.Flag)
err := rows.Scan(&flag.Name, &flag.Value, &flag.Enabled)
if err != nil {
if err := rows.Scan(&flag.Name, &flag.Value, &flag.Enabled); err != nil {
return nil, err
}
flag.Height = height
Expand Down
3 changes: 1 addition & 2 deletions persistence/kvstore/kvstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ func (store *badgerKVStore) Set(key, value []byte) error {
tx := store.db.NewTransaction(true)
defer tx.Discard()

err := tx.Set(key, value)
if err != nil {
if err := tx.Set(key, value); err != nil {
return err
}

Expand Down
6 changes: 2 additions & 4 deletions shared/crypto/ed25519.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ func (priv Ed25519PrivateKey) Seed() []byte {

func (priv *Ed25519PrivateKey) UnmarshalJSON(data []byte) error {
var privateKey string
err := json.Unmarshal(data, &privateKey)
if err != nil {
if err := json.Unmarshal(data, &privateKey); err != nil {
return err
}
return priv.UnmarshalText([]byte(privateKey))
Expand Down Expand Up @@ -201,8 +200,7 @@ func (pub Ed25519PublicKey) MarshalJSON() ([]byte, error) {

func (pub *Ed25519PublicKey) UnmarshalJSON(data []byte) error {
var publicKey string
err := json.Unmarshal(data, &publicKey)
if err != nil {
if err := json.Unmarshal(data, &publicKey); err != nil {
return err
}
keyBytes, err := hex.DecodeString(publicKey)
Expand Down
3 changes: 1 addition & 2 deletions shared/crypto/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ type PrivateKey interface {

func (a *Address) UnmarshalJSON(data []byte) error {
var address string
err := json.Unmarshal(data, &address)
if err != nil {
if err := json.Unmarshal(data, &address); err != nil {
return err
}
bz, err := hex.DecodeString(address)
Expand Down