From 3c60ac7f61b8d6e94e2053d165409c8108d7b059 Mon Sep 17 00:00:00 2001 From: Dhruba Basu <7675102+dhrubabasu@users.noreply.github.com> Date: Fri, 22 Sep 2023 16:26:29 -0400 Subject: [PATCH] Add `dupword` linter (#2087) --- .golangci.yml | 1 + api/keystore/keystore.go | 7 ------- chains/atomic/state.go | 2 +- database/test_database.go | 2 +- network/config.go | 2 +- snow/consensus/snowman/topological.go | 2 +- snow/engine/common/bootstrapper.go | 5 ----- snow/networking/handler/message_queue_metrics.go | 2 +- utils/crypto/bls/secret.go | 2 +- vms/components/index/index.go | 2 +- vms/platformvm/txs/mempool/mempool.go | 7 +++---- 11 files changed, 11 insertions(+), 23 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index d168b5f325fa..e330f88311da 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -18,6 +18,7 @@ linters: - asciicheck - bodyclose - depguard + - dupword - errcheck - errorlint - exportloopref diff --git a/api/keystore/keystore.go b/api/keystore/keystore.go index d1bb06b46ae4..fe3bee0e9dc0 100644 --- a/api/keystore/keystore.go +++ b/api/keystore/keystore.go @@ -103,13 +103,6 @@ type keystore struct { // Used to persist users and their data userDB database.Database bcDB database.Database - // BaseDB - // / \ - // UserDB BlockchainDB - // / | \ - // Usr Usr Usr - // / | \ - // BID BID BID } func New(log logging.Logger, dbManager manager.Manager) Keystore { diff --git a/chains/atomic/state.go b/chains/atomic/state.go index c16a0a2e8530..cd7a3f2a0faa 100644 --- a/chains/atomic/state.go +++ b/chains/atomic/state.go @@ -137,7 +137,7 @@ func (s *state) SetValue(e *Element) error { // // This implies that chains interacting with shared memory must be able to // generate their chain state without actually performing the read of shared -// memory. Shared memory should only be used to verify that the the transition +// memory. Shared memory should only be used to verify that the transition // being performed is valid. That ensures that such verification can be skipped // during bootstrapping. It is up to the chain to ensure this based on the // current engine state. diff --git a/database/test_database.go b/database/test_database.go index cb47f3bb5859..69fb1d2b7948 100644 --- a/database/test_database.go +++ b/database/test_database.go @@ -648,7 +648,7 @@ func TestIterator(t *testing.T, db Database) { require.NoError(iterator.Error()) } -// TestIteratorStart tests to make sure the the iterator can be configured to +// TestIteratorStart tests to make sure the iterator can be configured to // start mid way through the database. func TestIteratorStart(t *testing.T, db Database) { require := require.New(t) diff --git a/network/config.go b/network/config.go index 11191b836067..54b6e56b5220 100644 --- a/network/config.go +++ b/network/config.go @@ -26,7 +26,7 @@ type HealthConfig struct { Enabled bool `json:"-"` // MinConnectedPeers is the minimum number of peers that the network should - // be connected to to be considered healthy. + // be connected to be considered healthy. MinConnectedPeers uint `json:"minConnectedPeers"` // MaxTimeSinceMsgReceived is the maximum amount of time since the network diff --git a/snow/consensus/snowman/topological.go b/snow/consensus/snowman/topological.go index 0d8fd26e806c..38deaf26a9ff 100644 --- a/snow/consensus/snowman/topological.go +++ b/snow/consensus/snowman/topological.go @@ -483,7 +483,7 @@ func (ts *Topological) vote(ctx context.Context, voteStack []votes) (ids.ID, err // get the block that we are going to vote on parentBlock, notRejected := ts.blocks[vote.parentID] - // if the block block we are going to vote on was already rejected, then + // if the block we are going to vote on was already rejected, then // we should stop applying the votes if !notRejected { break diff --git a/snow/engine/common/bootstrapper.go b/snow/engine/common/bootstrapper.go index 3db15fb8dc9b..c2ff101b1f7e 100644 --- a/snow/engine/common/bootstrapper.go +++ b/snow/engine/common/bootstrapper.go @@ -143,11 +143,6 @@ func (b *bootstrapper) markAcceptedFrontierReceived(ctx context.Context, nodeID // Ask each bootstrap validator to filter the list of containers that we were // told are on the accepted frontier such that the list only contains containers // they think are accepted. - // - // Create a newAlpha taking using the sampled beacon - // Keep the proportion of b.Alpha in the newAlpha - // newAlpha := totalSampledWeight * b.Alpha / totalWeight - newAlpha := float64(b.sampledBeacons.Weight()*b.Alpha) / float64(b.Beacons.Weight()) failedBeaconWeight := b.Beacons.SubsetWeight(b.failedAcceptedFrontier) diff --git a/snow/networking/handler/message_queue_metrics.go b/snow/networking/handler/message_queue_metrics.go index e165d04593a1..ce28769a41ca 100644 --- a/snow/networking/handler/message_queue_metrics.go +++ b/snow/networking/handler/message_queue_metrics.go @@ -49,7 +49,7 @@ func (m *messageQueueMetrics) initialize( opMetric := prometheus.NewGauge(prometheus.GaugeOpts{ Namespace: namespace, Name: fmt.Sprintf("%s_count", opStr), - Help: fmt.Sprintf("Number of of %s messages in the message queue.", opStr), + Help: fmt.Sprintf("Number of %s messages in the message queue.", opStr), }) m.ops[op] = opMetric errs.Add(metricsRegisterer.Register(opMetric)) diff --git a/utils/crypto/bls/secret.go b/utils/crypto/bls/secret.go index a37961eb2251..04716ab13a48 100644 --- a/utils/crypto/bls/secret.go +++ b/utils/crypto/bls/secret.go @@ -17,7 +17,7 @@ var ( errFailedSecretKeyDeserialize = errors.New("couldn't deserialize secret key") // The ciphersuite is more commonly known as G2ProofOfPossession. - // There are two digests to ensure that that message space for normal + // There are two digests to ensure that message space for normal // signatures and the proof of possession are distinct. ciphersuiteSignature = []byte("BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_") ciphersuiteProofOfPossession = []byte("BLS_POP_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_") diff --git a/vms/components/index/index.go b/vms/components/index/index.go index 25f004dd3f7b..a1bced563979 100644 --- a/vms/components/index/index.go +++ b/vms/components/index/index.go @@ -175,7 +175,7 @@ func (i *indexer) Accept(txID ids.ID, inputUTXOs []*avax.UTXO, outputUTXOs []*av // Read returns IDs of transactions that changed [address]'s balance of [assetID], // starting at [cursor], in order of transaction acceptance. e.g. if [cursor] == 1, does -// not return the first transaction that changed the balance. (This is for for pagination.) +// not return the first transaction that changed the balance. (This is for pagination.) // Returns at most [pageSize] elements. // See AddressTxsIndexer func (i *indexer) Read(address []byte, assetID ids.ID, cursor, pageSize uint64) ([]ids.ID, error) { diff --git a/vms/platformvm/txs/mempool/mempool.go b/vms/platformvm/txs/mempool/mempool.go index cec810feb0dc..7d1ba9b609bd 100644 --- a/vms/platformvm/txs/mempool/mempool.go +++ b/vms/platformvm/txs/mempool/mempool.go @@ -69,10 +69,9 @@ type Mempool interface { // It's guaranteed that the returned tx, if not nil, is a StakerTx. PeekStakerTx() *txs.Tx - // Note: dropped txs are added to droppedTxIDs but not - // not evicted from unissued decision/staker txs. - // This allows previously dropped txs to be possibly - // reissued. + // Note: dropped txs are added to droppedTxIDs but are not evicted from + // unissued decision/staker txs. This allows previously dropped txs to be + // possibly reissued. MarkDropped(txID ids.ID, reason error) GetDropReason(txID ids.ID) error }