From 37f0e5c73b7b312fc93c38541087f93698633d94 Mon Sep 17 00:00:00 2001 From: Quentin McGaw Date: Thu, 8 Jun 2023 07:21:12 +0000 Subject: [PATCH] chore(lint): add linters `dupword`, `paralleltest` and `gocheckcompilerdirectives` --- .golangci.yml | 3 +++ internal/openvpn/extract/extract.go | 2 +- internal/openvpn/extract/extract_test.go | 8 ++++---- internal/provider/custom/openvpnconf_test.go | 4 ++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index a3bf8465..6ce69536 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -46,6 +46,7 @@ linters: - decorder - dogsled - dupl + - dupword - durationcheck - errchkjson - errname @@ -54,6 +55,7 @@ linters: - exportloopref - forcetypeassert - gci + - gocheckcompilerdirectives - gochecknoglobals - gochecknoinits - gocognit @@ -83,6 +85,7 @@ linters: - noctx - nolintlint - nosprintfhostport + - paralleltest - prealloc - predeclared - promlinter diff --git a/internal/openvpn/extract/extract.go b/internal/openvpn/extract/extract.go index c3ef47bd..c79b8ad3 100644 --- a/internal/openvpn/extract/extract.go +++ b/internal/openvpn/extract/extract.go @@ -91,7 +91,7 @@ func extractProto(line string) (protocol string, err error) { var ( errRemoteLineFieldsCount = errors.New("remote line has not 2 fields as expected") - errHostNotIP = errors.New("host is not an an IP address") + errHostNotIP = errors.New("host is not an IP address") errPortNotValid = errors.New("port is not valid") ) diff --git a/internal/openvpn/extract/extract_test.go b/internal/openvpn/extract/extract_test.go index a38d6a6e..34a91b2e 100644 --- a/internal/openvpn/extract/extract_test.go +++ b/internal/openvpn/extract/extract_test.go @@ -20,7 +20,7 @@ func Test_extractDataFromLines(t *testing.T) { err error }{ "success": { - lines: []string{"bla bla", "proto tcp", "remote 1.2.3.4 1194 tcp", "dev tun6"}, + lines: []string{"bla", "proto tcp", "remote 1.2.3.4 1194 tcp", "dev tun6"}, connection: models.Connection{ IP: netip.AddrFrom4([4]byte{1, 2, 3, 4}), Port: 1194, @@ -28,7 +28,7 @@ func Test_extractDataFromLines(t *testing.T) { }, }, "extraction error": { - lines: []string{"bla bla", "proto bad", "remote 1.2.3.4 1194 tcp"}, + lines: []string{"bla", "proto bad", "remote 1.2.3.4 1194 tcp"}, err: errors.New("on line 2: extracting protocol from proto line: network protocol not supported: bad"), }, "only use first values found": { @@ -94,7 +94,7 @@ func Test_extractDataFromLine(t *testing.T) { isErr error }{ "irrelevant line": { - line: "bla bla", + line: "bla", }, "extract proto error": { line: "proto bad", @@ -201,7 +201,7 @@ func Test_extractRemote(t *testing.T) { }, "host is not an IP": { line: "remote somehost.com", - err: errors.New("host is not an an IP address: somehost.com"), + err: errors.New("host is not an IP address: somehost.com"), }, "only IP host": { line: "remote 1.2.3.4", diff --git a/internal/provider/custom/openvpnconf_test.go b/internal/provider/custom/openvpnconf_test.go index 796219e6..e3d7178c 100644 --- a/internal/provider/custom/openvpnconf_test.go +++ b/internal/provider/custom/openvpnconf_test.go @@ -39,7 +39,7 @@ func Test_modifyConfig(t *testing.T) { settings: settings.OpenVPN{ User: stringPtr("user"), Ciphers: []string{"cipher"}, - Auth: stringPtr("auth"), + Auth: stringPtr("sha512"), MSSFix: uint16Ptr(1000), ProcessUser: "procuser", Interface: "tun3", @@ -66,7 +66,7 @@ func Test_modifyConfig(t *testing.T) { "verb 0", "data-ciphers-fallback cipher", "data-ciphers cipher", - "auth auth", + "auth sha512", "mssfix 1000", "pull-filter ignore \"route-ipv6\"", "pull-filter ignore \"ifconfig-ipv6\"",