Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lint: Fix errors showing up w/ golanci-lint #1358

Merged
merged 1 commit into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion conduit/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ import "fmt"
type CriticalError struct{}

func (e *CriticalError) Error() string {
return fmt.Sprintf("critical error occured")
return fmt.Sprintf("critical error occurred")
}
12 changes: 6 additions & 6 deletions conduit/pipeline/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ import (
"github.com/prometheus/client_golang/prometheus/promhttp"
log "github.com/sirupsen/logrus"
"github.com/spf13/viper"

"github.com/algorand/go-algorand/crypto"
"github.com/algorand/go-algorand/data/basics"
"gopkg.in/yaml.v3"

"github.com/algorand/indexer/conduit"
Expand All @@ -30,6 +27,9 @@ import (
"github.com/algorand/indexer/data"
"github.com/algorand/indexer/util"
"github.com/algorand/indexer/util/metrics"

"github.com/algorand/go-algorand/crypto"
"github.com/algorand/go-algorand/data/basics"
)

func init() {
Expand Down Expand Up @@ -319,7 +319,7 @@ func (p *pipelineImpl) Init() error {
for _, cb := range p.metricsCallback {
collectors := cb()
for _, c := range collectors {
prometheus.Register(c)
_ = prometheus.Register(c)
}
}
go p.startMetricsServer()
Expand Down Expand Up @@ -429,7 +429,7 @@ func (p *pipelineImpl) Start() {

// Increment Round, update metadata
p.pipelineMetadata.NextRound++
p.encodeMetadataToFile()
_ = p.encodeMetadataToFile()

// Callback Processors
for _, cb := range p.completeCallback {
Expand Down Expand Up @@ -518,7 +518,7 @@ func (p *pipelineImpl) initializeOrLoadBlockMetadata() (state, error) {
// start a http server serving /metrics
func (p *pipelineImpl) startMetricsServer() {
http.Handle("/metrics", promhttp.Handler())
http.ListenAndServe(p.cfg.Metrics.Addr, nil)
_ = http.ListenAndServe(p.cfg.Metrics.Addr, nil)
p.logger.Infof("conduit metrics serving on %s", p.cfg.Metrics.Addr)
}

Expand Down
3 changes: 2 additions & 1 deletion conduit/plugins/exporters/postgresql/util/prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import (
"sync"
"time"

"github.com/algorand/indexer/idb"
"github.com/sirupsen/logrus"

"github.com/algorand/indexer/idb"
)

// Interval determines how often to delete data
Expand Down
10 changes: 5 additions & 5 deletions conduit/plugins/importers/algod/algod_importer.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import (
"github.com/sirupsen/logrus"
"gopkg.in/yaml.v3"

"github.com/algorand/go-algorand-sdk/client/v2/algod"
"github.com/algorand/go-algorand/data/bookkeeping"
"github.com/algorand/go-algorand/protocol"
"github.com/algorand/go-algorand/rpcs"

"github.com/algorand/indexer/conduit"
"github.com/algorand/indexer/conduit/plugins"
"github.com/algorand/indexer/conduit/plugins/importers"
"github.com/algorand/indexer/data"

"github.com/algorand/go-algorand-sdk/client/v2/algod"
"github.com/algorand/go-algorand/data/bookkeeping"
"github.com/algorand/go-algorand/protocol"
"github.com/algorand/go-algorand/rpcs"
)

const importerName = "algod"
Expand Down
4 changes: 2 additions & 2 deletions conduit/plugins/importers/filereader/filereader.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import (
"github.com/sirupsen/logrus"
"gopkg.in/yaml.v3"

"github.com/algorand/go-algorand/data/bookkeeping"

"github.com/algorand/indexer/conduit"
"github.com/algorand/indexer/conduit/plugins"
"github.com/algorand/indexer/conduit/plugins/exporters/filewriter"
"github.com/algorand/indexer/conduit/plugins/importers"
"github.com/algorand/indexer/data"
"github.com/algorand/indexer/util"

"github.com/algorand/go-algorand/data/bookkeeping"
)

const importerName = "file_reader"
Expand Down
4 changes: 2 additions & 2 deletions conduit/plugins/importers/importer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (

"github.com/sirupsen/logrus"

"github.com/algorand/go-algorand/data/bookkeeping"

"github.com/algorand/indexer/conduit"
"github.com/algorand/indexer/conduit/plugins"
"github.com/algorand/indexer/data"

"github.com/algorand/go-algorand/data/bookkeeping"
)

// Importer defines the interface for importer plugins
Expand Down
16 changes: 8 additions & 8 deletions conduit/plugins/processors/blockprocessor/block_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ import (
log "github.com/sirupsen/logrus"
"gopkg.in/yaml.v3"

"github.com/algorand/indexer/accounting"
"github.com/algorand/indexer/conduit"
"github.com/algorand/indexer/conduit/plugins"
"github.com/algorand/indexer/conduit/plugins/processors"
indexerledger "github.com/algorand/indexer/conduit/plugins/processors/eval"
"github.com/algorand/indexer/data"
"github.com/algorand/indexer/util"

"github.com/algorand/go-algorand/agreement"
"github.com/algorand/go-algorand/config"
"github.com/algorand/go-algorand/data/basics"
Expand All @@ -18,14 +26,6 @@ import (
"github.com/algorand/go-algorand/ledger"
"github.com/algorand/go-algorand/ledger/ledgercore"
"github.com/algorand/go-algorand/rpcs"

"github.com/algorand/indexer/accounting"
"github.com/algorand/indexer/conduit"
"github.com/algorand/indexer/conduit/plugins"
"github.com/algorand/indexer/conduit/plugins/processors"
indexerledger "github.com/algorand/indexer/conduit/plugins/processors/eval"
"github.com/algorand/indexer/data"
"github.com/algorand/indexer/util"
)

const implementationName = "block_evaluator"
Expand Down
6 changes: 3 additions & 3 deletions conduit/plugins/processors/blockprocessor/initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (

log "github.com/sirupsen/logrus"

"github.com/algorand/indexer/conduit/plugins/processors/blockprocessor/internal"
"github.com/algorand/indexer/fetcher"

"github.com/algorand/go-algorand/data/bookkeeping"
"github.com/algorand/go-algorand/ledger/ledgercore"
"github.com/algorand/go-algorand/rpcs"

"github.com/algorand/indexer/conduit/plugins/processors/blockprocessor/internal"
"github.com/algorand/indexer/fetcher"
)

// InitializeLedger will initialize a ledger to the directory given by the
Expand Down
3 changes: 2 additions & 1 deletion conduit/plugins/processors/filterprocessor/fields/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package fields
import (
"fmt"

"github.com/algorand/go-algorand/data/transactions"
"github.com/algorand/indexer/data"

"github.com/algorand/go-algorand/data/transactions"
)

// Operation an operation like "any" or "all" for boolean logic
Expand Down
6 changes: 3 additions & 3 deletions conduit/plugins/processors/filterprocessor/fields/searcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"fmt"
"reflect"

"github.com/algorand/go-algorand/data/transactions"

"github.com/algorand/indexer/conduit/plugins/processors/filterprocessor/expression"

"github.com/algorand/go-algorand/data/transactions"
)

// Searcher searches the struct with an expression and method to call
Expand Down Expand Up @@ -55,7 +55,7 @@ func checkTagExistsAndHasCorrectFunction(expressionType expression.FilterType, t
// actually reach inside the if conditional unless we intentionally panic.
// However, having this function gives additional safety to a critical function
if r := recover(); r != nil {
outError = fmt.Errorf("error occured regarding tag %s - %v", tag, r)
outError = fmt.Errorf("error occurred regarding tag %s - %v", tag, r)
}
}()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import (
log "github.com/sirupsen/logrus"
"gopkg.in/yaml.v3"

"github.com/algorand/go-algorand/data/transactions"

"github.com/algorand/indexer/conduit"
"github.com/algorand/indexer/conduit/plugins"
"github.com/algorand/indexer/conduit/plugins/processors"
"github.com/algorand/indexer/conduit/plugins/processors/filterprocessor/expression"
"github.com/algorand/indexer/conduit/plugins/processors/filterprocessor/fields"
"github.com/algorand/indexer/data"

"github.com/algorand/go-algorand/data/transactions"
)

const implementationName = "filter_processor"
Expand Down
8 changes: 4 additions & 4 deletions idb/dummy/dummy.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package dummy
import (
"context"

"github.com/algorand/go-algorand/crypto"
log "github.com/sirupsen/logrus"

"github.com/algorand/indexer/idb"

"github.com/algorand/go-algorand/crypto"
"github.com/algorand/go-algorand/data/bookkeeping"
"github.com/algorand/go-algorand/data/transactions"
"github.com/algorand/go-algorand/ledger/ledgercore"
log "github.com/sirupsen/logrus"

"github.com/algorand/indexer/idb"
)

type dummyIndexerDb struct {
Expand Down
2 changes: 1 addition & 1 deletion util/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "github.com/prometheus/client_golang/prometheus"
// metrics handler.
func RegisterPrometheusMetrics() {
for _, c := range collectors {
prometheus.Register(c)
_ = prometheus.Register(c)
}
}

Expand Down
17 changes: 9 additions & 8 deletions util/test/mock_algod.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package test

import (
"net/http"
"net/http/httptest"
"path"
"strconv"
"strings"

"github.com/algorand/go-algorand-sdk/client/v2/algod"
"github.com/algorand/go-algorand-sdk/client/v2/common/models"
"github.com/algorand/go-algorand/data/basics"
"github.com/algorand/go-algorand/data/bookkeeping"
"github.com/algorand/go-algorand/protocol"
"github.com/algorand/go-algorand/rpcs"
"net/http"
"net/http/httptest"
"path"
"strconv"
"strings"
)

// AlgodHandler is used to handle http requests to a mock algod server
Expand Down Expand Up @@ -52,7 +53,7 @@ func BlockResponder(reqPath string, w http.ResponseWriter) bool {
blk := rpcs.EncodedBlockCert{Block: bookkeeping.Block{BlockHeader: bookkeeping.BlockHeader{Round: basics.Round(rnd)}}}
blockbytes := protocol.Encode(&blk)
w.WriteHeader(http.StatusOK)
w.Write(blockbytes)
_, _ = w.Write(blockbytes)
return true
}
return false
Expand All @@ -64,7 +65,7 @@ func GenesisResponder(reqPath string, w http.ResponseWriter) bool {
w.WriteHeader(http.StatusOK)
genesis := &bookkeeping.Genesis{}
blockbytes := protocol.EncodeJSON(*genesis)
w.Write(blockbytes)
_, _ = w.Write(blockbytes)
return true
}
return false
Expand All @@ -75,7 +76,7 @@ func BlockAfterResponder(reqPath string, w http.ResponseWriter) bool {
if strings.Contains(reqPath, "/wait-for-block-after") {
w.WriteHeader(http.StatusOK)
nStatus := models.NodeStatus{}
w.Write(protocol.EncodeJSON(nStatus))
_, _ = w.Write(protocol.EncodeJSON(nStatus))
return true
}
return false
Expand Down
7 changes: 4 additions & 3 deletions util/test/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import (
"os"
"runtime"

"github.com/algorand/go-algorand/data/bookkeeping"
log "github.com/sirupsen/logrus"

"github.com/algorand/go-algorand/data/basics"
"github.com/algorand/go-algorand/ledger"
"github.com/algorand/indexer/idb"
"github.com/algorand/indexer/util"

"github.com/algorand/go-algorand/data/basics"
"github.com/algorand/go-algorand/data/bookkeeping"
"github.com/algorand/go-algorand/ledger"
)

var quiet = false
Expand Down
3 changes: 2 additions & 1 deletion util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import (
"unicode"
"unicode/utf8"

"github.com/algorand/go-algorand-sdk/encoding/json"
"github.com/algorand/go-codec/codec"

"github.com/algorand/go-algorand-sdk/encoding/json"
)

// EncodeToFile is used to encode an object to a file. If the file ends in .gz it will be gzipped.
Expand Down