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
- 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

View File

@@ -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")
)

View File

@@ -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",

View File

@@ -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\"",