Skip to content

Commit

Permalink
golangci-lint: --fix nolintlint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jmank88 committed Nov 12, 2024
1 parent 66e3488 commit 6a0bf91
Show file tree
Hide file tree
Showing 18 changed files with 27 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func TestCCIPReader_CommitReportsGTETimestamp(t *testing.T) {
tokenA := common.HexToAddress("123")
const numReports = 5

for i := 0; i < numReports; i++ {
for i := uint8(0); i < numReports; i++ {
_, err := s.contract.EmitCommitReportAccepted(s.auth, ccip_reader_tester.OffRampCommitReport{
PriceUpdates: ccip_reader_tester.InternalPriceUpdates{
TokenPriceUpdates: []ccip_reader_tester.InternalTokenPriceUpdate{
Expand All @@ -100,7 +100,7 @@ func TestCCIPReader_CommitReportsGTETimestamp(t *testing.T) {
SourceChainSelector: uint64(chainS1),
MinSeqNr: 10,
MaxSeqNr: 20,
MerkleRoot: [32]byte{uint8(i) + 1}, //nolint:gosec // this won't overflow
MerkleRoot: [32]byte{i + 1},
OnRampAddress: common.LeftPadBytes(onRampAddress.Bytes(), 32),
},
},
Expand Down
1 change: 1 addition & 0 deletions core/capabilities/ccip/ccipevm/encodingUtilsAbi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"DoNotDeploy","type":"error"},{"inputs":[{"internalType":"bytes32","name":"rmnReportVersion","type":"bytes32"},{"components":[{"internalType":"uint256","name":"destChainId","type":"uint256"},{"internalType":"uint64","name":"destChainSelector","type":"uint64"},{"internalType":"address","name":"rmnRemoteContractAddress","type":"address"},{"internalType":"address","name":"offrampAddress","type":"address"},{"internalType":"bytes32","name":"rmnHomeContractConfigDigest","type":"bytes32"},{"components":[{"internalType":"uint64","name":"sourceChainSelector","type":"uint64"},{"internalType":"bytes","name":"onRampAddress","type":"bytes"},{"internalType":"uint64","name":"minSeqNr","type":"uint64"},{"internalType":"uint64","name":"maxSeqNr","type":"uint64"},{"internalType":"bytes32","name":"merkleRoot","type":"bytes32"}],"internalType":"struct Internal.MerkleRoot[]","name":"destLaneUpdates","type":"tuple[]"}],"internalType":"struct RMNRemote.Report","name":"rmnReport","type":"tuple"}],"name":"_rmnReport","outputs":[],"stateMutability":"nonpayable","type":"function"}]
7 changes: 5 additions & 2 deletions core/capabilities/ccip/ccipevm/rmncrypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ccipevm
import (
"bytes"
"context"
_ "embed"
"errors"
"fmt"
"math/big"
Expand All @@ -18,8 +19,10 @@ import (

// encodingUtilsAbi is the ABI for the EncodingUtils contract.
// Should be imported when gethwrappers are moved from ccip repo to core.
// nolint:lll
const encodingUtilsAbiRaw = `[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"DoNotDeploy","type":"error"},{"inputs":[{"internalType":"bytes32","name":"rmnReportVersion","type":"bytes32"},{"components":[{"internalType":"uint256","name":"destChainId","type":"uint256"},{"internalType":"uint64","name":"destChainSelector","type":"uint64"},{"internalType":"address","name":"rmnRemoteContractAddress","type":"address"},{"internalType":"address","name":"offrampAddress","type":"address"},{"internalType":"bytes32","name":"rmnHomeContractConfigDigest","type":"bytes32"},{"components":[{"internalType":"uint64","name":"sourceChainSelector","type":"uint64"},{"internalType":"bytes","name":"onRampAddress","type":"bytes"},{"internalType":"uint64","name":"minSeqNr","type":"uint64"},{"internalType":"uint64","name":"maxSeqNr","type":"uint64"},{"internalType":"bytes32","name":"merkleRoot","type":"bytes32"}],"internalType":"struct Internal.MerkleRoot[]","name":"destLaneUpdates","type":"tuple[]"}],"internalType":"struct RMNRemote.Report","name":"rmnReport","type":"tuple"}],"name":"_rmnReport","outputs":[],"stateMutability":"nonpayable","type":"function"}]`
//
//go:embed encodingUtilsAbi.json
var encodingUtilsAbiRaw string

const addressEncodeAbiRaw = `[{"name":"method","type":"function","inputs":[{"name": "", "type": "address"}]}]`

var (
Expand Down
1 change: 0 additions & 1 deletion core/capabilities/integration_tests/framework/don.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ func (d *DON) Initialise() {
if len(d.externalCapabilities) > 0 {
id := d.capabilitiesRegistry.setupDON(d.config, d.externalCapabilities)

//nolint:gosec // disable G115
d.config.DON.ID = uint32(id)
}
}
Expand Down
1 change: 0 additions & 1 deletion core/capabilities/integration_tests/framework/ethereum.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ type EthBlockchain struct {
func NewEthBlockchain(t *testing.T, initialEth int, blockTimeProcessingTime time.Duration) *EthBlockchain {
transactOpts := testutils.MustNewSimTransactor(t) // config contract deployer and owner
genesisData := core.GenesisAlloc{transactOpts.From: {Balance: assets.Ether(initialEth).ToInt()}}
//nolint:gosec // disable G115
backend := cltest.NewSimulatedBackend(t, genesisData, uint32(ethconfig.Defaults.Miner.GasCeil))
gethlog.SetDefault(gethlog.NewLogger(gethlog.NewTerminalHandlerWithLevel(os.Stderr, gethlog.LevelWarn, true)))
backend.Commit()
Expand Down
2 changes: 1 addition & 1 deletion core/capabilities/integration_tests/keystone/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func newReport(t *testing.T, feedID [32]byte, price *big.Int, timestamp int64) [
v3Codec := reportcodec.NewReportCodec(feedID, logger.TestLogger(t))
raw, err := v3Codec.BuildReport(ctx, v3.ReportFields{
BenchmarkPrice: price,
//nolint:gosec // disable G115

Timestamp: uint32(timestamp),
Bid: big.NewInt(0),
Ask: big.NewInt(0),
Expand Down
9 changes: 6 additions & 3 deletions core/chains/evm/client/simulated_backend_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"errors"
"fmt"
"math"
"math/big"
"strings"
"testing"
Expand All @@ -18,10 +19,9 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/rpc"

"github.com/smartcontractkit/chainlink-common/pkg/utils/hex"

"github.com/smartcontractkit/chainlink-common/pkg/assets"
"github.com/smartcontractkit/chainlink-common/pkg/logger"
"github.com/smartcontractkit/chainlink-common/pkg/utils/hex"

commonclient "github.com/smartcontractkit/chainlink/v2/common/client"
evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types"
Expand Down Expand Up @@ -319,9 +319,12 @@ func (c *SimulatedBackendClient) SubscribeToHeads(
case h := <-ch:
var head *evmtypes.Head
if h != nil {
if h.Time > math.MaxInt64 {
c.t.Fatalf("time overflows int64: %d", h.Time)
}
head = &evmtypes.Head{
Difficulty: h.Difficulty,
Timestamp: time.Unix(int64(h.Time), 0), //nolint:gosec
Timestamp: time.Unix(int64(h.Time), 0), //nolint:gosec // G115 false positive
Number: h.Number.Int64(),
Hash: h.Hash(),
ParentHash: h.ParentHash,
Expand Down
2 changes: 1 addition & 1 deletion core/chains/evm/txmgr/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (c *evmTxmClient) SequenceAt(ctx context.Context, addr common.Address, bloc
if nonce > math.MaxInt64 {
return 0, fmt.Errorf("overflow for nonce: %d", nonce)
}
//nolint:gosec // disable G115

return evmtypes.Nonce(nonce), err
}

Expand Down
1 change: 0 additions & 1 deletion core/cmd/shell_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,6 @@ func (s *Shell) RebroadcastTransactions(c *cli.Context) (err error) {
nonces[i] = evmtypes.Nonce(beginningNonce + i)
}
if gasPriceWei <= math.MaxInt64 {
//nolint:gosec // disable G115
return s.errorOut(ec.ForceRebroadcast(ctx, nonces, gas.EvmFee{GasPrice: assets.NewWeiI(int64(gasPriceWei))}, address, uint64(overrideGasLimit)))
}
return s.errorOut(fmt.Errorf("integer overflow conversion error. GasPrice: %v", gasPriceWei))
Expand Down
4 changes: 2 additions & 2 deletions core/services/llo/mercurytransmitter/orm.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (o *orm) Insert(ctx context.Context, transmissions []*Transmission) error {
DonID: o.donID,
ServerURL: t.ServerURL,
ConfigDigest: t.ConfigDigest,
SeqNr: int64(t.SeqNr), //nolint
SeqNr: int64(t.SeqNr), //nolint:gosec // G115 false positive
Report: t.Report.Report,
LifecycleStage: string(t.Report.Info.LifeCycleStage),
ReportFormat: uint32(t.Report.Info.ReportFormat),
Expand Down Expand Up @@ -162,7 +162,7 @@ func (o *orm) Get(ctx context.Context, serverURL string) ([]*Transmission, error
}
transmission.Sigs = append(transmission.Sigs, ocrtypes.AttributedOnchainSignature{
Signature: sig,
Signer: commontypes.OracleID(signers[i]), //nolint
Signer: commontypes.OracleID(signers[i]), //nolint:gosec // G115 false positive
})
}

Expand Down
2 changes: 1 addition & 1 deletion core/services/ocrcommon/adapters.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func MarshalMultichainPublicKey(ost map[string]ocrtypes.OnchainPublicKey) (ocrty
if length < 0 || length > math.MaxUint16 {
return nil, fmt.Errorf("pubKey doesn't fit into uint16")
}
if err = binary.Write(buf, binary.LittleEndian, uint16(length)); err != nil { //nolint:gosec
if err = binary.Write(buf, binary.LittleEndian, uint16(length)); err != nil { //nolint:gosec // G115 false positive

Check failure on line 115 in core/services/ocrcommon/adapters.go

View workflow job for this annotation

GitHub Actions / lint

directive `//nolint:gosec // G115 false positive` is unused for linter "gosec" (nolintlint)
return nil, err
}
_, _ = buf.Write(pubKey)
Expand Down
8 changes: 5 additions & 3 deletions core/services/relay/evm/capabilities/testutils/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package testutils
import (
"context"
"encoding/json"
"math"
"math/big"
"testing"
"time"
Expand Down Expand Up @@ -56,9 +57,10 @@ func NewEVMBackendTH(t *testing.T) *EVMBackendTH {
contractsOwner.From: {Balance: assets.Ether(100000).ToInt()},
}
chainID := testutils.SimulatedChainID
gasLimit := uint32(ethconfig.Defaults.Miner.GasCeil) //nolint:gosec
backend := cltest.NewSimulatedBackend(t, genesisData, gasLimit)
blockTime := time.UnixMilli(int64(backend.Blockchain().CurrentHeader().Time)) //nolint:gosec
require.LessOrEqual(t, ethconfig.Defaults.Miner.GasCeil, math.MaxUint32)
backend := cltest.NewSimulatedBackend(t, genesisData, uint32(ethconfig.Defaults.Miner.GasCeil)) //nolint:gosec // G115 false positive
require.LessOrEqual(t, backend.Blockchain().CurrentHeader().Time, math.MaxInt64)
blockTime := time.UnixMilli(int64(backend.Blockchain().CurrentHeader().Time)) //nolint:gosec // G115 false positive
err = backend.AdjustTime(time.Since(blockTime) - 24*time.Hour)
require.NoError(t, err)
backend.Commit()
Expand Down
2 changes: 1 addition & 1 deletion core/services/relay/evm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func init() {
}
}

var _ commontypes.Relayer = &Relayer{} //nolint:staticcheck
var _ commontypes.Relayer = &Relayer{}

// The current PluginProvider interface does not support an error return. This was fine up until CCIP.
// CCIP is the first product to introduce the idea of incomplete implementations of a provider based on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func (r *ReportCodec) ValidFromBlockNumFromReport(report ocrtypes.Report) (int64
if n > math.MaxInt64 {
return 0, fmt.Errorf("ValidFromBlockNum=%d overflows max int64", n)
}
return int64(n), nil //nolint:gosec // G115
return int64(n), nil //nolint:gosec // G115 false positive

Check failure on line 160 in core/services/relay/evm/mercury/v1/reportcodec/report_codec_test.go

View workflow job for this annotation

GitHub Actions / lint

directive `//nolint:gosec // G115 false positive` is unused for linter "gosec" (nolintlint)
}

func Test_ReportCodec_ValidFromBlockNumFromReport(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion core/services/relay/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type ServerAdapter struct {
}

// NewServerAdapter returns a new ServerAdapter.
func NewServerAdapter(r types.Relayer) *ServerAdapter { //nolint:staticcheck
func NewServerAdapter(r types.Relayer) *ServerAdapter {
return &ServerAdapter{Relayer: r}
}

Expand Down
2 changes: 0 additions & 2 deletions core/store/migrate/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ func ensureMigrated(ctx context.Context, db *sql.DB, p *goose.Provider, provider
}

// insert records for existing migrations
//nolint

sql := fmt.Sprintf(`INSERT INTO %s (version_id, is_applied) VALUES ($1, true);`, providerTableName)
return sqlutil.TransactDataSource(ctx, sqlxDB, nil, func(tx sqlutil.DataSource) error {
for _, name := range names {
Expand Down
1 change: 0 additions & 1 deletion core/store/migrate/migrations/0036_external_job_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const (
`
)

// nolint
func Up36(ctx context.Context, tx *sql.Tx) error {
// Add the external ID column and remove type specific ones.
if _, err := tx.ExecContext(ctx, up36_1); err != nil {
Expand Down
2 changes: 0 additions & 2 deletions core/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -595,8 +595,6 @@ func (eb *ErrorBuffer) SetCap(cap int) {
}

// UnwrapError returns a list of underlying errors if passed error implements joinedError or return the err in a single-element list otherwise.
//
//nolint:errorlint // error type checks will fail on wrapped errors. Disabled since we are not doing checks on error types.
func UnwrapError(err error) []error {
joined, ok := err.(interface{ Unwrap() []error })
if !ok {
Expand Down

0 comments on commit 6a0bf91

Please sign in to comment.