Skip to content

Commit

Permalink
chore(lint): add new linters
Browse files Browse the repository at this point in the history
  • Loading branch information
qdm12 committed Oct 17, 2024
1 parent fc2680f commit b5dbe37
Show file tree
Hide file tree
Showing 20 changed files with 16 additions and 24 deletions.
12 changes: 12 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,21 @@ issues:
- linters:
- ireturn
text: ".+returns interface \\(github\\.com\\/prometheus\\/client_golang\\/prometheus\\.[a-zA-Z]+\\)$"
- linters:
- nolintlint
path: pkg/middlewares/.+/middleware\.go
text: "directive `\\/\\/nolint:ireturn` is unused for linter \"ireturn\""

linters:
enable:
- asasalint
- asciicheck
- bidichk
- bodyclose
- canonicalheader
- containedctx
- contextcheck
- copyloopvar
- cyclop
- decorder
- dogsled
Expand All @@ -36,6 +42,7 @@ linters:
- errname
- errorlint
- exhaustive
- fatcontext
- forcetypeassert
- gci
- gocheckcompilerdirectives
Expand All @@ -52,13 +59,16 @@ linters:
- gomoddirectives
- goprintffuncname
- gosec
- gosmopolitan
- grouper
- importas
- interfacebloat
- intrange
- ireturn
- lll
- maintidx
- makezero
- mirror
- misspell
- mnd
- musttag
Expand All @@ -77,6 +87,7 @@ linters:
- revive
- rowserrcheck
- sqlclosecheck
- tagalign
- tenv
- thelper
- tparallel
Expand All @@ -85,3 +96,4 @@ linters:
- usestdlibvars
- wastedassign
- whitespace
- zerologlint
2 changes: 0 additions & 2 deletions internal/local/islocal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ func Test_IsFQDNLocal(t *testing.T) {
}

