chore(lint): add linters dupword, paralleltest and gocheckcompilerdirectives

This commit is contained in:
Quentin McGaw
2023-06-08 07:21:12 +00:00
parent a9cd7be3f9
commit 37f0e5c73b
4 changed files with 10 additions and 7 deletions

View File

@@ -46,6 +46,7 @@ linters:
- decorder - decorder
- dogsled - dogsled
- dupl - dupl
- dupword
- durationcheck - durationcheck
- errchkjson - errchkjson
- errname - errname
@@ -54,6 +55,7 @@ linters:
- exportloopref - exportloopref
- forcetypeassert - forcetypeassert
- gci - gci
- gocheckcompilerdirectives
- gochecknoglobals - gochecknoglobals
- gochecknoinits - gochecknoinits
- gocognit - gocognit
@@ -83,6 +85,7 @@ linters:
- noctx - noctx
- nolintlint - nolintlint
- nosprintfhostport - nosprintfhostport
- paralleltest
- prealloc - prealloc
- predeclared - predeclared
- promlinter - promlinter

View File

@@ -91,7 +91,7 @@ func extractProto(line string) (protocol string, err error) {
var ( var (
errRemoteLineFieldsCount = errors.New("remote line has not 2 fields as expected") 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") errPortNotValid = errors.New("port is not valid")
) )

View File

@@ -20,7 +20,7 @@ func Test_extractDataFromLines(t *testing.T) {
err error err error
}{ }{
"success": { "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{ connection: models.Connection{
IP: netip.AddrFrom4([4]byte{1, 2, 3, 4}), IP: netip.AddrFrom4([4]byte{1, 2, 3, 4}),
Port: 1194, Port: 1194,
@@ -28,7 +28,7 @@ func Test_extractDataFromLines(t *testing.T) {
}, },
}, },
"extraction error": { "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"), err: errors.New("on line 2: extracting protocol from proto line: network protocol not supported: bad"),
}, },
"only use first values found": { "only use first values found": {
@@ -94,7 +94,7 @@ func Test_extractDataFromLine(t *testing.T) {
isErr error isErr error
}{ }{
"irrelevant line": { "irrelevant line": {
line: "bla bla", line: "bla",
}, },
"extract proto error": { "extract proto error": {
line: "proto bad", line: "proto bad",
@@ -201,7 +201,7 @@ func Test_extractRemote(t *testing.T) {
}, },
"host is not an IP": { "host is not an IP": {
line: "remote somehost.com", 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": { "only IP host": {
line: "remote 1.2.3.4", line: "remote 1.2.3.4",

View File

@@ -39,7 +39,7 @@ func Test_modifyConfig(t *testing.T) {
settings: settings.OpenVPN{ settings: settings.OpenVPN{
User: stringPtr("user"), User: stringPtr("user"),
Ciphers: []string{"cipher"}, Ciphers: []string{"cipher"},
Auth: stringPtr("auth"), Auth: stringPtr("sha512"),
MSSFix: uint16Ptr(1000), MSSFix: uint16Ptr(1000),
ProcessUser: "procuser", ProcessUser: "procuser",
Interface: "tun3", Interface: "tun3",
@@ -66,7 +66,7 @@ func Test_modifyConfig(t *testing.T) {
"verb 0", "verb 0",
"data-ciphers-fallback cipher", "data-ciphers-fallback cipher",
"data-ciphers cipher", "data-ciphers cipher",
"auth auth", "auth sha512",
"mssfix 1000", "mssfix 1000",
"pull-filter ignore \"route-ipv6\"", "pull-filter ignore \"route-ipv6\"",
"pull-filter ignore \"ifconfig-ipv6\"", "pull-filter ignore \"ifconfig-ipv6\"",