Skip to content

Commit 2b23793

Browse files
authored
golangci-lint v2 (#46)
1 parent 6a91fc1 commit 2b23793

File tree

5 files changed

+69
-59
lines changed

5 files changed

+69
-59
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,4 @@ jobs:
2525
with:
2626
files: ./coverage.txt
2727
- name: lint
28-
uses: golangci/golangci-lint-action@v6
29-
with:
30-
version: latest
28+
uses: golangci/golangci-lint-action@v7

.golangci.yaml

Lines changed: 57 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,64 @@
1+
version: "2"
12
run:
23
go: "1.23"
34
tests: false
4-
issues:
5-
exclude-files:
6-
- ".*_gen.go$"
7-
exclude-dirs:
8-
- temp
95
linters:
10-
enable-all: true
6+
default: all
117
disable:
12-
- gochecknoglobals
13-
- ireturn
8+
- depguard
149
- exhaustruct
10+
- gochecknoglobals
1511
- gocognit
16-
- depguard
17-
- intrange #pending 1.57.3
18-
- tenv
19-
linters-settings:
20-
cyclop:
21-
max-complexity: 18
22-
gci:
23-
sections:
24-
- standard
25-
- default
26-
- prefix(github.com/bir/iken)
27-
varnamelen:
28-
max-distance: 10
29-
ignore-type-assert-ok: true
30-
ignore-map-index-ok: true
31-
ignore-decls:
32-
- ok bool
33-
- i int
34-
- n int
35-
- e error
36-
- h http.Handler
37-
- t time.Time
38-
- v reflect.Value
39-
- w io.Writer
40-
- w http.ResponseWriter
41-
- rw http.ResponseWriter
42-
- r *http.Request
43-
- wg sync.WaitGroup
44-
- c chan
45-
- op string
46-
- l zerolog.Logger
47-
- r io.Reader
48-
- l zerolog.Context
49-
- s string
50-
- l string
12+
- intrange
13+
- ireturn
14+
settings:
15+
cyclop:
16+
max-complexity: 18
17+
varnamelen:
18+
max-distance: 10
19+
ignore-type-assert-ok: true
20+
ignore-map-index-ok: true
21+
ignore-decls:
22+
- ok bool
23+
- i int
24+
- n int
25+
- e error
26+
- h http.Handler
27+
- t time.Time
28+
- v reflect.Value
29+
- w io.Writer
30+
- w http.ResponseWriter
31+
- rw http.ResponseWriter
32+
- r *http.Request
33+
- wg sync.WaitGroup
34+
- c chan
35+
- op string
36+
- l zerolog.Logger
37+
- r io.Reader
38+
- l zerolog.Context
39+
- s string
40+
- l string
41+
exclusions:
42+
generated: lax
43+
presets:
44+
- comments
45+
- common-false-positives
46+
- legacy
47+
- std-error-handling
48+
paths:
49+
- .*_gen.go$
50+
- temp
51+
formatters:
52+
enable:
53+
- goimports
54+
- gci
55+
- gofumpt
56+
settings:
57+
gci:
58+
sections:
59+
- standard
60+
- default
61+
- localmodule
62+
custom-order: true
63+
exclusions:
64+
generated: disable

Makefile

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
lint:
2-
golangci-lint run --sort-results
2+
golangci-lint run
33

44
test:
55
go test -race ./...
@@ -17,14 +17,10 @@ updateAll:
1717
go get -u ./...
1818

1919
fmt:
20-
gofumpt -l -w .
21-
gci write . -s standard -s default -s "prefix(github.com/bir/iken)"
20+
golangci-lint fmt
2221

2322
tools:
24-
go install golang.org/x/tools/cmd/goimports@latest
25-
go install mvdan.cc/gofumpt@latest
26-
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
27-
go install github.com/daixiang0/gci@latest
23+
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
2824

2925
.PHONY: lint test cover tidy update updateAll fmt tools
3026

httputil/wrap_writer.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func (f *fancyWriter) Flush() {
125125
var ErrUnsupported = errors.New("not implemented")
126126

127127
func (f *fancyWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
128-
hj, ok := f.basicWriter.ResponseWriter.(http.Hijacker)
128+
hj, ok := f.ResponseWriter.(http.Hijacker)
129129
if !ok {
130130
return nil, nil, ErrUnsupported // Ignore coverage - unlikely to error
131131
}
@@ -134,16 +134,16 @@ func (f *fancyWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
134134
}
135135

136136
func (f *fancyWriter) ReadFrom(r io.Reader) (int64, error) {
137-
if f.basicWriter.tee != nil {
137+
if f.tee != nil {
138138
return io.Copy(&f.basicWriter, r) //nolint:wrapcheck // just a proxy
139139
}
140140

141-
rf, ok := f.basicWriter.ResponseWriter.(io.ReaderFrom)
141+
rf, ok := f.ResponseWriter.(io.ReaderFrom)
142142
if !ok {
143143
return 0, ErrUnsupported // Ignore coverage - unlikely to error
144144
}
145145

146-
f.basicWriter.maybeWriteHeader()
146+
f.maybeWriteHeader()
147147

148148
n, err := rf.ReadFrom(r)
149149
f.bytes += int(n)

params/params_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,10 @@ const (
361361
ParamSourceCookie
362362
)
363363

364-
var ParamSources = []ParamSource{ParamSourcePath, ParamSourceQuery, ParamSourceHeader, ParamSourceCookie}
365-
var ParamSourceNames = []string{"Path", "Query", "Header", "Cookie"}
364+
var (
365+
ParamSources = []ParamSource{ParamSourcePath, ParamSourceQuery, ParamSourceHeader, ParamSourceCookie}
366+
ParamSourceNames = []string{"Path", "Query", "Header", "Cookie"}
367+
)
366368

367369
// This abomination of a test function exists to run the same tests against all the different types
368370
// that can be retrieved from a param and all the different ways a param can be passed. The

0 commit comments

Comments
 (0)