Skip to content

Commit 36302cb

Browse files
authored
Merge pull request #285 from bookingcom/avereha/golangci-lint
Avereha/golangci lint
2 parents 3f7591f + f19ab30 commit 36302cb

File tree

75 files changed

+533
-438
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+533
-438
lines changed

.github/workflows/ci.yml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
on: [push, pull_request]
21
name: CI
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
37
jobs:
48
test:
59
strategy:
@@ -20,3 +24,22 @@ jobs:
2024
run: make all check
2125
- name: integration test
2226
run: tests/system_test.sh
27+
golangci:
28+
name: lint
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v2
32+
- name: golangci-lint
33+
uses: golangci/golangci-lint-action@v2
34+
with:
35+
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
36+
version: v1.30
37+
38+
# Optional: working directory, useful for monorepos
39+
# working-directory: somedir
40+
41+
# Optional: golangci-lint command line arguments.
42+
#args: --new-from-rev=f7cdb31b6a6c8
43+
44+
# Optional: show only new issues if it's a pull request. The default value is `false`.
45+
# only-new-issues: true

.golangci.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ linters-settings:
3333
# [deprecated] comma-separated list of pairs of the form pkg:regex
3434
# the regex is used to ignore names within pkg. (default "fmt:.*").
3535
# see https://github.com/kisielk/errcheck#the-deprecated-method for details
36-
ignore: fmt:.*,io/ioutil:^Read.*
36+
ignore: fmt:.*,io/ioutil:^Read.*,github.com/bradfitz/gomemcache/memcache:^Set,github.com/bookingcom/carbonapi/pkg/prioritylimiter:Leave,github.com/bookingcom/carbonapi/cache:Set
3737

3838
# path to a file containing a list of functions to exclude from checking
3939
# see https://github.com/kisielk/errcheck#excluding-functions for details
40-
# exclude: /path/to/file.txt
40+
#exclude:
4141
govet:
4242
# report about shadowed variables
4343
check-shadowing: true
@@ -138,6 +138,8 @@ linters-settings:
138138
paramsOnly: true
139139
rangeValCopy:
140140
sizeThreshold: 32
141+
exhaustive:
142+
default-signifies-exhaustive: true
141143

142144
linters:
143145
enable:
@@ -175,6 +177,7 @@ issues:
175177
- errcheck
176178
- dupl
177179
- gosec
180+
- noctx
178181

179182
# Exclude known linters from partially hard-vendored code,
180183
# which is impossible to exclude via "nolint" comments.

Makefile

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@ vet:
3737
go vet -composites=false ./...
3838

3939
lint:
40-
# Show only issues introduced since switching from gometalinter to
41-
# golangci-lint. The commit b5dd153 was the merge-base on master at the time.
42-
# This is not in .golangci.yml in order to show all the gore when run directly.
43-
golangci-lint run --new-from-rev 9ce419bc428b76f1505230e501546e2245374c94
44-
45-
lint-all:
4640
golangci-lint run
4741

4842
check: test vet

app/carbonapi/app.go

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func (app *App) Start() func() {
106106

107107
handler := initHandlers(app)
108108

109-
prometheusServer := app.registerPrometheusMetrics(logger)
109+
prometheusServer := app.registerPrometheusMetrics()
110110

111111
app.requestBlocker.ScheduleRuleReload()
112112

@@ -125,20 +125,7 @@ func (app *App) Start() func() {
125125
return flush
126126
}
127127

128-
func recoveryHandler(h http.Handler, lg *zap.Logger) http.Handler {
129-
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
130-
defer func() {
131-
if r := recover(); r != nil {
132-
http.Error(w, "recovered from panic", http.StatusInternalServerError)
133-
lg.Error("recovered from panic", zap.Any("details", r))
134-
}
135-
}()
136-
137-
h.ServeHTTP(w, r)
138-
})
139-
}
140-
141-
func (app *App) registerPrometheusMetrics(logger *zap.Logger) *http.Server {
128+
func (app *App) registerPrometheusMetrics() *http.Server {
142129
prometheus.MustRegister(app.prometheusMetrics.Requests)
143130
prometheus.MustRegister(app.prometheusMetrics.Responses)
144131
prometheus.MustRegister(app.prometheusMetrics.FindNotFound)
@@ -426,16 +413,11 @@ var timeBuckets []int64
426413
var expTimeBuckets []int64
427414

428415
type bucketEntry int
429-
type expBucketEntry int
430416

431417
func (b bucketEntry) String() string {
432418
return strconv.Itoa(int(atomic.LoadInt64(&timeBuckets[b])))
433419
}
434420

435-
func (b expBucketEntry) String() string {
436-
return strconv.Itoa(int(atomic.LoadInt64(&expTimeBuckets[b])))
437-
}
438-
439421
func renderTimeBuckets() interface{} {
440422
return timeBuckets
441423
}

app/carbonapi/app_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ func renderHandlerErrs(t *testing.T) {
235235
}
236236

237237
for _, tst := range tests {
238+
tst := tst
238239
t.Run(tst.req, func(t *testing.T) {
239240
req := httptest.NewRequest("GET", tst.req, nil)
240241
rr := httptest.NewRecorder()

0 commit comments

Comments
 (0)