Skip to content

Commit

Permalink
bump golangci-lint to 1.51.2; remove unused code (#8700)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmank88 authored Mar 14, 2023
1 parent 1bad41e commit 85c78f1
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 119 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
##
uses: smartcontractkit/golangci-lint-action@54ab6c5f11d66a92d14c3f7cc41ea13f676644bd # feature/multiple-output-formats-backup
with:
version: v1.51.1
version: v1.51.2
only-new-issues: ${{ github.event.schedule == '' }} # show only new issues, unless it's a scheduled run
allow-extra-out-format-args: true
args: --out-format checkstyle:golangci-lint-report.xml
Expand Down
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ nodejs 16.13.2
postgres 13.3
helm 3.10.3
zig 0.10.1
golangci-lint 1.51.1
golangci-lint 1.51.2
shellspec 0.28.1
codecgen 1.2.10
2 changes: 1 addition & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ config-docs: ## Generate core node configuration documentation

.PHONY: golangci-lint
golangci-lint: ## Run golangci-lint for all issues.
docker run --rm -v $(shell pwd):/app -w /app golangci/golangci-lint:latest golangci-lint run --max-issues-per-linter 0 --max-same-issues 0 > golangci-lint-output.txt
docker run --rm -v $(shell pwd):/app -w /app golangci/golangci-lint:v1.51.2 golangci-lint run --max-issues-per-linter 0 --max-same-issues 0 > golangci-lint-output.txt

.PHONY: snapshot
snapshot:
Expand Down
2 changes: 0 additions & 2 deletions core/chains/evm/client/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,6 @@ func (s *SendError) is(errorType int) bool {
return false
}

var hexDataRegex = regexp.MustCompile(`0x\w+$`)

// IsReplacementUnderpriced indicates that a transaction already exists in the mempool with this nonce but a different gas price or payload
func (s *SendError) IsReplacementUnderpriced() bool {
return s.is(ReplacementTransactionUnderpriced)
Expand Down
109 changes: 0 additions & 109 deletions core/chains/orm.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package chains

import (
"database/sql"
"fmt"
"strings"
"time"
Expand Down Expand Up @@ -91,13 +90,6 @@ func (o *chainsORM[I, C]) GetChainsByIDs(ids []I) (chains []DBChain[I, C], err e
return chains, nil
}

func (o *chainsORM[I, C]) CreateChain(id I, config C, qopts ...pg.QOpt) (chain DBChain[I, C], err error) {
q := o.q.WithOpts(qopts...)
sql := fmt.Sprintf(`INSERT INTO %s_chains (id, cfg, created_at, updated_at) VALUES ($1, $2, now(), now()) RETURNING *`, o.prefix)
err = q.Get(&chain, sql, id, config)
return
}

func (o *chainsORM[I, C]) EnsureChains(ids []I, qopts ...pg.QOpt) (err error) {
named := make([]struct{ ID I }, len(ids))
for i, id := range ids {
Expand All @@ -113,64 +105,6 @@ func (o *chainsORM[I, C]) EnsureChains(ids []I, qopts ...pg.QOpt) (err error) {
return nil
}

func (o *chainsORM[I, C]) UpdateChain(id I, enabled bool, config C, qopts ...pg.QOpt) (chain DBChain[I, C], err error) {
q := o.q.WithOpts(qopts...)
sql := fmt.Sprintf(`UPDATE %s_chains SET enabled = $1, cfg = $2, updated_at = now() WHERE id = $3 RETURNING *`, o.prefix)
err = q.Get(&chain, sql, enabled, config, id)
return
}

// StoreString saves a string value into the config for the given chain and key
func (o *chainsORM[I, C]) StoreString(chainID I, name, val string) error {
s := fmt.Sprintf(`UPDATE %s_chains SET cfg = cfg || jsonb_build_object($1::text, $2::text) WHERE id = $3`, o.prefix)
res, err := o.q.Exec(s, name, val, chainID)
if err != nil {
return errors.Wrapf(err, "failed to store chain config for chain ID %v", chainID)
}
rowsAffected, err := res.RowsAffected()
if err != nil {
return err
}
if rowsAffected == 0 {
return errors.Wrapf(sql.ErrNoRows, "no chain found with ID %v", chainID)
}
return nil
}

// Clear deletes a config value for the given chain and key
func (o *chainsORM[I, C]) Clear(chainID I, name string) error {
s := fmt.Sprintf(`UPDATE %s_chains SET cfg = cfg - $1 WHERE id = $2`, o.prefix)
res, err := o.q.Exec(s, name, chainID)
if err != nil {
return errors.Wrapf(err, "failed to clear chain config for chain ID %v", chainID)
}
rowsAffected, err := res.RowsAffected()
if err != nil {
return err
}
if rowsAffected == 0 {
return errors.Wrapf(sql.ErrNoRows, "no chain found with ID %v", chainID)
}
return nil
}

func (o *chainsORM[I, C]) DeleteChain(id I, qopts ...pg.QOpt) error {
q := o.q.WithOpts(qopts...)
query := fmt.Sprintf(`DELETE FROM %s_chains WHERE id = $1`, o.prefix)
result, err := q.Exec(query, id)
if err != nil {
return err
}
rowsAffected, err := result.RowsAffected()
if err != nil {
return err
}
if rowsAffected == 0 {
return sql.ErrNoRows
}
return nil
}

func (o *chainsORM[I, C]) Chains(offset, limit int, qopts ...pg.QOpt) (chains []DBChain[I, C], count int, err error) {
err = o.q.WithOpts(qopts...).Transaction(func(q pg.Queryer) error {
if err = q.Get(&count, fmt.Sprintf("SELECT COUNT(*) FROM %s_chains", o.prefix)); err != nil {
Expand Down Expand Up @@ -209,49 +143,6 @@ func newNodesORM[I ID, N Node](q pg.Q, prefix string, nodeCols ...string) *nodes
}
}

func (o *nodesORM[I, N]) ensureNodes(nodes []N, qopts ...pg.QOpt) (err error) {
q := o.q.WithOpts(qopts...)
_, err = q.NamedExec(o.ensureNodeQ, nodes)
err = errors.Wrap(err, "failed to insert nodes")
return
}

func (o *nodesORM[I, N]) CreateNode(data N, qopts ...pg.QOpt) (node N, err error) {
q := o.q.WithOpts(qopts...)
stmt, err := q.PrepareNamed(o.createNodeQ)
if err != nil {
return node, err
}
err = stmt.Get(&node, data)
return node, err
}

func (o *nodesORM[I, N]) DeleteNode(id int32, qopts ...pg.QOpt) error {
q := o.q.WithOpts(qopts...)
query := fmt.Sprintf(`DELETE FROM %s_nodes WHERE id = $1`, o.prefix)
result, err := q.Exec(query, id)
if err != nil {
return err
}
rowsAffected, err := result.RowsAffected()
if err != nil {
return err
}
if rowsAffected == 0 {
return sql.ErrNoRows
}
return nil
}

func (o *nodesORM[I, N]) truncateNodes(qopts ...pg.QOpt) error {
q := o.q.WithOpts(qopts...)
_, err := q.Exec(fmt.Sprintf(`TRUNCATE %s_nodes;`, o.prefix))
if err != nil {
return errors.Wrapf(err, "failed to truncate %s_nodes table", o.prefix)
}
return nil
}

func (o *nodesORM[I, N]) NodeNamed(name string, qopts ...pg.QOpt) (node N, err error) {
q := o.q.WithOpts(qopts...)
err = q.Get(&node, fmt.Sprintf("SELECT * FROM %s_nodes WHERE name = $1;", o.prefix), name)
Expand Down
7 changes: 2 additions & 5 deletions core/services/relay/evm/mercury/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package mercury

import (
"encoding/base64"
"fmt"
"math/big"
"strings"

"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/smartcontractkit/libocr/offchainreporting2/chains/evmutil"
Expand Down Expand Up @@ -62,9 +60,8 @@ var (
},
ExtraHash: [32]uint8{27, 144, 106, 73, 166, 228, 123, 166, 179, 138, 225, 191, 69, 101, 63, 86, 182, 86, 253, 58, 163, 53, 239, 127, 174, 105, 107, 102, 63, 27, 132, 114},
}
samplePayload = buildSamplePayload()
samplePayloadHex = hexutil.Encode(samplePayload)
sampleMercuryReport = fmt.Sprintf(`{"Payload":"%s","FromAccount":"%s"}`, samplePayloadHex, strings.ToLower(sampleFromAccount.Hex()))
samplePayload = buildSamplePayload()
samplePayloadHex = hexutil.Encode(samplePayload)
)

func mustDecodeBase64(s string) (b []byte) {
Expand Down

0 comments on commit 85c78f1

Please sign in to comment.