diff --git a/.golangci.yml b/.golangci.yml index 71ec1be1..f81454ca 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -16,6 +16,10 @@ 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: @@ -23,8 +27,10 @@ linters: - asciicheck - bidichk - bodyclose + - canonicalheader - containedctx - contextcheck + - copyloopvar - cyclop - decorder - dogsled @@ -36,6 +42,7 @@ linters: - errname - errorlint - exhaustive + - fatcontext - forcetypeassert - gci - gocheckcompilerdirectives @@ -52,13 +59,16 @@ linters: - gomoddirectives - goprintffuncname - gosec + - gosmopolitan - grouper - importas - interfacebloat + - intrange - ireturn - lll - maintidx - makezero + - mirror - misspell - mnd - musttag @@ -77,6 +87,7 @@ linters: - revive - rowserrcheck - sqlclosecheck + - tagalign - tenv - thelper - tparallel @@ -85,3 +96,4 @@ linters: - usestdlibvars - wastedassign - whitespace + - zerologlint diff --git a/internal/local/islocal_test.go b/internal/local/islocal_test.go index 50adff10..6211293c 100644 --- a/internal/local/islocal_test.go +++ b/internal/local/islocal_test.go @@ -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() diff --git a/internal/server/handler_test.go b/internal/server/handler_test.go index c0b15cc2..fd072f2f 100644 --- a/internal/server/handler_test.go +++ b/internal/server/handler_test.go @@ -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) diff --git a/internal/stateful/writer_test.go b/internal/stateful/writer_test.go index daa2c212..ad7c75b8 100644 --- a/internal/stateful/writer_test.go +++ b/internal/stateful/writer_test.go @@ -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() diff --git a/pkg/blockbuilder/all_test.go b/pkg/blockbuilder/all_test.go index e475543d..1eb6ccf7 100644 --- a/pkg/blockbuilder/all_test.go +++ b/pkg/blockbuilder/all_test.go @@ -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() diff --git a/pkg/blockbuilder/getlist_test.go b/pkg/blockbuilder/getlist_test.go index 7e1a42ad..d1ce9b5c 100644 --- a/pkg/blockbuilder/getlist_test.go +++ b/pkg/blockbuilder/getlist_test.go @@ -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() diff --git a/pkg/blockbuilder/hostnames_test.go b/pkg/blockbuilder/hostnames_test.go index c8ae3961..7fe4d048 100644 --- a/pkg/blockbuilder/hostnames_test.go +++ b/pkg/blockbuilder/hostnames_test.go @@ -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() diff --git a/pkg/blockbuilder/ips_test.go b/pkg/blockbuilder/ips_test.go index 28299be4..4657192f 100644 --- a/pkg/blockbuilder/ips_test.go +++ b/pkg/blockbuilder/ips_test.go @@ -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() diff --git a/pkg/dot/settings_test.go b/pkg/dot/settings_test.go index 70648685..9086cde5 100644 --- a/pkg/dot/settings_test.go +++ b/pkg/dot/settings_test.go @@ -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() diff --git a/pkg/middlewares/filter/mapfilter/filter_test.go b/pkg/middlewares/filter/mapfilter/filter_test.go index e5b2fd70..f30acdf2 100644 --- a/pkg/middlewares/filter/mapfilter/filter_test.go +++ b/pkg/middlewares/filter/mapfilter/filter_test.go @@ -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() diff --git a/pkg/middlewares/filter/mapfilter/request_test.go b/pkg/middlewares/filter/mapfilter/request_test.go index 9431a473..10fbf5f7 100644 --- a/pkg/middlewares/filter/mapfilter/request_test.go +++ b/pkg/middlewares/filter/mapfilter/request_test.go @@ -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() diff --git a/pkg/middlewares/filter/update/settings_test.go b/pkg/middlewares/filter/update/settings_test.go index 2c1c32a3..ccdb062e 100644 --- a/pkg/middlewares/filter/update/settings_test.go +++ b/pkg/middlewares/filter/update/settings_test.go @@ -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() diff --git a/pkg/middlewares/localdns/handler_test.go b/pkg/middlewares/localdns/handler_test.go index 38c4b689..d5cc0b5c 100644 --- a/pkg/middlewares/localdns/handler_test.go +++ b/pkg/middlewares/localdns/handler_test.go @@ -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) diff --git a/pkg/middlewares/localdns/settings_test.go b/pkg/middlewares/localdns/settings_test.go index 152d1fc0..22439117 100644 --- a/pkg/middlewares/localdns/settings_test.go +++ b/pkg/middlewares/localdns/settings_test.go @@ -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() diff --git a/pkg/middlewares/log/log_test.go b/pkg/middlewares/log/log_test.go index 890a062c..99173a68 100644 --- a/pkg/middlewares/log/log_test.go +++ b/pkg/middlewares/log/log_test.go @@ -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) diff --git a/pkg/middlewares/log/settings_test.go b/pkg/middlewares/log/settings_test.go index b6706fe1..708a078c 100644 --- a/pkg/middlewares/log/settings_test.go +++ b/pkg/middlewares/log/settings_test.go @@ -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() diff --git a/pkg/middlewares/substituter/middleware_test.go b/pkg/middlewares/substituter/middleware_test.go index 39f43c22..b84df71b 100644 --- a/pkg/middlewares/substituter/middleware_test.go +++ b/pkg/middlewares/substituter/middleware_test.go @@ -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) diff --git a/pkg/middlewares/substituter/settings_test.go b/pkg/middlewares/substituter/settings_test.go index 39925c0d..04b68df6 100644 --- a/pkg/middlewares/substituter/settings_test.go +++ b/pkg/middlewares/substituter/settings_test.go @@ -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() @@ -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() @@ -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() diff --git a/pkg/provider/provider.go b/pkg/provider/provider.go index 75e830e9..dcfcbf60 100644 --- a/pkg/provider/provider.go +++ b/pkg/provider/provider.go @@ -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 { @@ -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"` } diff --git a/pkg/provider/providers_test.go b/pkg/provider/providers_test.go index 591db3c2..ad8f66f6 100644 --- a/pkg/provider/providers_test.go +++ b/pkg/provider/providers_test.go @@ -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()