for name, testCase := range testCases {
testCase := testCase

t.Run(name, func(t *testing.T) {
t.Parallel()

Expand Down
1 change: 0 additions & 1 deletion internal/server/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ func Test_Handler_ServeDNS(t *testing.T) {
}

for name, testCase := range testCases {
testCase := testCase
t.Run(name, func(t *testing.T) {
t.Parallel()
ctrl := gomock.NewController(t)
Expand Down
1 change: 0 additions & 1 deletion internal/stateful/writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ func Test_Writer(t *testing.T) {
}

for name, testCase := range testCases {
testCase := testCase
t.Run(name, func(t *testing.T) {
t.Parallel()

Expand Down
1 change: 0 additions & 1 deletion pkg/blockbuilder/all_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ func Test_Builder_BuildAll(t *testing.T) { //nolint:cyclop,maintidx
},
}
for name, tc := range tests {
tc := tc
t.Run(name, func(t *testing.T) {
t.Parallel()
ctx := context.Background()
Expand Down
1 change: 0 additions & 1 deletion pkg/blockbuilder/getlist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ func Test_getList(t *testing.T) {
},
}
for name, tc := range tests {
tc := tc
t.Run(name, func(t *testing.T) {
t.Parallel()
ctx := context.Background()
Expand Down
1 change: 0 additions & 1 deletion pkg/blockbuilder/hostnames_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ func Test_Builder_Hostnames(t *testing.T) { //nolint:cyclop
},
}
for name, tc := range tests {
tc := tc
t.Run(name, func(t *testing.T) {
t.Parallel()

Expand Down
1 change: 0 additions & 1 deletion pkg/blockbuilder/ips_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ func Test_Builder_IPs(t *testing.T) { //nolint:cyclop
},
}
for name, tc := range tests {
tc := tc
t.Run(name, func(t *testing.T) {
t.Parallel()

Expand Down
1 change: 0 additions & 1 deletion pkg/dot/settings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ func Test_ServerSettings_String(t *testing.T) {
}

for name, testCase := range testCases {
testCase := testCase
t.Run(name, func(t *testing.T) {
t.Parallel()

Expand Down
2 changes: 1 addition & 1 deletion pkg/middlewares/filter/mapfilter/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func Test_Filter_threadSafety(t *testing.T) {
const parallelism = 1000
startWg.Add(parallelism)
endWg.Add(parallelism)
for i := 0; i < parallelism; i++ {
for range parallelism {
go func() {
defer endWg.Done()
startWg.Done()
Expand Down
1 change: 0 additions & 1 deletion pkg/middlewares/filter/mapfilter/request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ func Test_FilterRequest(t *testing.T) {
}

for name, testCase := range testCases {
testCase := testCase
t.Run(name, func(t *testing.T) {
t.Parallel()

Expand Down
1 change: 0 additions & 1 deletion pkg/middlewares/filter/update/settings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ func Test_Settings_BlockHostnames(t *testing.T) {
}

for name, testCase := range testCases {
testCase := testCase
t.Run(name, func(t *testing.T) {
t.Parallel()

Expand Down
1 change: 0 additions & 1 deletion pkg/middlewares/localdns/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,6 @@ func Test_handler_ServeDNS(t *testing.T) {
}

for name, testCase := range testCases {
testCase := testCase
t.Run(name, func(t *testing.T) {
t.Parallel()
ctrl := gomock.NewController(t)
Expand Down
1 change: 0 additions & 1 deletion pkg/middlewares/localdns/settings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ func Test_Settings_String(t *testing.T) {
}

for name, testCase := range testCases {
testCase := testCase
t.Run(name, func(t *testing.T) {
t.Parallel()

Expand Down
1 change: 0 additions & 1 deletion pkg/middlewares/log/log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ func Test_handler_ServeDNS(t *testing.T) {
}

for name, testCase := range testCases {
testCase := testCase
t.Run(name, func(t *testing.T) {
t.Parallel()
ctrl := gomock.NewController(t)
Expand Down
1 change: 0 additions & 1 deletion pkg/middlewares/log/settings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ func Test_Settings_String(t *testing.T) {
}

for name, testCase := range testCases {
testCase := testCase
t.Run(name, func(t *testing.T) {
t.Parallel()

Expand Down
1 change: 0 additions & 1 deletion pkg/middlewares/substituter/middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ func Test_handler_ServeDNS(t *testing.T) {
}

for name, testCase := range testCases {
testCase := testCase
t.Run(name, func(t *testing.T) {
t.Parallel()
ctrl := gomock.NewController(t)
Expand Down
3 changes: 0 additions & 3 deletions pkg/middlewares/substituter/settings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ func Test_Settings_SetDefaults(t *testing.T) {
}

for name, testCase := range testCases {
testCase := testCase
t.Run(name, func(t *testing.T) {
t.Parallel()

Expand All @@ -68,7 +67,6 @@ func Test_Settings_Validate(t *testing.T) {
}

for name, testCase := range testCases {
testCase := testCase
t.Run(name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -106,7 +104,6 @@ func Test_Settings_String(t *testing.T) {
}

for name, testCase := range testCases {
testCase := testCase
t.Run(name, func(t *testing.T) {
t.Parallel()

Expand Down
6 changes: 3 additions & 3 deletions pkg/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (

type Provider struct {
Name string `json:"name" yaml:"name"`
DoT DoTServer `json:"dot" yaml:"dot"`
DoH DoHServer `json:"doh" yaml:"doh"`
DoT DoTServer `json:"dot" yaml:"dot"`
DoH DoHServer `json:"doh" yaml:"doh"`
}

type DoTServer struct {
Expand All @@ -19,7 +19,7 @@ type DoTServer struct {
}

type DoHServer struct {
URL string `json:"url" yaml:"url"`
URL string `json:"url" yaml:"url"`
IPv4 []netip.Addr `json:"ipv4" yaml:"ipv4"`
IPv6 []netip.Addr `json:"ipv6" yaml:"ipv6"`
}
Expand Down
1 change: 0 additions & 1 deletion pkg/provider/providers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ func Test_Providers_Get(t *testing.T) {
}

for name, testCase := range testCases {
testCase := testCase
t.Run(name, func(t *testing.T) {
t.Parallel()

Expand Down

0 comments on commit b5dbe37

Please sign in to comment.