From abe9dcbe33615e70f64c2e5b8e8dd054deb6df2b Mon Sep 17 00:00:00 2001 From: Quentin McGaw Date: Fri, 11 Oct 2024 18:28:00 +0000 Subject: [PATCH] chore(lint): add new linters and update codebase - add canonicalheader - add copyloopvar - add fatcontext - add intrange --- .golangci.yml | 4 ++++ internal/command/run_test.go | 1 - internal/command/start_test.go | 1 - internal/configuration/settings/firewall.go | 1 - internal/configuration/settings/firewall_test.go | 1 - internal/configuration/settings/openvpn_test.go | 1 - internal/configuration/settings/settings_test.go | 1 - internal/configuration/sources/files/wireguard_test.go | 3 --- internal/configuration/sources/secrets/reader_test.go | 1 - internal/firewall/delete_test.go | 2 -- internal/firewall/list_test.go | 1 - internal/firewall/parse_test.go | 2 -- internal/firewall/support_test.go | 4 ---- internal/format/duration_test.go | 1 - internal/healthcheck/health_test.go | 1 - internal/httpserver/server_test.go | 1 - internal/httpserver/settings_test.go | 5 ----- internal/models/markdown_test.go | 1 - internal/models/server_test.go | 1 - internal/models/servers_test.go | 2 -- internal/natpmp/checks_test.go | 3 --- internal/natpmp/externaladdress_test.go | 1 - internal/natpmp/portmapping_test.go | 1 - internal/natpmp/rpc.go | 2 +- internal/natpmp/rpc_test.go | 2 -- internal/netlink/conversion_test.go | 3 --- internal/openvpn/extract/extract_test.go | 4 ---- internal/openvpn/extract/pem_test.go | 1 - internal/openvpn/logs_test.go | 1 - internal/openvpn/pkcs8/algorithms_test.go | 1 - internal/openvpn/pkcs8/upgrade_test.go | 1 - internal/portforward/service/helpers_test.go | 1 - internal/pprof/settings_test.go | 5 ----- internal/provider/custom/openvpnconf_test.go | 1 - internal/provider/expressvpn/connection_test.go | 1 - internal/provider/fastestvpn/updater/api.go | 2 +- internal/provider/fastestvpn/updater/api_test.go | 2 -- internal/provider/ipvanish/updater/filename_test.go | 1 - internal/provider/ipvanish/updater/hosttoserver_test.go | 4 ---- internal/provider/ipvanish/updater/servers_test.go | 1 - internal/provider/ivpn/connection_test.go | 1 - internal/provider/ivpn/updater/api_test.go | 1 - internal/provider/ivpn/updater/servers_test.go | 1 - internal/provider/mullvad/connection_test.go | 1 - internal/provider/mullvad/updater/ips_test.go | 1 - internal/provider/perfectprivacy/portforward_test.go | 1 - internal/provider/privateinternetaccess/portforward_test.go | 2 -- internal/provider/privatevpn/portforward_test.go | 1 - internal/provider/slickvpn/updater/website_test.go | 2 -- internal/provider/surfshark/updater/api_test.go | 2 -- internal/provider/utils/cipher_test.go | 1 - internal/provider/utils/connection_test.go | 1 - internal/provider/utils/filtering_test.go | 2 -- internal/provider/utils/port_test.go | 1 - internal/provider/utils/protocol_test.go | 2 -- internal/provider/utils/wireguard_test.go | 1 - internal/provider/vpnsecure/updater/website_test.go | 2 -- internal/provider/wevpn/connection_test.go | 1 - internal/provider/windscribe/connection_test.go | 1 - internal/publicip/api/multi.go | 2 +- internal/routing/conversion_test.go | 1 - internal/routing/ip_test.go | 1 - internal/routing/rules_test.go | 5 ----- internal/server/middlewares/auth/apikey.go | 2 +- internal/server/middlewares/auth/configfile_test.go | 1 - internal/server/middlewares/auth/lookup_test.go | 1 - internal/server/middlewares/auth/middleware_test.go | 1 - internal/storage/copy_test.go | 1 - internal/storage/read_test.go | 1 - internal/updater/html/fetch_test.go | 1 - internal/updater/resolver/ips_test.go | 1 - internal/wireguard/address_test.go | 1 - internal/wireguard/config_test.go | 1 - internal/wireguard/constructor_test.go | 1 - internal/wireguard/route_test.go | 1 - internal/wireguard/rule_test.go | 1 - internal/wireguard/settings_test.go | 3 --- 77 files changed, 8 insertions(+), 116 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index ca124b07..1627a4d2 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -37,7 +37,9 @@ linters: - asciicheck - bidichk - bodyclose + - canonicalheader - containedctx + - copyloopvar - decorder - dogsled - dupl @@ -47,6 +49,7 @@ linters: - errchkjson - errname - exhaustive + - fatcontext - forcetypeassert - gci - gocheckcompilerdirectives @@ -66,6 +69,7 @@ linters: - grouper - importas - interfacebloat + - intrange - ireturn - lll - maintidx diff --git a/internal/command/run_test.go b/internal/command/run_test.go index 0f7892c5..f3047a3c 100644 --- a/internal/command/run_test.go +++ b/internal/command/run_test.go @@ -30,7 +30,6 @@ func Test_run(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/command/start_test.go b/internal/command/start_test.go index 5f808ae3..7d116484 100644 --- a/internal/command/start_test.go +++ b/internal/command/start_test.go @@ -54,7 +54,6 @@ func Test_start(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/configuration/settings/firewall.go b/internal/configuration/settings/firewall.go index a7b664f8..19712d66 100644 --- a/internal/configuration/settings/firewall.go +++ b/internal/configuration/settings/firewall.go @@ -104,7 +104,6 @@ func (f Firewall) toLinesNode() (node *gotree.Node) { if len(f.OutboundSubnets) > 0 { outboundSubnets := node.Appendf("Outbound subnets:") for _, subnet := range f.OutboundSubnets { - subnet := subnet outboundSubnets.Appendf("%s", &subnet) } } diff --git a/internal/configuration/settings/firewall_test.go b/internal/configuration/settings/firewall_test.go index a477d8c1..e79ca3f1 100644 --- a/internal/configuration/settings/firewall_test.go +++ b/internal/configuration/settings/firewall_test.go @@ -59,7 +59,6 @@ func Test_Firewall_validate(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/configuration/settings/openvpn_test.go b/internal/configuration/settings/openvpn_test.go index 09610f19..355d0eb4 100644 --- a/internal/configuration/settings/openvpn_test.go +++ b/internal/configuration/settings/openvpn_test.go @@ -32,7 +32,6 @@ func Test_ivpnAccountID(t *testing.T) { } for _, testCase := range testCases { - testCase := testCase t.Run(testCase.s, func(t *testing.T) { t.Parallel() diff --git a/internal/configuration/settings/settings_test.go b/internal/configuration/settings/settings_test.go index 6f1592be..75ae9292 100644 --- a/internal/configuration/settings/settings_test.go +++ b/internal/configuration/settings/settings_test.go @@ -86,7 +86,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/internal/configuration/sources/files/wireguard_test.go b/internal/configuration/sources/files/wireguard_test.go index 93fe5b2b..26ac77e9 100644 --- a/internal/configuration/sources/files/wireguard_test.go +++ b/internal/configuration/sources/files/wireguard_test.go @@ -73,7 +73,6 @@ PresharedKey = YJ680VN+dGrdsWNjSFqZ6vvwuiNhbq502ZL3G7Q3o3g= } for testName, testCase := range testCases { - testCase := testCase t.Run(testName, func(t *testing.T) { t.Parallel() @@ -123,7 +122,6 @@ Address = 10.38.22.35/32 } for testName, testCase := range testCases { - testCase := testCase t.Run(testName, func(t *testing.T) { t.Parallel() @@ -184,7 +182,6 @@ Endpoint = 1.2.3.4:51820`, } for testName, testCase := range testCases { - testCase := testCase t.Run(testName, func(t *testing.T) { t.Parallel() diff --git a/internal/configuration/sources/secrets/reader_test.go b/internal/configuration/sources/secrets/reader_test.go index db12c55b..35577eba 100644 --- a/internal/configuration/sources/secrets/reader_test.go +++ b/internal/configuration/sources/secrets/reader_test.go @@ -91,7 +91,6 @@ func Test_Source_Get(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/firewall/delete_test.go b/internal/firewall/delete_test.go index 2095ecf9..1f6b5ceb 100644 --- a/internal/firewall/delete_test.go +++ b/internal/firewall/delete_test.go @@ -38,7 +38,6 @@ func Test_isDeleteMatchInstruction(t *testing.T) { }, } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -161,7 +160,6 @@ func Test_deleteIPTablesRule(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/firewall/list_test.go b/internal/firewall/list_test.go index d86592d9..7adcd716 100644 --- a/internal/firewall/list_test.go +++ b/internal/firewall/list_test.go @@ -105,7 +105,6 @@ num pkts bytes target prot opt in out source destinati } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/firewall/parse_test.go b/internal/firewall/parse_test.go index 1244dc6c..ae07bc6b 100644 --- a/internal/firewall/parse_test.go +++ b/internal/firewall/parse_test.go @@ -68,7 +68,6 @@ func Test_parseIptablesInstruction(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -121,7 +120,6 @@ func Test_parseIPPrefix(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/firewall/support_test.go b/internal/firewall/support_test.go index 4f7039bd..2a90a2f0 100644 --- a/internal/firewall/support_test.go +++ b/internal/firewall/support_test.go @@ -110,7 +110,6 @@ func Test_checkIptablesSupport(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() ctrl := gomock.NewController(t) @@ -249,7 +248,6 @@ func Test_testIptablesPath(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() ctrl := gomock.NewController(t) @@ -287,7 +285,6 @@ func Test_isPermissionDenied(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -330,7 +327,6 @@ func Test_extractInputPolicy(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/format/duration_test.go b/internal/format/duration_test.go index e9e6ee0c..5728d364 100644 --- a/internal/format/duration_test.go +++ b/internal/format/duration_test.go @@ -54,7 +54,6 @@ func Test_FriendlyDuration(t *testing.T) { }, } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/healthcheck/health_test.go b/internal/healthcheck/health_test.go index 35029d73..15d46a19 100644 --- a/internal/healthcheck/health_test.go +++ b/internal/healthcheck/health_test.go @@ -90,7 +90,6 @@ func Test_makeAddressToDial(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/httpserver/server_test.go b/internal/httpserver/server_test.go index e8654009..0523db7e 100644 --- a/internal/httpserver/server_test.go +++ b/internal/httpserver/server_test.go @@ -48,7 +48,6 @@ func Test_New(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/httpserver/settings_test.go b/internal/httpserver/settings_test.go index 27a8edbd..3c817f3c 100644 --- a/internal/httpserver/settings_test.go +++ b/internal/httpserver/settings_test.go @@ -44,7 +44,6 @@ func Test_Settings_SetDefaults(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -87,7 +86,6 @@ func Test_Settings_Copy(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -173,7 +171,6 @@ func Test_Settings_OverrideWith(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -263,7 +260,6 @@ func Test_Settings_Validate(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -300,7 +296,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/internal/models/markdown_test.go b/internal/models/markdown_test.go index c62750cf..16d7cee4 100644 --- a/internal/models/markdown_test.go +++ b/internal/models/markdown_test.go @@ -52,7 +52,6 @@ func Test_Servers_ToMarkdown(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/models/server_test.go b/internal/models/server_test.go index d42c38d6..8cdd7de1 100644 --- a/internal/models/server_test.go +++ b/internal/models/server_test.go @@ -103,7 +103,6 @@ func Test_Server_Equal(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/models/servers_test.go b/internal/models/servers_test.go index 0c452512..9cf7dbfc 100644 --- a/internal/models/servers_test.go +++ b/internal/models/servers_test.go @@ -54,7 +54,6 @@ func Test_AllServers_MarshalJSON(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -124,7 +123,6 @@ func Test_AllServers_UnmarshalJSON(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/natpmp/checks_test.go b/internal/natpmp/checks_test.go index 096b82e3..8efc6463 100644 --- a/internal/natpmp/checks_test.go +++ b/internal/natpmp/checks_test.go @@ -25,7 +25,6 @@ func Test_checkRequest(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -88,7 +87,6 @@ func Test_checkResponse(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -146,7 +144,6 @@ func Test_checkResultCode(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/natpmp/externaladdress_test.go b/internal/natpmp/externaladdress_test.go index ddef6798..d040aea7 100644 --- a/internal/natpmp/externaladdress_test.go +++ b/internal/natpmp/externaladdress_test.go @@ -46,7 +46,6 @@ func Test_Client_ExternalAddress(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/natpmp/portmapping_test.go b/internal/natpmp/portmapping_test.go index 3bbbb923..98d90143 100644 --- a/internal/natpmp/portmapping_test.go +++ b/internal/natpmp/portmapping_test.go @@ -115,7 +115,6 @@ func Test_Client_AddPortMapping(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/natpmp/rpc.go b/internal/natpmp/rpc.go index f9467746..75cb0ed7 100644 --- a/internal/natpmp/rpc.go +++ b/internal/natpmp/rpc.go @@ -69,7 +69,7 @@ func (c *Client) rpc(ctx context.Context, gateway netip.Addr, var retryCount uint var failedAttempts []string - for retryCount = 0; retryCount < c.maxRetries; retryCount++ { + for retryCount = 0; retryCount < c.maxRetries; retryCount++ { //nolint:intrange deadline := time.Now().Add(connectionDuration) err = connection.SetDeadline(deadline) if err != nil { diff --git a/internal/natpmp/rpc_test.go b/internal/natpmp/rpc_test.go index 072c0db3..3019d012 100644 --- a/internal/natpmp/rpc_test.go +++ b/internal/natpmp/rpc_test.go @@ -138,7 +138,6 @@ func Test_Client_rpc(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -193,7 +192,6 @@ func Test_dedupFailedAttempts(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/netlink/conversion_test.go b/internal/netlink/conversion_test.go index c9e89594..3c16fd29 100644 --- a/internal/netlink/conversion_test.go +++ b/internal/netlink/conversion_test.go @@ -42,7 +42,6 @@ func Test_netipPrefixToIPNet(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -90,7 +89,6 @@ func Test_netIPNetToNetipPrefix(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -128,7 +126,6 @@ func Test_netIPToNetipAddress(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/openvpn/extract/extract_test.go b/internal/openvpn/extract/extract_test.go index b1d424fb..ee21588e 100644 --- a/internal/openvpn/extract/extract_test.go +++ b/internal/openvpn/extract/extract_test.go @@ -65,7 +65,6 @@ func Test_extractDataFromLines(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -129,7 +128,6 @@ func Test_extractDataFromLine(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -175,7 +173,6 @@ func Test_extractProto(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -253,7 +250,6 @@ func Test_extractRemote(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/openvpn/extract/pem_test.go b/internal/openvpn/extract/pem_test.go index 77a2a037..2a4680b6 100644 --- a/internal/openvpn/extract/pem_test.go +++ b/internal/openvpn/extract/pem_test.go @@ -40,7 +40,6 @@ func Test_PEM(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/openvpn/logs_test.go b/internal/openvpn/logs_test.go index 00929a13..6f1c6077 100644 --- a/internal/openvpn/logs_test.go +++ b/internal/openvpn/logs_test.go @@ -75,7 +75,6 @@ That error usually happens because either: }, } for name, tc := range tests { - tc := tc t.Run(name, func(t *testing.T) { t.Parallel() filtered, level := processLogLine(tc.s) diff --git a/internal/openvpn/pkcs8/algorithms_test.go b/internal/openvpn/pkcs8/algorithms_test.go index 66a49f9d..8fb3ae77 100644 --- a/internal/openvpn/pkcs8/algorithms_test.go +++ b/internal/openvpn/pkcs8/algorithms_test.go @@ -86,7 +86,6 @@ func Test_getEncryptionAlgorithmOid(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/openvpn/pkcs8/upgrade_test.go b/internal/openvpn/pkcs8/upgrade_test.go index 8fc03614..cd99522d 100644 --- a/internal/openvpn/pkcs8/upgrade_test.go +++ b/internal/openvpn/pkcs8/upgrade_test.go @@ -48,7 +48,6 @@ func Test_UpgradeEncryptedKey(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/portforward/service/helpers_test.go b/internal/portforward/service/helpers_test.go index e92f3c11..da28c246 100644 --- a/internal/portforward/service/helpers_test.go +++ b/internal/portforward/service/helpers_test.go @@ -31,7 +31,6 @@ func Test_portsToString(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/pprof/settings_test.go b/internal/pprof/settings_test.go index 5331ce7d..d3155531 100644 --- a/internal/pprof/settings_test.go +++ b/internal/pprof/settings_test.go @@ -55,7 +55,6 @@ func Test_Settings_SetDefaults(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -97,7 +96,6 @@ func Test_Settings_Copy(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -182,7 +180,6 @@ func Test_Settings_OverrideWith(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -245,7 +242,6 @@ func Test_Settings_Validate(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -293,7 +289,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/internal/provider/custom/openvpnconf_test.go b/internal/provider/custom/openvpnconf_test.go index e3d7178c..ab8ef6bb 100644 --- a/internal/provider/custom/openvpnconf_test.go +++ b/internal/provider/custom/openvpnconf_test.go @@ -79,7 +79,6 @@ func Test_modifyConfig(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/provider/expressvpn/connection_test.go b/internal/provider/expressvpn/connection_test.go index e9e30818..fdf45ec0 100644 --- a/internal/provider/expressvpn/connection_test.go +++ b/internal/provider/expressvpn/connection_test.go @@ -77,7 +77,6 @@ func Test_Provider_GetConnection(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/provider/fastestvpn/updater/api.go b/internal/provider/fastestvpn/updater/api.go index 39e35fc6..f0d02be9 100644 --- a/internal/provider/fastestvpn/updater/api.go +++ b/internal/provider/fastestvpn/updater/api.go @@ -77,7 +77,7 @@ func fetchAPIServers(ctx context.Context, client *http.Client, protocol string) var server apiServer const numberOfTDBlocks = 3 - for i := 0; i < numberOfTDBlocks; i++ { + for i := range numberOfTDBlocks { tdBlock := getNextTDBlock(trBlock) if tdBlock == nil { return nil, fmt.Errorf("%w: expected 3 blocks in block %q", diff --git a/internal/provider/fastestvpn/updater/api_test.go b/internal/provider/fastestvpn/updater/api_test.go index ec49a887..9c31ed86 100644 --- a/internal/provider/fastestvpn/updater/api_test.go +++ b/internal/provider/fastestvpn/updater/api_test.go @@ -89,7 +89,6 @@ func Test_fechAPIServers(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -152,7 +151,6 @@ func Test_getNextBlock(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/provider/ipvanish/updater/filename_test.go b/internal/provider/ipvanish/updater/filename_test.go index 41128264..50a6d702 100644 --- a/internal/provider/ipvanish/updater/filename_test.go +++ b/internal/provider/ipvanish/updater/filename_test.go @@ -37,7 +37,6 @@ func Test_parseFilename(t *testing.T) { }, } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/provider/ipvanish/updater/hosttoserver_test.go b/internal/provider/ipvanish/updater/hosttoserver_test.go index 01438397..41d384cf 100644 --- a/internal/provider/ipvanish/updater/hosttoserver_test.go +++ b/internal/provider/ipvanish/updater/hosttoserver_test.go @@ -87,7 +87,6 @@ func Test_hostToServer_add(t *testing.T) { }, } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() testCase.initialHTS.add(testCase.host, testCase.country, testCase.city, testCase.tcp, testCase.udp) @@ -121,7 +120,6 @@ func Test_hostToServer_toHostsSlice(t *testing.T) { }, } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() hosts := testCase.hts.toHostsSlice() @@ -175,7 +173,6 @@ func Test_hostToServer_adaptWithIPs(t *testing.T) { }, } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() testCase.initialHTS.adaptWithIPs(testCase.hostToIPs) @@ -206,7 +203,6 @@ func Test_hostToServer_toServersSlice(t *testing.T) { }, } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() servers := testCase.hts.toServersSlice() diff --git a/internal/provider/ipvanish/updater/servers_test.go b/internal/provider/ipvanish/updater/servers_test.go index 71024001..8a0cd6e7 100644 --- a/internal/provider/ipvanish/updater/servers_test.go +++ b/internal/provider/ipvanish/updater/servers_test.go @@ -187,7 +187,6 @@ func Test_Updater_GetServers(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/provider/ivpn/connection_test.go b/internal/provider/ivpn/connection_test.go index 87396d54..f854b7ee 100644 --- a/internal/provider/ivpn/connection_test.go +++ b/internal/provider/ivpn/connection_test.go @@ -88,7 +88,6 @@ func Test_Provider_GetConnection(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/provider/ivpn/updater/api_test.go b/internal/provider/ivpn/updater/api_test.go index ab338303..9472e2a9 100644 --- a/internal/provider/ivpn/updater/api_test.go +++ b/internal/provider/ivpn/updater/api_test.go @@ -63,7 +63,6 @@ func Test_fetchAPI(t *testing.T) { }, } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/provider/ivpn/updater/servers_test.go b/internal/provider/ivpn/updater/servers_test.go index 9bf525bb..1516eead 100644 --- a/internal/provider/ivpn/updater/servers_test.go +++ b/internal/provider/ivpn/updater/servers_test.go @@ -131,7 +131,6 @@ func Test_Updater_GetServers(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/provider/mullvad/connection_test.go b/internal/provider/mullvad/connection_test.go index 1a357755..23f08202 100644 --- a/internal/provider/mullvad/connection_test.go +++ b/internal/provider/mullvad/connection_test.go @@ -88,7 +88,6 @@ func Test_Provider_GetConnection(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/provider/mullvad/updater/ips_test.go b/internal/provider/mullvad/updater/ips_test.go index ae8ec6ab..3b06bb47 100644 --- a/internal/provider/mullvad/updater/ips_test.go +++ b/internal/provider/mullvad/updater/ips_test.go @@ -31,7 +31,6 @@ func Test_uniqueSortedIPs(t *testing.T) { }, } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() outputIPs := uniqueSortedIPs(testCase.inputIPs) diff --git a/internal/provider/perfectprivacy/portforward_test.go b/internal/provider/perfectprivacy/portforward_test.go index 9aae7daa..78c74a49 100644 --- a/internal/provider/perfectprivacy/portforward_test.go +++ b/internal/provider/perfectprivacy/portforward_test.go @@ -21,7 +21,6 @@ func Test_internalIPToPorts(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/provider/privateinternetaccess/portforward_test.go b/internal/provider/privateinternetaccess/portforward_test.go index f1498484..371c9269 100644 --- a/internal/provider/privateinternetaccess/portforward_test.go +++ b/internal/provider/privateinternetaccess/portforward_test.go @@ -43,7 +43,6 @@ func Test_unpackPayload(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() port, token, expiration, err := unpackPayload(testCase.payload) @@ -97,7 +96,6 @@ func Test_replaceInString(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() result := replaceInString(testCase.s, testCase.substitutions) diff --git a/internal/provider/privatevpn/portforward_test.go b/internal/provider/privatevpn/portforward_test.go index 91d69a46..5f476e33 100644 --- a/internal/provider/privatevpn/portforward_test.go +++ b/internal/provider/privatevpn/portforward_test.go @@ -196,7 +196,6 @@ func Test_Provider_PortForward(t *testing.T) { }, } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/provider/slickvpn/updater/website_test.go b/internal/provider/slickvpn/updater/website_test.go index 4efed74a..f99d04fb 100644 --- a/internal/provider/slickvpn/updater/website_test.go +++ b/internal/provider/slickvpn/updater/website_test.go @@ -70,7 +70,6 @@ func Test_fetchServers(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -253,7 +252,6 @@ func Test_parseHTML(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/provider/surfshark/updater/api_test.go b/internal/provider/surfshark/updater/api_test.go index 3eb05ba4..1d3ed986 100644 --- a/internal/provider/surfshark/updater/api_test.go +++ b/internal/provider/surfshark/updater/api_test.go @@ -92,7 +92,6 @@ func Test_addServersFromAPI(t *testing.T) { }, } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -206,7 +205,6 @@ func Test_fetchAPI(t *testing.T) { }, } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/provider/utils/cipher_test.go b/internal/provider/utils/cipher_test.go index a48d06ed..56c13ef2 100644 --- a/internal/provider/utils/cipher_test.go +++ b/internal/provider/utils/cipher_test.go @@ -30,7 +30,6 @@ func Test_CipherLines(t *testing.T) { }, } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/provider/utils/connection_test.go b/internal/provider/utils/connection_test.go index cefe17b3..37fb66f2 100644 --- a/internal/provider/utils/connection_test.go +++ b/internal/provider/utils/connection_test.go @@ -185,7 +185,6 @@ func Test_GetConnection(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/provider/utils/filtering_test.go b/internal/provider/utils/filtering_test.go index 50f919cf..75e733e4 100644 --- a/internal/provider/utils/filtering_test.go +++ b/internal/provider/utils/filtering_test.go @@ -274,7 +274,6 @@ func Test_FilterServers(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -305,7 +304,6 @@ func Test_filterByPossibilities(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() filtered := filterByPossibilities(testCase.value, testCase.possibilities) diff --git a/internal/provider/utils/port_test.go b/internal/provider/utils/port_test.go index 7e90b629..a0e4e5bc 100644 --- a/internal/provider/utils/port_test.go +++ b/internal/provider/utils/port_test.go @@ -115,7 +115,6 @@ func Test_GetPort(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/provider/utils/protocol_test.go b/internal/provider/utils/protocol_test.go index 0a10bb3d..178b033b 100644 --- a/internal/provider/utils/protocol_test.go +++ b/internal/provider/utils/protocol_test.go @@ -46,7 +46,6 @@ func Test_getProtocol(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -123,7 +122,6 @@ func Test_filterByProtocol(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/provider/utils/wireguard_test.go b/internal/provider/utils/wireguard_test.go index 3b79ea61..61303e4d 100644 --- a/internal/provider/utils/wireguard_test.go +++ b/internal/provider/utils/wireguard_test.go @@ -63,7 +63,6 @@ func Test_BuildWireguardSettings(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/provider/vpnsecure/updater/website_test.go b/internal/provider/vpnsecure/updater/website_test.go index 038655e0..7c937032 100644 --- a/internal/provider/vpnsecure/updater/website_test.go +++ b/internal/provider/vpnsecure/updater/website_test.go @@ -79,7 +79,6 @@ func Test_fetchServers(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() ctrl := gomock.NewController(t) @@ -217,7 +216,6 @@ func Test_parseHTML(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/provider/wevpn/connection_test.go b/internal/provider/wevpn/connection_test.go index 22103c49..7011cbfa 100644 --- a/internal/provider/wevpn/connection_test.go +++ b/internal/provider/wevpn/connection_test.go @@ -82,7 +82,6 @@ func Test_Provider_GetConnection(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/provider/windscribe/connection_test.go b/internal/provider/windscribe/connection_test.go index 187a4b18..a4115dfe 100644 --- a/internal/provider/windscribe/connection_test.go +++ b/internal/provider/windscribe/connection_test.go @@ -89,7 +89,6 @@ func Test_Provider_GetConnection(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/publicip/api/multi.go b/internal/publicip/api/multi.go index d9f020c9..be4f375a 100644 --- a/internal/publicip/api/multi.go +++ b/internal/publicip/api/multi.go @@ -35,7 +35,7 @@ func FetchMultiInfo(ctx context.Context, fetcher Fetcher, ips []netip.Addr) ( } results = make([]models.PublicIP, len(ips)) - for i := 0; i < len(ips); i++ { + for range len(ips) { aResult := <-resultsCh if aResult.err != nil { if err == nil { diff --git a/internal/routing/conversion_test.go b/internal/routing/conversion_test.go index a30dfbb5..ad908c84 100644 --- a/internal/routing/conversion_test.go +++ b/internal/routing/conversion_test.go @@ -34,7 +34,6 @@ func Test_netIPToNetipAddress(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/routing/ip_test.go b/internal/routing/ip_test.go index b25d1b3a..62ebbde2 100644 --- a/internal/routing/ip_test.go +++ b/internal/routing/ip_test.go @@ -83,7 +83,6 @@ func Test_ipIsPrivate(t *testing.T) { }, } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/routing/rules_test.go b/internal/routing/rules_test.go index 12f63666..afd5bf8e 100644 --- a/internal/routing/rules_test.go +++ b/internal/routing/rules_test.go @@ -105,7 +105,6 @@ func Test_Routing_addIPRule(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() ctrl := gomock.NewController(t) @@ -223,7 +222,6 @@ func Test_Routing_deleteIPRule(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() ctrl := gomock.NewController(t) @@ -289,7 +287,6 @@ func Test_ruleDbgMsg(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -386,7 +383,6 @@ func Test_rulesAreEqual(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -434,7 +430,6 @@ func Test_ipPrefixesAreEqual(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/server/middlewares/auth/apikey.go b/internal/server/middlewares/auth/apikey.go index f9fd5383..6aa0df2d 100644 --- a/internal/server/middlewares/auth/apikey.go +++ b/internal/server/middlewares/auth/apikey.go @@ -27,7 +27,7 @@ func (a *apiKeyMethod) equal(other authorizationChecker) bool { } func (a *apiKeyMethod) isAuthorized(_ http.Header, request *http.Request) bool { - xAPIKey := request.Header.Get("X-API-Key") + xAPIKey := request.Header.Get("X-API-Key") //nolint:canonicalheader if xAPIKey == "" { xAPIKey = request.URL.Query().Get("api_key") } diff --git a/internal/server/middlewares/auth/configfile_test.go b/internal/server/middlewares/auth/configfile_test.go index 4dcc3009..77101799 100644 --- a/internal/server/middlewares/auth/configfile_test.go +++ b/internal/server/middlewares/auth/configfile_test.go @@ -57,7 +57,6 @@ routes = ["GET /v1/vpn/status"] } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/server/middlewares/auth/lookup_test.go b/internal/server/middlewares/auth/lookup_test.go index 225f7f8c..3812daa4 100644 --- a/internal/server/middlewares/auth/lookup_test.go +++ b/internal/server/middlewares/auth/lookup_test.go @@ -44,7 +44,6 @@ func Test_settingsToLookupMap(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/server/middlewares/auth/middleware_test.go b/internal/server/middlewares/auth/middleware_test.go index 5f9f75cc..d8f72707 100644 --- a/internal/server/middlewares/auth/middleware_test.go +++ b/internal/server/middlewares/auth/middleware_test.go @@ -80,7 +80,6 @@ func Test_authHandler_ServeHTTP(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/storage/copy_test.go b/internal/storage/copy_test.go index 0b5004a9..bea568d2 100644 --- a/internal/storage/copy_test.go +++ b/internal/storage/copy_test.go @@ -47,7 +47,6 @@ func Test_copyIPs(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/storage/read_test.go b/internal/storage/read_test.go index 5e540d43..60e70efe 100644 --- a/internal/storage/read_test.go +++ b/internal/storage/read_test.go @@ -91,7 +91,6 @@ func Test_extractServersFromBytes(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/updater/html/fetch_test.go b/internal/updater/html/fetch_test.go index a80abcd2..a78d06d3 100644 --- a/internal/updater/html/fetch_test.go +++ b/internal/updater/html/fetch_test.go @@ -63,7 +63,6 @@ func Test_Fetch(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/updater/resolver/ips_test.go b/internal/updater/resolver/ips_test.go index b2832af7..f80125de 100644 --- a/internal/updater/resolver/ips_test.go +++ b/internal/updater/resolver/ips_test.go @@ -31,7 +31,6 @@ func Test_uniqueIPsToSlice(t *testing.T) { }, } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() outputIPs := uniqueIPsToSlice(testCase.inputIPs) diff --git a/internal/wireguard/address_test.go b/internal/wireguard/address_test.go index 03c4d1c8..d1851160 100644 --- a/internal/wireguard/address_test.go +++ b/internal/wireguard/address_test.go @@ -94,7 +94,6 @@ func Test_Wireguard_addAddresses(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/wireguard/config_test.go b/internal/wireguard/config_test.go index c50ba9ef..dfa24620 100644 --- a/internal/wireguard/config_test.go +++ b/internal/wireguard/config_test.go @@ -93,7 +93,6 @@ func Test_makeDeviceConfig(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/wireguard/constructor_test.go b/internal/wireguard/constructor_test.go index 28409cd0..8ca2b89c 100644 --- a/internal/wireguard/constructor_test.go +++ b/internal/wireguard/constructor_test.go @@ -61,7 +61,6 @@ func Test_New(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/wireguard/route_test.go b/internal/wireguard/route_test.go index b95a9cc4..57e48afa 100644 --- a/internal/wireguard/route_test.go +++ b/internal/wireguard/route_test.go @@ -57,7 +57,6 @@ func Test_Wireguard_addRoute(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/wireguard/rule_test.go b/internal/wireguard/rule_test.go index b883d39a..52eb1464 100644 --- a/internal/wireguard/rule_test.go +++ b/internal/wireguard/rule_test.go @@ -61,7 +61,6 @@ func Test_Wireguard_addRule(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/wireguard/settings_test.go b/internal/wireguard/settings_test.go index 4d736359..a0fb4923 100644 --- a/internal/wireguard/settings_test.go +++ b/internal/wireguard/settings_test.go @@ -64,7 +64,6 @@ func Test_Settings_SetDefaults(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -293,7 +292,6 @@ func Test_Settings_Check(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -434,7 +432,6 @@ func Test_Settings_Lines(t *testing.T) { } for name, testCase := range testCases { - testCase := testCase t.Run(name, func(t *testing.T) { t.Parallel()