Skip to content

Commit 3b122a9

Browse files
authored
Fix golangci configuration (#27)
* Fix golangci configuration - Remove golint and add revive. golint is deprecated - Also fix goimports local-prefixes Signed-off-by: Friedrich Gonzalez <[email protected]> * Fix linting Signed-off-by: Friedrich Gonzalez <[email protected]> --------- Signed-off-by: Friedrich Gonzalez <[email protected]>
1 parent 0ab74e4 commit 3b122a9

33 files changed

+82
-87
lines changed

.golangci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ output:
1111
linters:
1212
enable:
1313
- goimports
14-
- golint
14+
- revive
1515
- misspell
1616
- gofmt
1717

1818
linters-settings:
1919
errcheck:
2020
exclude: .errcheck-exclude
2121
goimports:
22-
local-prefixes: "github.com/cortexproject/cortextool"
22+
local-prefixes: "github.com/cortexproject/cortex-tools"

cmd/e2ealerting/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import (
44
"flag"
55
"os"
66

7-
"github.com/cortexproject/cortex-tools/pkg/alerting"
87
"github.com/go-kit/log/level"
98

9+
"github.com/cortexproject/cortex-tools/pkg/alerting"
10+
1011
"github.com/cortexproject/cortex/pkg/util/flagext"
1112
util_log "github.com/cortexproject/cortex/pkg/util/log"
1213
"github.com/prometheus/client_golang/prometheus"

cmd/logtool/main.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func main() {
4545
for scanner.Scan() {
4646
show := false
4747
var qt time.Time
48-
var dur, len time.Duration
48+
var dur, length time.Duration
4949
var status, path, query, trace string
5050
var err error
5151

@@ -99,13 +99,13 @@ func main() {
9999
fmt.Println(err, line)
100100
continue
101101
}
102-
len = et.Sub(st)
102+
length = et.Sub(st)
103103
} else {
104104
// Loki queries are nanosecond, simple check to see if it's a second or nanosecond timestamp
105105
if st > 9999999999 {
106-
len = time.Unix(0, et).Sub(time.Unix(0, st))
106+
length = time.Unix(0, et).Sub(time.Unix(0, st))
107107
} else {
108-
len = time.Unix(et, 0).Sub(time.Unix(st, 0))
108+
length = time.Unix(et, 0).Sub(time.Unix(st, 0))
109109
}
110110

111111
}
@@ -132,9 +132,9 @@ func main() {
132132
ts = fmt.Sprint(qt.Local())
133133
}
134134
if *showQuery {
135-
fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v\t%v\t%v\n", ts, trace, len, dur, status, path, query)
135+
fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v\t%v\t%v\n", ts, trace, length, dur, status, path, query)
136136
} else {
137-
fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v\t%v\n", ts, trace, len, dur, status, path)
137+
fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v\t%v\n", ts, trace, length, dur, status, path)
138138
}
139139
//If looking at stdin, flush after every line as someone would only paste one line at a time at the terminal
140140
if !isPipe {

pkg/alerting/runner.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ import (
99
"sync"
1010
"time"
1111

12-
"github.com/cortexproject/cortex-tools/pkg/client"
13-
"github.com/cortexproject/cortex-tools/pkg/rules/rwrulefmt"
1412
"github.com/go-kit/log"
1513
"github.com/go-kit/log/level"
1614
"github.com/prometheus/client_golang/prometheus"
1715
yaml "gopkg.in/yaml.v3"
16+
17+
"github.com/cortexproject/cortex-tools/pkg/client"
18+
"github.com/cortexproject/cortex-tools/pkg/rules/rwrulefmt"
1819
)
1920

2021
// Case represents a metric that can be used for exporting, then verified against an Alertmanager webhook

pkg/analyse/ruler.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ package analyse
33
import (
44
"sort"
55

6-
"github.com/cortexproject/cortex-tools/pkg/rules/rwrulefmt"
76
"github.com/pkg/errors"
87
"github.com/prometheus/prometheus/promql/parser"
98
log "github.com/sirupsen/logrus"
9+
10+
"github.com/cortexproject/cortex-tools/pkg/rules/rwrulefmt"
1011
)
1112

1213
type MetricsInRuler struct {

pkg/bench/query_runner.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,8 @@ func (q *queryRunner) executeQuery(ctx context.Context, queryReq query) error {
204204
now := time.Now()
205205

206206
var (
207-
queryType string = "instant"
208-
status string = "success"
207+
queryType = "instant"
208+
status = "success"
209209
)
210210
if queryReq.timeRange > 0 {
211211
queryType = "range"

pkg/bench/write_client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ type writeClient struct {
3939
}
4040

4141
// newWriteClient creates a new client for remote write.
42-
func newWriteClient(name string, tenantName string, conf *remote.ClientConfig, logger log.Logger, requestHistogram *prometheus.HistogramVec) (*writeClient, error) {
42+
func newWriteClient(name string, tenantName string, conf *remote.ClientConfig, _ log.Logger, requestHistogram *prometheus.HistogramVec) (*writeClient, error) {
4343
httpClient, err := config_util.NewClientFromConfig(conf.HTTPClientConfig, "bench_write_client", config_util.WithHTTP2Disabled())
4444
if err != nil {
4545
return nil, err

pkg/chunk/cassandra/storage_client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,4 @@ func (noopConvictionPolicy) AddFailure(err error, host *gocql.HostInfo) bool {
196196
}
197197

198198
// Implementats gocql.ConvictionPolicy.
199-
func (noopConvictionPolicy) Reset(host *gocql.HostInfo) {}
199+
func (noopConvictionPolicy) Reset(_ *gocql.HostInfo) {}

pkg/chunk/migrate/writer/writer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func (w *Writer) Run(ctx context.Context, inChan chan chunk.Chunk) {
9191
}
9292
}
9393

94-
func (w *Writer) writeLoop(ctx context.Context, workerID int, inChan chan chunk.Chunk, errChan chan error) {
94+
func (w *Writer) writeLoop(ctx context.Context, _ int, inChan chan chunk.Chunk, errChan chan error) {
9595
defer w.workerGroup.Done()
9696

9797
for {

pkg/client/alerts.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type configCompat struct {
1717
}
1818

1919
// CreateAlertmanagerConfig creates a new alertmanager config
20-
func (r *CortexClient) CreateAlertmanagerConfig(ctx context.Context, cfg string, templates map[string]string) error {
20+
func (r *CortexClient) CreateAlertmanagerConfig(_ context.Context, cfg string, templates map[string]string) error {
2121
payload, err := yaml.Marshal(&configCompat{
2222
TemplateFiles: templates,
2323
AlertmanagerConfig: cfg,
@@ -37,7 +37,7 @@ func (r *CortexClient) CreateAlertmanagerConfig(ctx context.Context, cfg string,
3737
}
3838

3939
// DeleteAlermanagerConfig deletes the users alertmanagerconfig
40-
func (r *CortexClient) DeleteAlermanagerConfig(ctx context.Context) error {
40+
func (r *CortexClient) DeleteAlermanagerConfig(_ context.Context) error {
4141
res, err := r.doRequest(alertmanagerAPIPath, "DELETE", nil)
4242
if err != nil {
4343
return err
@@ -49,7 +49,7 @@ func (r *CortexClient) DeleteAlermanagerConfig(ctx context.Context) error {
4949
}
5050

5151
// GetAlertmanagerConfig retrieves a rule group
52-
func (r *CortexClient) GetAlertmanagerConfig(ctx context.Context) (string, map[string]string, error) {
52+
func (r *CortexClient) GetAlertmanagerConfig(_ context.Context) (string, map[string]string, error) {
5353
res, err := r.doRequest(alertmanagerAPIPath, "GET", nil)
5454
if err != nil {
5555
log.Debugln("no alert config present in response")

0 commit comments

Comments
 (0)