Skip to content

Commit

Permalink
exclude a bunch of checks from make lint
Browse files Browse the repository at this point in the history
This commit also removes the following items from lint checks :
* `goconst`
* `structcheck`
* `deadcode`
* `golint`
* `varcheck`
  • Loading branch information
siddarthkay committed Apr 9, 2024
1 parent b958ace commit 3b8f754
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 19 deletions.
5 changes: 0 additions & 5 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,17 @@ linters-settings:
linters:
disable-all: true
enable:
- deadcode
- errcheck
- gosec
- goconst
- goimports
- golint
- govet
- ineffassign
- megacheck
- misspell
- structcheck
# You can't disable typecheck, see:
# https://github.com/golangci/golangci-lint/blob/master/docs/src/docs/welcome/faq.mdx#why-do-you-have-typecheck-errors
- typecheck
- unconvert
- varcheck
fast: false

issues:
Expand Down
8 changes: 6 additions & 2 deletions mailserver/mailserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ func (s *MailserverSuite) TestInit() {
},
}

for _, tc := range testCases {
for _, testCase := range testCases {
// to satisfy gosec: C601 checks
tc := testCase
s.T().Run(tc.info, func(*testing.T) {
mailServer := &WakuMailServer{}
shh := waku.New(&waku.DefaultConfig, nil)
Expand Down Expand Up @@ -299,7 +301,9 @@ func (s *MailserverSuite) TestMailServer() {
info: "Processing a request where difference between from and to is > 24 should fail",
},
}
for _, tc := range testCases {
for _, testCase := range testCases {
// to satisfy gosec: C601 checks
tc := testCase
s.T().Run(tc.info, func(*testing.T) {
request := s.createRequest(tc.params)
src := crypto.FromECDSAPub(&tc.params.key.PublicKey)
Expand Down
3 changes: 2 additions & 1 deletion multiaccounts/accounts/keycard_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,8 @@ func (db *Database) deleteKeycardAccounts(tx *sql.Tx, kcUID string, accountAddre
}

inVector := strings.Repeat(",?", len(accountAddresses)-1)
query := `
//nolint: gosec
query := `
DELETE
FROM
keycards_accounts
Expand Down
2 changes: 1 addition & 1 deletion protocol/activity_center_persistence.go
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ func (db sqlitePersistence) MarkActivityCenterNotificationsDeleted(ids []types.H
return nil, err
}

update := "UPDATE activity_center_notifications SET deleted = 1, updated_at = ? WHERE id IN (" + inVector + ") AND NOT deleted"
update := "UPDATE activity_center_notifications SET deleted = 1, updated_at = ? WHERE id IN (" + inVector + ") AND NOT deleted" //nolint: gosec
_, err = tx.Exec(update, args...)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion protocol/communities/persistence.go
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ func (p *Persistence) GetLatestWakuMessageTimestamp(topics []types.TopicType) (u

func (p *Persistence) GetWakuMessagesByFilterTopic(topics []types.TopicType, from uint64, to uint64) ([]types.Message, error) {

query := "SELECT sig, timestamp, topic, payload, padding, hash, third_party_id FROM waku_messages WHERE timestamp >= " + fmt.Sprint(from) + " AND timestamp < " + fmt.Sprint(to) + " AND ("
query := "SELECT sig, timestamp, topic, payload, padding, hash, third_party_id FROM waku_messages WHERE timestamp >= " + fmt.Sprint(from) + " AND timestamp < " + fmt.Sprint(to) + " AND (" //nolint: gosec

for i, topic := range topics {
query += `topic = "` + topic.String() + `"`
Expand Down
2 changes: 1 addition & 1 deletion protocol/message_persistence.go
Original file line number Diff line number Diff line change
Expand Up @@ -3016,7 +3016,7 @@ func (db sqlitePersistence) findStatusMessageIDForBridgeMessageID(tx *sql.Tx, me
}

func (db sqlitePersistence) updateStatusMessagesWithResponse(tx *sql.Tx, statusMessagesToUpdate []string, responseValue string) error {
sql := "UPDATE user_messages SET response_to = ? WHERE id IN (?" + strings.Repeat(",?", len(statusMessagesToUpdate)-1) + ")"
sql := "UPDATE user_messages SET response_to = ? WHERE id IN (?" + strings.Repeat(",?", len(statusMessagesToUpdate)-1) + ")" //nolint: gosec
stmt, err := tx.Prepare(sql)
if err != nil {
return err
Expand Down
4 changes: 3 additions & 1 deletion protocol/transport/filters_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@ func (f *FiltersManager) InitCommunityFilters(communityFiltersToInitialize []Com
f.mutex.Lock()
defer f.mutex.Unlock()

for _, cf := range communityFiltersToInitialize {
for _, communityFilter := range communityFiltersToInitialize {
// to satisfy gosec: C601 checks
cf := communityFilter
if cf.PrivKey == nil {
continue
}
Expand Down
4 changes: 3 additions & 1 deletion services/wallet/collectibles/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,9 @@ func (s *Service) notifyCommunityCollectiblesReceived(ownedCollectibles OwnedCol
}

groups := make(map[CollectibleGroup]Collectible)
for _, collectible := range communityCollectibles {
for _, localCollectible := range communityCollectibles {
// to satisfy gosec: C601 checks
collectible := localCollectible
txHash := ""
for key, value := range hashMap {
if key.Same(&collectible.ID) {
Expand Down
4 changes: 3 additions & 1 deletion services/wallet/collectibles/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ func fullCollectiblesDataToDetails(data []thirdparty.FullCollectibleData) []Coll
func fullCollectiblesDataToCommunityHeader(data []thirdparty.FullCollectibleData) []Collectible {
res := make([]Collectible, 0, len(data))

for _, c := range data {
for _, localCollectibleData := range data {
// to satisfy gosec: C601 checks
c := localCollectibleData
collectibleID := c.CollectibleData.ID
communityID := c.CollectibleData.CommunityID

Expand Down
2 changes: 1 addition & 1 deletion services/wallet/transfer/block_ranges_sequential_dao.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (b *BlockRangeSequentialDAO) getBlockRanges(chainID uint64, addresses []com
}
}

query := "SELECT address, blk_start, blk_first, blk_last, token_blk_start, token_blk_first, token_blk_last, balance_check_hash FROM blocks_ranges_sequential WHERE address IN (" +
query := "SELECT address, blk_start, blk_first, blk_last, token_blk_start, token_blk_first, token_blk_last, balance_check_hash FROM blocks_ranges_sequential WHERE address IN (" + //nolint: gosec
addressesPlaceholder + ") AND network_id = ?"

params := []interface{}{}
Expand Down
4 changes: 3 additions & 1 deletion services/wallet/transfer/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,9 @@ func insertBlocksWithTransactions(chainID uint64, creator statementCreator, head

func updateOrInsertTransfers(chainID uint64, creator statementCreator, transfers []Transfer) error {
txsDBFields := make([]transferDBFields, 0, len(transfers))
for _, t := range transfers {
for _, localTransfer := range transfers {
// to satisfy gosec: C601 checks
t := localTransfer
var receiptType *uint8
var txHash, blockHash *common.Hash
var receiptStatus, cumulativeGasUsed, gasUsed *uint64
Expand Down
8 changes: 6 additions & 2 deletions transactions/testhelpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ func MockTestTransactions(t *testing.T, chainClient *MockChainClient, testTxs []
return false
}
for i := range b {
for _, sum := range chainSummaries {
for _, localSummary := range chainSummaries {
// to satisfy gosec: C601 checks
sum := localSummary
tx := &sum.tx
if sum.answered {
continue
Expand All @@ -165,7 +167,9 @@ func MockTestTransactions(t *testing.T, chainClient *MockChainClient, testTxs []
require.True(t, ok)
require.NotNil(t, receiptWrapper)
// Simulate parsing of eth_getTransactionReceipt response
for _, sum := range chainSummaries {
for _, localSum := range chainSummaries {
// to satisfy gosec: C601 checks
sum := localSum
tx := &sum.tx
if tx.Hash == elems[i].Args[0].(eth.Hash) {
if !sum.summary.DontConfirm {
Expand Down
4 changes: 3 additions & 1 deletion transactions/transactor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,9 @@ func (s *TransactorSuite) TestSendTransactionWithSignature() {
},
}

for _, scenario := range scenarios {
for _, localScenario := range scenarios {
// to satisfy gosec: C601 checks
scenario := localScenario
desc := fmt.Sprintf("nonceFromNetwork: %d, tx nonce: %d, expect error: %v", scenario.nonceFromNetwork, scenario.txNonce, scenario.expectError)
s.T().Run(desc, func(t *testing.T) {
nonce := scenario.txNonce
Expand Down

0 comments on commit 3b8f754

Please sign in to comment.