Skip to content

Commit

Permalink
Add nilerr linter
Browse files Browse the repository at this point in the history
  • Loading branch information
qdm12 committed Nov 26, 2021
1 parent 0b9d62b commit 068e73a
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 8 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ linters:
- megacheck
- megacheck
- misspell
- nilerr
- nilnil
- nolintlint
- revive
Expand Down
2 changes: 1 addition & 1 deletion dot/peerset/peerset.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ func (ps *PeerSet) allocSlots(setIdx int) error {

logger.Debugf("Sent connect message to peer %s", peerID)
}
return nil
return nil //nolint:nilerr
}

func (ps *PeerSet) addReservedPeers(setID int, peers ...peer.ID) error {
Expand Down
5 changes: 4 additions & 1 deletion lib/common/types/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package types

import (
"errors"
"io"

"github.com/ChainSafe/gossamer/lib/common"
Expand Down Expand Up @@ -53,8 +54,10 @@ func (r *Result) Decode(reader io.Reader) (*Result, error) {

for {
b, err := common.ReadByte(reader)
if err != nil {
if errors.Is(err, io.EOF) {
break
} else if err != nil {
return nil, err
}

r.data = append(r.data, b)
Expand Down
5 changes: 3 additions & 2 deletions lib/genesis/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package genesis

import (
"encoding/json"
"fmt"
"math/big"
"os"
"testing"
Expand Down Expand Up @@ -97,12 +98,12 @@ func CreateTestGenesisJSONFile(asRaw bool) (string, error) {

bz, err := json.Marshal(tGen)
if err != nil {
return "", nil
return "", fmt.Errorf("cannot marshal test genesis: %w", err)
}
// Write to temp file
_, err = file.Write(bz)
if err != nil {
return "", nil
return "", fmt.Errorf("cannot write JSON test genesis: %w", err)
}

return file.Name(), nil
Expand Down
2 changes: 1 addition & 1 deletion lib/runtime/life/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ func storageAppend(storage runtime.Storage, key, valueToAppend []byte) error {
if err != nil {
logger.Tracef("[ext_storage_append_version_1] item in storage is not SCALE encoded, overwriting at key 0x%x", key)
storage.Set(key, append([]byte{4}, valueToAppend...))
return nil
return nil //nolint:nilerr
}

lengthBytes, err := scale.Marshal(currLength)
Expand Down
2 changes: 1 addition & 1 deletion lib/runtime/wasmer/imports.go
Original file line number Diff line number Diff line change
Expand Up @@ -1790,7 +1790,7 @@ func storageAppend(storage runtime.Storage, key, valueToAppend []byte) error {
logger.Tracef(
"[ext_storage_append_version_1] item in storage is not SCALE encoded, overwriting at key 0x%x", key)
storage.Set(key, append([]byte{4}, valueToAppend...))
return nil
return nil //nolint:nilerr
}

lengthBytes, err := scale.Marshal(currLength)
Expand Down
5 changes: 3 additions & 2 deletions tests/utils/gossamer_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,11 @@ func InitNodes(num int, config string) ([]*Node, error) {

// StartNodes starts given array of nodes
func StartNodes(t *testing.T, nodes []*Node) error {
for _, n := range nodes {
for i, n := range nodes {
err := StartGossamer(t, n, false)
if err != nil {
return nil
return fmt.Errorf("node %d of %d: %w",
i+1, len(nodes), err)
}
}
return nil
Expand Down

0 comments on commit 068e73a

Please sign in to comment.