You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it worth offering a PR with the correction of alleged errors after the linter note golangci-lint?
An example of what the linter gives out, somewhere false positives, and somewhere it is worth adding logging
lib/db_utils.go:150:2: `_PrefixStakeIDTypeAmountStakeIDIndex` is unused (deadcode)
_PrefixStakeIDTypeAmountStakeIDIndex = []byte{26}
^
lib/db_utils.go:513:6: `_enumerateLimitedKeysReversedForPrefix` is unused (deadcode)
func _enumerateLimitedKeysReversedForPrefix(db *badger.DB, dbPrefix []byte, limit uint64) (_keysFound [][]byte, _valsFound [][]byte) {
^
lib/db_utils.go:1862:6: `_dbKeyForDiamondSenderToDiamondReceiverMappingWithoutEntry` is unused (deadcode)
func _dbKeyForDiamondSenderToDiamondReceiverMappingWithoutEntry(
^
lib/db_utils.go:4021:6: `_dbKeyForPublicKeyPostHash` is unused (deadcode)
func _dbKeyForPublicKeyPostHash(publicKey []byte, postHash *BlockHash) []byte {
^
lib/deso_math.go:98:2: `bigNegativeOneOne` is unused (deadcode)
bigNegativeOneOne = NewFloat().SetUint64(1)
^
lib/block_view_message_test.go:622:6: `_messagingKey` is unused (deadcode)
func _messagingKey(t *testing.T, chain *Blockchain, db *badger.DB, params *DeSoParams,
^
lib/blockchain_test.go:88:6: `_copyBlock` is unused (deadcode)
func _copyBlock(blk *MsgDeSoBlock) *MsgDeSoBlock {
^
lib/block_view_bitcoin_test.go:138:22: Error return value of `header.Deserialize` is not checked (errcheck)
header.Deserialize(bytes.NewBuffer(headerBytes))
^
lib/block_view_bitcoin_test.go:334:37: Error return value of `parsedBitcoinExchangeTxn.FromBytes` is not checked (errcheck)
parsedBitcoinExchangeTxn.FromBytes(bb)
^
lib/block_view_bitcoin_test.go:1031:37: Error return value of `parsedBitcoinExchangeTxn.FromBytes` is not checked (errcheck)
parsedBitcoinExchangeTxn.FromBytes(bb)
^
lib/block_view_bitcoin_test.go:1149:30: Error return value of `utxoView.ConnectTransaction` is not checked (errcheck)
utxoView.ConnectTransaction(burnTxn1, txHash1, burnTxn1Size, blockHeight, true /*verifySignature*/, false /*ignoreUtxos*/)
^
lib/block_view_bitcoin_test.go:1155:30: Error return value of `utxoView.ConnectTransaction` is not checked (errcheck)
utxoView.ConnectTransaction(burnTxn1, txHash1, burnTxn1Size, blockHeight, true /*verifySignature*/, false /*ignoreUtxos*/)
^
lib/block_view_bitcoin_test.go:1755:37: Error return value of `parsedBitcoinExchangeTxn.FromBytes` is not checked (errcheck)
parsedBitcoinExchangeTxn.FromBytes(bb)
^
lib/block_view_profile_test.go:1164:23: Error return value of `pprof.StartCPUProfile` is not checked (errcheck)
pprof.StartCPUProfile(f)
^
lib/block_view_test.go:472:33: Error return value of `utxoView.DisconnectTransaction` is not checked (errcheck)
utxoView.DisconnectTransaction(
^
lib/blockchain_test.go:530:10: Error return value of `flag.Set` is not checked (errcheck)
flag.Set("alsologtostderr", "true")
^
lib/db_utils.go:360:9: Error return value of `db.View` is not checked (errcheck)
db.View(func(txn *badger.Txn) error {
^
lib/db_utils.go:393:9: Error return value of `db.View` is not checked (errcheck)
db.View(func(txn *badger.Txn) error {
^
lib/db_utils.go:406:37: Error return value of `(*encoding/gob.Encoder).Encode` is not checked (errcheck)
gob.NewEncoder(pkidDataBuf).Encode(pkidEntry)
^
lib/db_utils.go:734:9: Error return value of `db.View` is not checked (errcheck)
db.View(func(txn *badger.Txn) error {
^
lib/db_utils.go:954:29: Error return value of `messagingGroupEntry.Decode` is not checked (errcheck)
messagingGroupEntry.Decode(valBytes)
^
lib/db_utils.go:1509:38: Error return value of `(*encoding/gob.Encoder).Encode` is not checked (errcheck)
gob.NewEncoder(repostDataBuf).Encode(repostEntry)
^
lib/db_utils.go:1887:40: Error return value of `(*encoding/gob.Encoder).Encode` is not checked (errcheck)
gob.NewEncoder(diamondEntryBuf).Encode(diamondEntry)
^
lib/db_utils.go:2288:13: Error return value of `handle.View` is not checked (errcheck)
handle.View(func(txn *badger.Txn) error {
^
lib/db_utils.go:2336:13: Error return value of `handle.View` is not checked (errcheck)
handle.View(func(txn *badger.Txn) error {
^
lib/db_utils.go:2364:13: Error return value of `handle.View` is not checked (errcheck)
handle.View(func(txn *badger.Txn) error {
^
lib/db_utils.go:3013:17: Error return value of `nodeValue.Value` is not checked (errcheck)
nodeValue.Value(func(nodeBytes []byte) error {
^
lib/db_utils.go:3421:15: Error return value of `handle.Update` is not checked (errcheck)
handle.Update(func(dbTxn *badger.Txn) error {
^
lib/db_utils.go:4637:53: Error return value of `(*encoding/gob.Decoder).Decode` is not checked (errcheck)
gob.NewDecoder(bytes.NewReader(byteString)).Decode(currentEntry)
^
lib/db_utils.go:4686:53: Error return value of `(*encoding/gob.Decoder).Decode` is not checked (errcheck)
gob.NewDecoder(bytes.NewReader(byteString)).Decode(currentEntry)
^
lib/db_utils.go:6120:15: Error return value of `handle.Update` is not checked (errcheck)
handle.Update(func(txn *badger.Txn) error {
^
lib/db_utils_test.go:45:21: Error return value of `bs.Header.FromBytes` is not checked (errcheck)
bs.Header.FromBytes(headerBytes)
^
lib/load_test.go:130:24: Error return value of `pprof.StartCPUProfile` is not checked (errcheck)
pprof.StartCPUProfile(ff)
^
lib/load_test.go:231:24: Error return value of `pprof.StartCPUProfile` is not checked (errcheck)
pprof.StartCPUProfile(ff)
^
lib/mempool.go:339:28: Error return value of `mp.regenerateReadOnlyView` is not checked (errcheck)
mp.regenerateReadOnlyView()
^
lib/mempool.go:628:28: Error return value of `mp.limitNumUnconnectedTxns` is not checked (errcheck)
mp.limitNumUnconnectedTxns()
^
lib/mempool.go:2090:28: Error return value of `mp.regenerateReadOnlyView` is not checked (errcheck)
mp.regenerateReadOnlyView()
^
lib/mempool.go:2273:31: Error return value of `mp.RegenerateReadOnlyView` is not checked (errcheck)
mp.RegenerateReadOnlyView()
^
lib/network.go:2240:33: Error return value of `blockProducerInfo.Deserialize` is not checked (errcheck)
blockProducerInfo.Deserialize(blockProducerInfoBytes)
^
lib/network.go:2834:16: Error return value of `json.Unmarshal` is not checked (errcheck)
json.Unmarshal(data, &anonymousTxn)
^
lib/network_test.go:489:25: Error return value of `invMsgFromBuf.FromBytes` is not checked (errcheck)
invMsgFromBuf.FromBytes(bb)
^
lib/network_test.go:646:23: Error return value of `bitcoinTx.Deserialize` is not checked (errcheck)
bitcoinTx.Deserialize(bytes.NewReader(bitcoinTxBytes))
^
lib/network_test.go:837:16: Error return value of `faker.FakeData` is not checked (errcheck)
faker.FakeData(&txMeta)
^
lib/network_test.go:861:16: Error return value of `faker.FakeData` is not checked (errcheck)
faker.FakeData(&txMeta)
^
lib/network_test.go:1263:20: Error return value of `v0Header.FromBytes` is not checked (errcheck)
v0Header.FromBytes(headerBytes)
^
lib/network_test.go:1283:19: Error return value of `v0Block.FromBytes` is not checked (errcheck)
v0Block.FromBytes(blockBytes)
^
lib/server.go:1378:27: Error return value of `srv.statsdClient.Gauge` is not checked (errcheck)
srv.statsdClient.Gauge("MEMPOOL.COUNT", float64(mempoolTotal), tags, 1)
^
lib/server.go:1382:27: Error return value of `srv.statsdClient.Gauge` is not checked (errcheck)
srv.statsdClient.Gauge("BLOCKS.HEIGHT", float64(blocksHeight), tags, 1)
^
lib/server.go:1385:27: Error return value of `srv.statsdClient.Gauge` is not checked (errcheck)
srv.statsdClient.Gauge("HEADERS.HEIGHT", float64(headersHeight), tags, 1)
^
lib/postgres.go:438:2: `tableName` is unused (structcheck)
tableName struct{} `pg:"pg_notifications"`
^
lib/postgres.go:601:2: `tableName` is unused (structcheck)
tableName struct{} `pg:"pg_follows"`
^
lib/postgres.go:289:2: `tableName` is unused (structcheck)
tableName struct{} `pg:"pg_metadata_dao_coins"`
^
lib/server.go:55:2: `eventManager` is unused (structcheck)
eventManager *EventManager
^
lib/postgres.go:792:2: `isDeleted` is unused (structcheck)
isDeleted bool
^
lib/notifier.go:241:27: func `(*Notifier).notifyBasicTransfers` is unused (unused)
func (notifier *Notifier) notifyBasicTransfers() {
^
lib/db_utils.go:530:6: func `_enumerateLimitedKeysReversedForPrefixWithTxn` is unused (unused)
func _enumerateLimitedKeysReversedForPrefixWithTxn(dbTxn *badger.Txn, dbPrefix []byte, limit uint64) (_keysFound [][]byte, _valsFound [][]byte, _err error) {
^
lib/postgres.go:1869:27: func `(*Postgres).flushMessagingGroups` is unused (unused)
func (postgres *Postgres) flushMessagingGroups(tx *pg.Tx, view *UtxoView) error {
^
lib/mempool.go:925:24: func `(*DeSoMempool)._quickCheckBitcoinExchangeTxn` is unused (unused)
func (mp *DeSoMempool) _quickCheckBitcoinExchangeTxn(
^
lib/block_view_message.go:173:22: func `(*UtxoView).deleteMessageMappings` is unused (unused)
func (bav *UtxoView) deleteMessageMappings(message *PGMessage) {
^
lib/db_utils.go:119:2: var `_PrefixPosterPublicKeyPostHash` is unused (unused)
_PrefixPosterPublicKeyPostHash = []byte{18}
^
lib/block_view_message.go:156:22: func `(*UtxoView).getMessage` is unused (unused)
func (bav *UtxoView) getMessage(messageHash *BlockHash) *PGMessage {
^
lib/block_view.go:1319:3: S1005: unnecessary assignment to the blank identifier (gosimple)
currentAmount, _ := amountsByPublicKey[MakePkMapKey(desoOutput.PublicKey)]
^
lib/block_view.go:1401:3: S1005: unnecessary assignment to the blank identifier (gosimple)
diamondRecipientTotal, _ := amountsByPublicKey[MakePkMapKey(diamondRecipientPubKey)]
^
lib/block_view_dao_coin_limit_order.go:1321:2: S1005: unnecessary assignment to the blank identifier (gosimple)
outputEntry, _ := bav.DAOCoinLimitOrderMapKeyToDAOCoinLimitOrderEntry[mapKey]
^
lib/constants.go:110:24: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
TikTokShortURLRegex = regexp.MustCompile("^.*(vm\\.tiktok\\.com/)([A-Za-z0-9]{6,12}).*")
^
lib/constants.go:111:24: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
TikTokFullURLRegex = regexp.MustCompile("^.*((tiktok\\.com/)(v/)|(@[A-Za-z0-9_-]{2,24}/video/)|(embed/v2/))(\\d{0,30}).*")
^
lib/mempool.go:1325:22: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
dollarTagRegex := regexp.MustCompile("\\w*[a-zA-Z_]\\w*")
^
lib/block_view_dao_coin_limit_order.go:1574:2: S1008: should use 'return exchangeRateProduct.Cmp(rightHandSide) >= 0' instead of 'if exchangeRateProduct.Cmp(rightHandSide) < 0 { return false }; return true' (gosimple)
if exchangeRateProduct.Cmp(rightHandSide) < 0 {
^
lib/db_utils.go:3801:2: S1008: should use 'return err == nil' instead of 'if err != nil { return false }; return true' (gosimple)
if err != nil {
^
lib/types.go:69:27: S1019: should use make([]byte, 33) instead (gosimple)
valBytes := make([]byte, 33, 33)
^
lib/types.go:182:27: S1019: should use make([]byte, HashSizeBytes) instead (gosimple)
valBytes := make([]byte, HashSizeBytes, HashSizeBytes)
^
lib/types.go:211:23: S1019: should use make([]byte, 32) instead (gosimple)
data := make([]byte, 32, 32)
^
lib/types.go:216:27: S1019: should use make([]byte, 32) instead (gosimple)
valBytes := make([]byte, 32, 32)
^
lib/bitcoin_burner.go:632:9: S1039: unnecessary use of fmt.Sprintf (gosimple)
URL := fmt.Sprintf("http://api.blockcypher.com/v1/btc/main/txs/push")
^
lib/bitcoin_burner.go:634:9: S1039: unnecessary use of fmt.Sprintf (gosimple)
URL = fmt.Sprintf("http://api.blockcypher.com/v1/btc/test3/txs/push")
^
lib/supply_test.go:203:2: unreachable: unreachable code (govet)
{
^
lib/db_utils.go:5099:2: ineffectual assignment to err (ineffassign)
err = derivedKeyEntryItem.Value(func(valBytes []byte) error {
^
lib/network.go:5901:17: ineffectual assignment to err (ineffassign)
numRecipients, err := ReadUvarint(rr)
^
lib/block_view_derived_key_test.go:238:52: ineffectual assignment to err (ineffassign)
txn, totalInputMake, changeAmountMake, feesMake, err = chain.CreateAuthorizeDerivedKeyTxn(
^
lib/block_view_derived_key_test.go:1232:3: ineffectual assignment to testUtxoOps (ineffassign)
testUtxoOps = append(testUtxoOps, utxoOps)
^
lib/block_view_derived_key_test.go:2154:3: ineffectual assignment to testUtxoOps (ineffassign)
testUtxoOps = append(testUtxoOps, utxoOps)
^
lib/block_view_post_test.go:1930:3: ineffectual assignment to totalInput (ineffassign)
totalInput, _, _, fees, err :=
^
lib/txindex.go:158:3: SA2000: should call txi.updateWaitGroup.Add(1) before starting the goroutine to avoid a race (staticcheck)
txi.updateWaitGroup.Add(1)
^
lib/block_view_message.go:314:6: SA4003: no value of type uint64 is less than 0 (staticcheck)
if version < 0 || version > MessagesVersion3 {
^
lib/block_view_post.go:936:6: SA4003: no value of type uint64 is less than 0 (staticcheck)
if txMeta.CreatorBasisPoints < 0 ||
^
lib/block_view_profile.go:566:72: SA4003: no value of type uint64 is less than 0 (staticcheck)
if txMeta.NewCreatorBasisPoints > bav.Params.MaxCreatorBasisPoints || txMeta.NewCreatorBasisPoints < 0 {
^
lib/block_view.go:2057:2: SA9003: empty branch (staticcheck)
if verifySignatures {
^
lib/block_view.go:2624:2: SA9003: empty branch (staticcheck)
if len(outputs) > 0 {
^
lib/block_view_bitcoin.go:186:2: SA9003: empty branch (staticcheck)
if verifySignatures {
^
lib/db_utils.go:3460:3: SA4004: the surrounding loop is unconditionally terminated (staticcheck)
return uint64(countVal + 1)
^
lib/blockchain.go:3308:26: SA4001: &*x will be simplified to x. It will not copy x. (staticcheck)
TransactorPublicKey: &(*publicKey), // create a pointer to a copy of the public key
^
lib/block_view_bitcoin_test.go:2004:3: SA4006: this value of `bitcoinExchangeTxns` is never used (staticcheck)
bitcoinExchangeTxns = append(bitcoinExchangeTxns, txn)
^
lib/block_view_derived_key_test.go:2727:2: SA4006: this value of `err` is never used (staticcheck)
m0PrivKeyBytes, _, err := Base58CheckDecode(m0Priv)
^
lib/supply_test.go:118:2: SA4006: this value of `assert` is never used (staticcheck)
assert := assert.New(t)
^
lib/supply_test.go:119:2: SA4006: this value of `require` is never used (staticcheck)
require := require.New(t)
^
desohash/sha3m/xor.go:64:7: `xorImplementationUnaligned` is unused (deadcode)
const xorImplementationUnaligned = "unaligned"
^
desohash/sha3m/xor_generic.go:12:6: `xorInGeneric` is unused (deadcode)
func xorInGeneric(d *state, buf []byte) {
^
desohash/sha3m/xor_generic.go:23:6: `copyOutGeneric` is unused (deadcode)
func copyOutGeneric(d *state, b []byte) {
^
desohash/sha3m/sha3.go:191:10: Error return value of `dup.Read` is not checked (errcheck)
dup.Read(hash)
^
cmd/node.go:45:10: Error return value of `flag.Set` is not checked (errcheck)
flag.Set("log_dir", node.Config.LogDirectory)
^
cmd/node.go:46:10: Error return value of `flag.Set` is not checked (errcheck)
flag.Set("v", fmt.Sprintf("%d", node.Config.GlogV))
^
cmd/run.go:181:18: Error return value of `viper.BindPFlag` is not checked (errcheck)
viper.BindPFlag(flag.Name, flag)
^
cmd/run.go:34:2: sigchanyzer: misuse of unbuffered os.Signal channel as argument to signal.Notify (govet)
signal.Notify(shutdownListener, syscall.SIGINT, syscall.SIGTERM)
^
scripts/mempool/mempool_dumper.go:34:2: `flagDiffNode` is unused (deadcode)
flagDiffNode = flag.String(
^
scripts/mempool/mempool_dumper.go:79:24: Error return value of `peer.WriteDeSoMessage` is not checked (errcheck)
peer.WriteDeSoMessage(&lib.MsgDeSoGetHeaders{
^
scripts/mempool/mempool_dumper.go:122:24: Error return value of `peer.WriteDeSoMessage` is not checked (errcheck)
peer.WriteDeSoMessage(&lib.MsgDeSoMempool{})
^
scripts/mempool/mempool_dumper.go:154:26: Error return value of `peer.WriteDeSoMessage` is not checked (errcheck)
peer.WriteDeSoMessage(getTxns)
^
scripts/mempool/mempool_dumper.go:165:16: SA1004: sleeping for 1 nanoseconds is probably a bug; be explicit if it isn't (staticcheck)
time.Sleep(1)
^
desohash/algorithm_test.go:106:6: S1004: should use !bytes.Equal(vec.expected.V1[:], hash[:]) instead (gosimple)
if bytes.Compare(vec.expected.V1[:], hash[:]) != 0 {
^
desohash/algorithm_test.go:117:6: S1004: should use !bytes.Equal(vec.expected.V0[:], hash[:]) instead (gosimple)
if bytes.Compare(vec.expected.V0[:], hash[:]) != 0 {
^
The text was updated successfully, but these errors were encountered:
Is it worth offering a PR with the correction of alleged errors after the linter note
golangci-lint
?An example of what the linter gives out, somewhere false positives, and somewhere it is worth adding logging
The text was updated successfully, but these errors were encountered: