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

CI: Fixing linter deprecations #4353

Merged
merged 3 commits into from
Sep 21, 2021
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
7 changes: 3 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,17 @@ linters:
- goconst
- gofmt
- goimports
- golint
- revive
- gosimple
- ineffassign
- megacheck
- staticcheck
- misspell
- structcheck
- unconvert
- unparam
- varcheck
- govet
- unused # new from here.
- interfacer
- unused
- typecheck

issues:
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ publish: dist
# Lint #
########

# To run this efficiently on your workstation, run this from the root dir:
# docker run --rm --tty -i -v $(pwd)/.cache:/go/cache -v $(pwd)/.pkg:/go/pkg -v $(pwd):/src/loki grafana/loki-build-image:0.17.0 lint
lint:
GO111MODULE=on GOGC=10 golangci-lint run -v $(GOLANGCI_ARG)
faillint -paths "sync/atomic=go.uber.org/atomic" ./...
Expand Down
2 changes: 1 addition & 1 deletion clients/cmd/docker-driver/loki.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func New(logCtx logger.Info, logger log.Logger) (logger.Logger, error) {
return nil, err
}
var handler api.EntryHandler = c
var stop func() = func() {}
var stop = func() {}
if len(cfg.pipeline.PipelineStages) != 0 {
pipeline, err := stages.NewPipeline(logger, cfg.pipeline.PipelineStages, &jobName, prometheus.DefaultRegisterer)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion clients/pkg/promtail/targets/file/filetarget.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (cfg *Config) RegisterFlags(flags *flag.FlagSet) {
}

// FileTarget describes a particular set of logs.
// nolint:golint
// nolint:revive
type FileTarget struct {
metrics *Metrics
logger log.Logger
Expand Down
2 changes: 1 addition & 1 deletion clients/pkg/promtail/targets/file/filetargetmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const (
)

// FileTargetManager manages a set of targets.
// nolint:golint
// nolint:revive
type FileTargetManager struct {
log log.Logger
quit context.CancelFunc
Expand Down
2 changes: 1 addition & 1 deletion clients/pkg/promtail/targets/gcplog/formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func init() {
// LogEntry that will be written to the pubsub topic.
// According to the following spec.
// https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry
// nolint: golint
// nolint:revive
type GCPLogEntry struct {
LogName string `json:"logName"`
Resource struct {
Expand Down
6 changes: 3 additions & 3 deletions clients/pkg/promtail/targets/gcplog/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (

// GcplogTarget represents the target specific to GCP project.
// It collects logs from GCP and push it to Loki.
// nolint:golint
// nolint:revive
type GcplogTarget struct {
metrics *Metrics
logger log.Logger
Expand All @@ -41,7 +41,7 @@ type GcplogTarget struct {
// and push it Loki via given `api.EntryHandler.`
// It starts the `run` loop to consume log entries that can be
// stopped via `target.Stop()`
// nolint:golint,govet
// nolint:revive,govet
func NewGcplogTarget(
metrics *Metrics,
logger log.Logger,
Expand All @@ -66,7 +66,7 @@ func NewGcplogTarget(
return target, nil
}

// nolint: golint
// nolint:revive
func newGcplogTarget(
metrics *Metrics,
logger log.Logger,
Expand Down
2 changes: 1 addition & 1 deletion clients/pkg/promtail/targets/gcplog/targetmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/grafana/loki/clients/pkg/promtail/targets/target"
)

// nolint: golint
// nolint:revive
type GcplogTargetManager struct {
logger log.Logger
targets map[string]*GcplogTarget
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

// JournalTargetManager manages a series of JournalTargets.
// nolint:golint
// nolint:revive
type JournalTargetManager struct{}

// NewJournalTargetManager returns nil as JournalTargets are not supported
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type Shutdownable interface {
Shutdown()
}

// nolint:golint
// nolint:revive
type StdinTargetManager struct {
*readerTarget
app Shutdownable
Expand Down
2 changes: 1 addition & 1 deletion clients/pkg/promtail/targets/syslog/syslogtarget.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var (
)

// SyslogTarget listens to syslog messages.
// nolint:golint
// nolint:revive
type SyslogTarget struct {
metrics *Metrics
logger log.Logger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

// SyslogTargetManager manages a series of SyslogTargets.
// nolint:golint
// nolint:revive
type SyslogTargetManager struct {
logger log.Logger
targets map[string]*SyslogTarget
Expand Down
2 changes: 1 addition & 1 deletion clients/pkg/promtail/targets/target/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
)

// TargetType is the type of target
// nolint:golint
// nolint:revive
type TargetType string

const (
Expand Down
2 changes: 1 addition & 1 deletion pkg/querier/queryrange/split_by_interval.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (h *splitByInterval) Process(
}

// don't spawn unnecessary goroutines
var p int = parallelism
var p = parallelism
if len(input) < parallelism {
p = len(input)
}
Expand Down
8 changes: 2 additions & 6 deletions pkg/storage/chunk/aws/dynamodb_table_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func (d dynamoTableClient) CreateTable(ctx context.Context, desc chunk.TableDesc
}

func (d dynamoTableClient) DeleteTable(ctx context.Context, name string) error {
if err := d.backoffAndRetry(ctx, func(ctx context.Context) error {
return d.backoffAndRetry(ctx, func(ctx context.Context) error {
return instrument.CollectedRequest(ctx, "DynamoDB.DeleteTable", d.metrics.dynamoRequestDuration, instrument.ErrorCode, func(ctx context.Context) error {
input := &dynamodb.DeleteTableInput{TableName: aws.String(name)}
_, err := d.DynamoDB.DeleteTableWithContext(ctx, input)
Expand All @@ -209,11 +209,7 @@ func (d dynamoTableClient) DeleteTable(ctx context.Context, name string) error {

return nil
})
}); err != nil {
return err
}

return nil
})
}

func (d dynamoTableClient) DescribeTable(ctx context.Context, name string) (desc chunk.TableDesc, isActive bool, err error) {
Expand Down
5 changes: 1 addition & 4 deletions pkg/storage/chunk/chunk_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,7 @@ func (cfg *StoreConfig) Validate(logger log.Logger) error {
if err := cfg.ChunkCacheConfig.Validate(); err != nil {
return err
}
if err := cfg.WriteDedupeCacheConfig.Validate(); err != nil {
return err
}
return nil
return cfg.WriteDedupeCacheConfig.Validate()
}

type baseStore struct {
Expand Down
6 changes: 1 addition & 5 deletions pkg/storage/chunk/gcp/gcs_object_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,7 @@ func (s *GCSObjectClient) PutObject(ctx context.Context, objectKey string, objec
_ = writer.Close()
return err
}
if err := writer.Close(); err != nil {
return err
}

return nil
return writer.Close()
}

// List implements chunk.ObjectClient.
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/chunk/purger/purger.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ func (p *Purger) executePlan(userID, requestID string, planNo int, logger log.Lo
return err
}

var partiallyDeletedInterval *model.Interval = nil
var partiallyDeletedInterval *model.Interval
if chunkDetails.PartiallyDeletedInterval != nil {
partiallyDeletedInterval = &model.Interval{
Start: model.Time(chunkDetails.PartiallyDeletedInterval.StartTimestampMs),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,7 @@ func Test_SeriesCleaner(t *testing.T) {
if err := cleaner.Cleanup(entryFromChunk(c2).UserID, c2.Metric); err != nil {
return err
}
if err := cleaner.Cleanup(entryFromChunk(c1).UserID, c1.Metric); err != nil {
return err
}
return nil
return cleaner.Cleanup(entryFromChunk(c1).UserID, c1.Metric)
})
require.NoError(t, err)

Expand Down
7 changes: 2 additions & 5 deletions pkg/storage/stores/shipper/compactor/retention/marker.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ func (r *markerProcessor) processPath(path string, deleteFunc func(ctx context.C
}
}()
}
if err := dbView.View(func(tx *bbolt.Tx) error {
return dbView.View(func(tx *bbolt.Tx) error {
b := tx.Bucket(chunkBucket)
if b == nil {
return nil
Expand All @@ -323,10 +323,7 @@ func (r *markerProcessor) processPath(path string, deleteFunc func(ctx context.C

}
return nil
}); err != nil {
return err
}
return nil
})
}

func processKey(ctx context.Context, key *keyPair, db *bbolt.DB, deleteFunc func(ctx context.Context, chunkId []byte) error) error {
Expand Down