Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update staticcheck version #5071

Merged
merged 1 commit into from
Dec 10, 2024
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
3 changes: 0 additions & 3 deletions cmd/configtxlator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,6 @@ func computeUpdt(original, updated, output *os.File, channelID string) error {

cu.ChannelId = channelID

if cu == nil {
return errors.New("error marshaling computed config update: proto: Marshal called with nil")
}
outBytes, err := proto.Marshal(cu)
if err != nil {
return errors.Wrapf(err, "error marshaling computed config update")
Expand Down
2 changes: 1 addition & 1 deletion core/chaincode/accesscontrol/access.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (ac *Authenticator) authenticate(msg *pb.ChaincodeMessage, stream grpc.Serv
if registeredName != ccName {
errMsg := fmt.Sprintf("Chaincode %s with given certificate hash %v belongs to a different chaincode", ccName, hash)
logger.Warning(errMsg)
return fmt.Errorf(errMsg)
return errors.New(errMsg)
}

logger.Debug("Chaincode", ccName, "'s authentication is authorized")
Expand Down
4 changes: 2 additions & 2 deletions core/common/validation/msgvalidation.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ func validateSignatureHeader(sHdr *common.SignatureHeader) error {
}

// ensure that there is a nonce
if sHdr.Nonce == nil || len(sHdr.Nonce) == 0 {
if len(sHdr.Nonce) == 0 {
return errors.New("invalid nonce specified in the header")
}

// ensure that there is a creator
if sHdr.Creator == nil || len(sHdr.Creator) == 0 {
if len(sHdr.Creator) == 0 {
return errors.New("invalid creator specified in the header")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/encoding/protowire"
"google.golang.org/protobuf/proto"
protoV2 "google.golang.org/protobuf/proto"
"google.golang.org/protobuf/protoadapt"
)

Expand Down Expand Up @@ -567,7 +566,7 @@ func TestSnapshotImportErrorPropagation(t *testing.T) {
srTmp := protoadapt.MessageV2Of(sr)
var buf []byte
buf = protowire.AppendVarint(buf, uint64(proto.Size(sr)))
nbuf, err := protoV2.MarshalOptions{
nbuf, err := proto.MarshalOptions{
Deterministic: false,
AllowPartial: true,
}.MarshalAppend(buf, srTmp)
Expand Down
18 changes: 9 additions & 9 deletions core/scc/qscc/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func TestQueryGetChainInfo(t *testing.T) {

mockStub, lq, _, cleanup, err := setupTestLedger(t, chainid, path)
if err != nil {
t.Fatalf(err.Error())
t.Fatal(err.Error())
}
defer cleanup()

Expand Down Expand Up @@ -128,7 +128,7 @@ func TestQueryGetTransactionByID(t *testing.T) {

mockStub, lq, _, cleanup, err := setupTestLedger(t, chainid, path)
if err != nil {
t.Fatalf(err.Error())
t.Fatal(err.Error())
}
defer cleanup()

Expand Down Expand Up @@ -164,7 +164,7 @@ func TestQueryGetBlockByNumber(t *testing.T) {

mockStub, lq, _, cleanup, err := setupTestLedger(t, chainid, path)
if err != nil {
t.Fatalf(err.Error())
t.Fatal(err.Error())
}
defer cleanup()

Expand Down Expand Up @@ -201,7 +201,7 @@ func TestQueryGetBlockByHash(t *testing.T) {

mockStub, lq, _, cleanup, err := setupTestLedger(t, chainid, path)
if err != nil {
t.Fatalf(err.Error())
t.Fatal(err.Error())
}
defer cleanup()

Expand All @@ -228,7 +228,7 @@ func TestQueryGetBlockByTxID(t *testing.T) {

mockStub, lq, _, cleanup, err := setupTestLedger(t, chainid, path)
if err != nil {
t.Fatalf(err.Error())
t.Fatal(err.Error())
}
defer cleanup()

Expand Down Expand Up @@ -290,7 +290,7 @@ func TestFailingAccessControl(t *testing.T) {

mockStub, lq, _, cleanup, err := setupTestLedger(t, chainid, path)
if err != nil {
t.Fatalf(err.Error())
t.Fatal(err.Error())
}
defer cleanup()

Expand Down Expand Up @@ -415,7 +415,7 @@ func TestQueryNonexistentFunction(t *testing.T) {

mockStub, lq, _, cleanup, err := setupTestLedger(t, chainid, path)
if err != nil {
t.Fatalf(err.Error())
t.Fatal(err.Error())
}
defer cleanup()

Expand All @@ -436,7 +436,7 @@ func TestQueryGeneratedBlock(t *testing.T) {

mockStub, lq, p, cleanup, err := setupTestLedger(t, chainid, path)
if err != nil {
t.Fatalf(err.Error())
t.Fatal(err.Error())
}
defer cleanup()

Expand Down Expand Up @@ -471,7 +471,7 @@ func TestQueryGeneratedBlock(t *testing.T) {
}
chdr, err := protoutil.UnmarshalChannelHeader(payload.Header.ChannelHeader)
if err != nil {
t.Fatalf(err.Error())
t.Fatal(err.Error())
}
if common.HeaderType(chdr.Type) == common.HeaderType_ENDORSER_TRANSACTION {
args = [][]byte{[]byte(GetBlockByTxID), []byte(chainid), []byte(chdr.TxId)}
Expand Down
2 changes: 1 addition & 1 deletion gotools.mk
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ go.fqp.misspell := github.com/client9/misspell/cmd/misspell
go.fqp.mockery := github.com/vektra/mockery/cmd/mockery
go.fqp.protoc-gen-go := google.golang.org/protobuf/cmd/protoc-gen-go
go.fqp.protoc-gen-go-grpc := google.golang.org/grpc/cmd/protoc-gen-go-grpc
go.fqp.staticcheck := honnef.co/go/tools/cmd/staticcheck@2023.1.7
go.fqp.staticcheck := honnef.co/go/tools/cmd/staticcheck@2024.1.1
go.fqp.swagger := github.com/go-swagger/go-swagger/cmd/swagger

.PHONY: gotools-install
Expand Down
2 changes: 1 addition & 1 deletion internal/peer/chaincode/invoke_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ func getMockDeliverClientRespondAfterDelay(delayChan chan struct{}, txStatus pb.
func getMockDeliverClientWithErr(errMsg string) *mock.PeerDeliverClient {
mockDC := &mock.PeerDeliverClient{}
mockDC.DeliverFilteredStub = func(ctx context.Context, opts ...grpc.CallOption) (pb.Deliver_DeliverFilteredClient, error) {
return nil, fmt.Errorf(errMsg)
return nil, errors.New(errMsg)
}
return mockDC
}
Expand Down
2 changes: 1 addition & 1 deletion orderer/consensus/smartbft/configverifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func (cbv *ConfigBlockValidator) checkConsentersMatchPolicy(conf *cb.Config) err
Value: protoutil.MarshalOrPanic(sp),
}

if conf.ChannelGroup.Groups["Orderer"].Policies == nil || len(conf.ChannelGroup.Groups["Orderer"].Policies) == 0 {
if len(conf.ChannelGroup.Groups["Orderer"].Policies) == 0 {
return fmt.Errorf("empty policies in 'Orderer' group")
}

Expand Down