Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

Commit ea94ad2

Browse files
author
Firas Qutishat
committed
[FAB-9312] Resolve metalinter warnings
- fix msp package - fix util package Change-Id: I85ab0032f8e114eb14fa0ef3ca034c7d6385053a Signed-off-by: Firas Qutishat <firas.qutishat@securekey.com>
1 parent c8911f3 commit ea94ad2

31 files changed

+369
-291
lines changed

gometalinter.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"Enable": [
99
"deadcode",
1010
"gocyclo",
11+
"gofmt",
1112
"gotype",
1213
"goimports",
1314
"golint",

pkg/common/errors/retry/defaults.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -68,93 +68,93 @@ var DefaultResMgmtOpts = Opts{
6868
// DefaultRetryableCodes these are the error codes, grouped by source of error,
6969
// that are considered to be transient error conditions by default
7070
var DefaultRetryableCodes = map[status.Group][]status.Code{
71-
status.EndorserClientStatus: []status.Code{
71+
status.EndorserClientStatus: {
7272
status.EndorsementMismatch,
7373
status.PrematureChaincodeExecution,
7474
},
75-
status.EndorserServerStatus: []status.Code{
75+
status.EndorserServerStatus: {
7676
status.Code(common.Status_SERVICE_UNAVAILABLE),
7777
status.Code(common.Status_INTERNAL_SERVER_ERROR),
7878
},
79-
status.OrdererServerStatus: []status.Code{
79+
status.OrdererServerStatus: {
8080
status.Code(common.Status_SERVICE_UNAVAILABLE),
8181
status.Code(common.Status_INTERNAL_SERVER_ERROR),
8282
},
83-
status.EventServerStatus: []status.Code{
83+
status.EventServerStatus: {
8484
status.Code(pb.TxValidationCode_DUPLICATE_TXID),
8585
status.Code(pb.TxValidationCode_ENDORSEMENT_POLICY_FAILURE),
8686
status.Code(pb.TxValidationCode_MVCC_READ_CONFLICT),
8787
status.Code(pb.TxValidationCode_PHANTOM_READ_CONFLICT),
8888
},
8989
// TODO: gRPC introduced retries in v1.8.0. This can be replaced with the
9090
// gRPC fail fast option, once available
91-
status.GRPCTransportStatus: []status.Code{
91+
status.GRPCTransportStatus: {
9292
status.Code(grpcCodes.Unavailable),
9393
},
9494
}
9595

9696
// ResMgmtDefaultRetryableCodes are the suggested codes that should be treated as
9797
// transient by fabric-sdk-go/pkg/client/resmgmt.Client
9898
var ResMgmtDefaultRetryableCodes = map[status.Group][]status.Code{
99-
status.EndorserClientStatus: []status.Code{
99+
status.EndorserClientStatus: {
100100
status.EndorsementMismatch,
101101
status.PrematureChaincodeExecution,
102102
},
103-
status.EndorserServerStatus: []status.Code{
103+
status.EndorserServerStatus: {
104104
status.Code(common.Status_SERVICE_UNAVAILABLE),
105105
status.Code(common.Status_INTERNAL_SERVER_ERROR),
106106
},
107-
status.OrdererServerStatus: []status.Code{
107+
status.OrdererServerStatus: {
108108
status.Code(common.Status_SERVICE_UNAVAILABLE),
109109
status.Code(common.Status_INTERNAL_SERVER_ERROR),
110110
status.Code(common.Status_BAD_REQUEST),
111111
status.Code(common.Status_NOT_FOUND),
112112
},
113-
status.EventServerStatus: []status.Code{
113+
status.EventServerStatus: {
114114
status.Code(pb.TxValidationCode_DUPLICATE_TXID),
115115
status.Code(pb.TxValidationCode_ENDORSEMENT_POLICY_FAILURE),
116116
status.Code(pb.TxValidationCode_MVCC_READ_CONFLICT),
117117
status.Code(pb.TxValidationCode_PHANTOM_READ_CONFLICT),
118118
},
119119
// TODO: gRPC introduced retries in v1.8.0. This can be replaced with the
120120
// gRPC fail fast option, once available
121-
status.GRPCTransportStatus: []status.Code{
121+
status.GRPCTransportStatus: {
122122
status.Code(grpcCodes.Unavailable),
123123
},
124124
}
125125

126126
// ChannelClientRetryableCodes are the suggested codes that should be treated as
127127
// transient by fabric-sdk-go/pkg/client/channel.Client
128128
var ChannelClientRetryableCodes = map[status.Group][]status.Code{
129-
status.EndorserClientStatus: []status.Code{
129+
status.EndorserClientStatus: {
130130
status.ConnectionFailed, status.EndorsementMismatch,
131131
status.PrematureChaincodeExecution,
132132
},
133-
status.EndorserServerStatus: []status.Code{
133+
status.EndorserServerStatus: {
134134
status.Code(common.Status_SERVICE_UNAVAILABLE),
135135
status.Code(common.Status_INTERNAL_SERVER_ERROR),
136136
},
137-
status.OrdererClientStatus: []status.Code{
137+
status.OrdererClientStatus: {
138138
status.ConnectionFailed,
139139
},
140-
status.OrdererServerStatus: []status.Code{
140+
status.OrdererServerStatus: {
141141
status.Code(common.Status_SERVICE_UNAVAILABLE),
142142
status.Code(common.Status_INTERNAL_SERVER_ERROR),
143143
},
144-
status.EventServerStatus: []status.Code{
144+
status.EventServerStatus: {
145145
status.Code(pb.TxValidationCode_DUPLICATE_TXID),
146146
status.Code(pb.TxValidationCode_ENDORSEMENT_POLICY_FAILURE),
147147
status.Code(pb.TxValidationCode_MVCC_READ_CONFLICT),
148148
status.Code(pb.TxValidationCode_PHANTOM_READ_CONFLICT),
149149
},
150150
// TODO: gRPC introduced retries in v1.8.0. This can be replaced with the
151151
// gRPC fail fast option, once available
152-
status.GRPCTransportStatus: []status.Code{
152+
status.GRPCTransportStatus: {
153153
status.Code(grpcCodes.Unavailable),
154154
},
155155
}
156156

157157
// ChannelConfigRetryableCodes error codes to be taken into account for query channel config retry
158158
var ChannelConfigRetryableCodes = map[status.Group][]status.Code{
159-
status.EndorserClientStatus: []status.Code{status.EndorsementMismatch},
159+
status.EndorserClientStatus: {status.EndorsementMismatch},
160160
}

pkg/core/logging/metadata/callerInfo.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ func (l *CallerInfo) IsCallerInfoEnabled(module string, level api.Level) bool {
5050
//getDefaultCallerInfoSetting default setting for callerinfo
5151
func (l *CallerInfo) getDefaultCallerInfoSetting() map[callerInfoKey]bool {
5252
return map[callerInfoKey]bool{
53-
callerInfoKey{"", api.CRITICAL}: true,
54-
callerInfoKey{"", api.ERROR}: true,
55-
callerInfoKey{"", api.WARNING}: true,
56-
callerInfoKey{"", api.INFO}: true,
57-
callerInfoKey{"", api.DEBUG}: true,
53+
{"", api.CRITICAL}: true,
54+
{"", api.ERROR}: true,
55+
{"", api.WARNING}: true,
56+
{"", api.INFO}: true,
57+
{"", api.DEBUG}: true,
5858
}
5959
}

pkg/fab/events/eventhubclient/connection/connection_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func TestSend(t *testing.T) {
6464
Event: &pb.Event_Register{
6565
Register: &pb.Register{
6666
Events: []*pb.Interest{
67-
&pb.Interest{EventType: pb.EventType_FILTEREDBLOCK},
67+
{EventType: pb.EventType_FILTEREDBLOCK},
6868
},
6969
},
7070
},
@@ -100,7 +100,7 @@ func TestSend(t *testing.T) {
100100
Event: &pb.Event_Unregister{
101101
Unregister: &pb.Unregister{
102102
Events: []*pb.Interest{
103-
&pb.Interest{EventType: pb.EventType_FILTEREDBLOCK},
103+
{EventType: pb.EventType_FILTEREDBLOCK},
104104
},
105105
},
106106
},
@@ -155,7 +155,7 @@ func TestDisconnected(t *testing.T) {
155155
Event: &pb.Event_Register{
156156
Register: &pb.Register{
157157
Events: []*pb.Interest{
158-
&pb.Interest{EventType: pb.EventType_FILTEREDBLOCK},
158+
{EventType: pb.EventType_FILTEREDBLOCK},
159159
},
160160
},
161161
},

pkg/fab/events/eventhubclient/dispatcher/dispatcher_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func TestRegisterInterests(t *testing.T) {
6666
// Unregister interests
6767
dispatcherEventch <- NewUnregisterInterestsEvent(
6868
[]*pb.Interest{
69-
&pb.Interest{
69+
{
7070
EventType: pb.EventType_FILTEREDBLOCK,
7171
},
7272
},
@@ -108,7 +108,7 @@ func TestRegisterInterests(t *testing.T) {
108108
func registerFilteredBlockEvent(dispatcherEventch chan<- interface{}, errch chan error, t *testing.T) chan<- interface{} {
109109
dispatcherEventch <- NewRegisterInterestsEvent(
110110
[]*pb.Interest{
111-
&pb.Interest{
111+
{
112112
EventType: pb.EventType_FILTEREDBLOCK,
113113
},
114114
},
@@ -127,7 +127,7 @@ func registerFilteredBlockEvent(dispatcherEventch chan<- interface{}, errch chan
127127
func checkFailedRegisterInterest(dispatcherEventch chan<- interface{}, errch chan error, t *testing.T) chan<- interface{} {
128128
dispatcherEventch <- NewRegisterInterestsEvent(
129129
[]*pb.Interest{
130-
&pb.Interest{
130+
{
131131
EventType: pb.EventType_FILTEREDBLOCK,
132132
},
133133
},
@@ -164,7 +164,7 @@ func TestRegisterInterestsInvalid(t *testing.T) {
164164
// Unregister interests
165165
dispatcherEventch <- NewUnregisterInterestsEvent(
166166
[]*pb.Interest{
167-
&pb.Interest{
167+
{
168168
EventType: pb.EventType_FILTEREDBLOCK,
169169
},
170170
},
@@ -278,7 +278,7 @@ func TestTimedOutRegister(t *testing.T) {
278278
// Register interests
279279
dispatcherEventch <- NewRegisterInterestsEvent(
280280
[]*pb.Interest{
281-
&pb.Interest{
281+
{
282282
EventType: pb.EventType_FILTEREDBLOCK,
283283
},
284284
},

pkg/fab/events/eventhubclient/opts.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import (
1313
pb "github.com/hyperledger/fabric-sdk-go/third_party/github.com/hyperledger/fabric/protos/peer"
1414
)
1515

16-
var blockInterests = []*pb.Interest{&pb.Interest{EventType: pb.EventType_BLOCK}}
17-
var filteredBlockInterests = []*pb.Interest{&pb.Interest{EventType: pb.EventType_FILTEREDBLOCK}}
16+
var blockInterests = []*pb.Interest{{EventType: pb.EventType_BLOCK}}
17+
var filteredBlockInterests = []*pb.Interest{{EventType: pb.EventType_FILTEREDBLOCK}}
1818

1919
type params struct {
2020
connProvider api.ConnectionProvider

pkg/fab/events/service/mocks/mockevents.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func NewFilteredTxWithCCEvent(txID, ccID, event string) *pb.FilteredTransaction
9292
Data: &pb.FilteredTransaction_TransactionActions{
9393
TransactionActions: &pb.FilteredTransactionActions{
9494
ChaincodeActions: []*pb.FilteredChaincodeAction{
95-
&pb.FilteredChaincodeAction{
95+
{
9696
ChaincodeEvent: &pb.ChaincodeEvent{
9797
ChaincodeId: ccID,
9898
EventName: event,

pkg/fab/mocks/mockbroadcastserver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func StartMockBroadcastServer(broadcastTestURL string, grpcServer *grpc.Server)
102102
po.RegisterAtomicBroadcastServer(grpcServer, broadcastServer)
103103
go func() {
104104
if err := grpcServer.Serve(lis); err != nil {
105-
panic(err.Error())
105+
fmt.Printf("StartMockBroadcastServer failed to start %v", err.Error())
106106
}
107107
}()
108108

pkg/fab/mocks/mockendorserserver.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ func (m *MockEndorserServer) createProposalResponsePayload() []byte {
4949

5050
if m.AddkvWrite {
5151
txRwSet.NsRwSets = []*rwsetutil.NsRwSet{
52-
&rwsetutil.NsRwSet{NameSpace: "ns1", KvRwSet: &kvrwset.KVRWSet{
53-
Reads: []*kvrwset.KVRead{&kvrwset.KVRead{Key: "key1", Version: &kvrwset.Version{BlockNum: 1, TxNum: 1}}},
54-
Writes: []*kvrwset.KVWrite{&kvrwset.KVWrite{Key: "key2", IsDelete: false, Value: []byte("value2")}},
52+
{NameSpace: "ns1", KvRwSet: &kvrwset.KVRWSet{
53+
Reads: []*kvrwset.KVRead{{Key: "key1", Version: &kvrwset.Version{BlockNum: 1, TxNum: 1}}},
54+
Writes: []*kvrwset.KVWrite{{Key: "key2", IsDelete: false, Value: []byte("value2")}},
5555
}}}
5656
}
5757

pkg/fab/mocks/mockeventserver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func StartMockEventServer(testAddress string) (*MockEventServer, error) {
3535
fmt.Printf("Starting mock event server\n")
3636
go func() {
3737
if err := grpcServer.Serve(lis); err != nil {
38-
panic(err.Error())
38+
fmt.Printf("StartMockEventServer failed %v", err.Error())
3939
}
4040
}()
4141

0 commit comments

Comments
 (0)