Skip to content

Commit b675540

Browse files
authored
fix(lint): fix lint errors (#4760)
1 parent da3b0d3 commit b675540

File tree

6 files changed

+14
-13
lines changed

6 files changed

+14
-13
lines changed

blob/service_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ func TestService_GetSingleBlobWithoutPadding(t *testing.T) {
469469
rawShares1, err := BlobsToShares(blobs[1])
470470
require.NoError(t, err)
471471

472-
rawShares := make([]libshare.Share, 0)
472+
rawShares := make([]libshare.Share, 0) //nolint:prealloc
473473
rawShares = append(rawShares, append(rawShares0, padding0)...)
474474
rawShares = append(rawShares, append(rawShares1, padding1)...)
475475
service := createService(ctx, t, rawShares)
@@ -544,7 +544,7 @@ func TestService_GetAllWithoutPadding(t *testing.T) {
544544
blobs, err := convertBlobs(libBlob...)
545545
require.NoError(t, err)
546546

547-
rawShares := make([]libshare.Share, 0)
547+
rawShares := make([]libshare.Share, 0) //nolint:prealloc
548548

549549
require.NoError(t, err)
550550
padding, err := libshare.NamespacePaddingShare(blobs[0].Namespace(), libshare.ShareVersionZero)

nodebuilder/da/service.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ func (s *Service) GetIDs(ctx context.Context, height uint64, namespace da.Namesp
116116
return nil, err
117117
}
118118

119-
var ids []da.ID //nolint:prealloc
120119
log.Debugw("getting ids", "height", height, "namespace", ns)
121120
blobs, err := s.blobServ.GetAll(ctx, height, []libshare.Namespace{ns})
122121
log.Debugw("got ids", "height", height, "namespace", ns)
@@ -126,6 +125,8 @@ func (s *Service) GetIDs(ctx context.Context, height uint64, namespace da.Namesp
126125
}
127126
return nil, err
128127
}
128+
129+
ids := make([]da.ID, 0, len(blobs))
129130
for _, b := range blobs {
130131
ids = append(ids, MakeID(height, b.Commitment))
131132
}

share/eds/edstest/testing.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func GenerateTestBlock(
130130
blobSize,
131131
)
132132

133-
txs := make(coretypes.Txs, 0)
133+
txs := make(coretypes.Txs, 0) //nolint:prealloc
134134
txs = append(txs, coreTxs...)
135135

136136
eds, err := da.ConstructEDS(txs.ToSliceOfBytes(), appconsts.Version, -1)
@@ -152,10 +152,10 @@ func createTestBlobTransactions(
152152
t *testing.T,
153153
numberOfTransactions, size int,
154154
) ([]libshare.Namespace, []*blobtypes.MsgPayForBlobs, []*libshare.Blob, []coretypes.Tx) {
155-
nss := make([]libshare.Namespace, 0)
156-
msgs := make([]*blobtypes.MsgPayForBlobs, 0)
157-
blobs := make([]*libshare.Blob, 0)
158-
coreTxs := make([]coretypes.Tx, 0)
155+
nss := make([]libshare.Namespace, 0, numberOfTransactions)
156+
msgs := make([]*blobtypes.MsgPayForBlobs, 0, numberOfTransactions)
157+
blobs := make([]*libshare.Blob, 0, numberOfTransactions)
158+
coreTxs := make([]coretypes.Tx, 0, numberOfTransactions)
159159
config := encoding.MakeConfig(app.ModuleEncodingRegisters...)
160160
keyring := testfactory.TestKeyring(config.Codec, accountName)
161161
account := user.NewAccount(accountName, 0, 0)

share/ipld/get_shares_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ func TestGetSharesByNamespace(t *testing.T) {
176176
eds, err := AddShares(ctx, tt.rawData, bServ)
177177
require.NoError(t, err)
178178

179-
var shares []libshare.Share
179+
shares := make([]libshare.Share, 0)
180180
rowRoots, err := eds.RowRoots()
181181
require.NoError(t, err)
182182
for _, row := range rowRoots {
@@ -373,7 +373,7 @@ func TestGetSharesWithProofsByNamespace(t *testing.T) {
373373
eds, err := AddShares(ctx, tt.rawData, bServ)
374374
require.NoError(t, err)
375375

376-
var shares []libshare.Share
376+
shares := make([]libshare.Share, 0)
377377
rowRoots, err := eds.RowRoots()
378378
require.NoError(t, err)
379379
for _, row := range rowRoots {
@@ -391,7 +391,7 @@ func TestGetSharesWithProofsByNamespace(t *testing.T) {
391391
shares = append(shares, rowShares...)
392392

393393
// construct nodes from shares by prepending namespace
394-
var leaves [][]byte
394+
leaves := make([][]byte, 0, len(rowShares))
395395
for _, shr := range rowShares {
396396
leaves = append(leaves, append(shr.Namespace().Bytes(), shr.ToBytes()...))
397397
}

share/shwap/namespace_data.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type NamespaceData []RowNamespaceData
2121

2222
// Flatten combines all shares from all rows within the namespace into a single slice.
2323
func (nd NamespaceData) Flatten() []libshare.Share {
24-
var shares []libshare.Share
24+
var shares []libshare.Share //nolint:prealloc
2525
for _, row := range nd {
2626
shares = append(shares, row.Shares...)
2727
}

share/shwap/range_namespace_data.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ func (rngdata *RangeNamespaceData) verifyShares(
257257
// If the RangeNamespaceData is empty (i.e., contains no shares), Flatten returns nil.
258258
// Otherwise, it returns a flattened slice of libshare.Share combining shares from all rows.
259259
func (rngdata *RangeNamespaceData) Flatten() []libshare.Share {
260-
var shares []libshare.Share
260+
var shares []libshare.Share //nolint:prealloc
261261
for _, shrs := range rngdata.Shares {
262262
shares = append(shares, shrs...)
263263
}

0 commit comments

Comments
 (0)