diff --git a/.golangci.yaml b/.golangci.yaml index 3f1cd9b..be6dd8e 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -3,6 +3,8 @@ linters: enable-all: true disable: - 'depguard' + - 'mnd' + - 'nlreturn' - 'tagliatelle' # Temporary @@ -21,11 +23,7 @@ linters: - 'gosec' - 'lll' - 'maintidx' - - 'mnd' - 'nestif' - - 'nlreturn' - - 'paralleltest' - - 'perfsprint' - 'revive' - 'stylecheck' - 'varnamelen' diff --git a/fields/extract.go b/fields/extract.go index 4481ebf..962d21f 100644 --- a/fields/extract.go +++ b/fields/extract.go @@ -54,7 +54,7 @@ func downloadJar(url *url.URL, outputDir string) (string, error) { } } if uncompressedReader == nil { - return "", fmt.Errorf("unable to find .deb data file") + return "", errors.New("unable to find .deb data file") } tarReader := tar.NewReader(uncompressedReader) @@ -86,7 +86,7 @@ func downloadJar(url *url.URL, outputDir string) (string, error) { } if aceJar == nil { - return "", fmt.Errorf("unable to find ace.jar") + return "", errors.New("unable to find ace.jar") } defer aceJar.Close() diff --git a/fields/main_test.go b/fields/main_test.go index e6fddb2..80ef045 100644 --- a/fields/main_test.go +++ b/fields/main_test.go @@ -9,6 +9,8 @@ import ( ) func TestFieldInfoFromValidation(t *testing.T) { + t.Parallel() + for i, c := range []struct { expectedType string expectedComment string @@ -32,6 +34,8 @@ func TestFieldInfoFromValidation(t *testing.T) { {"bool", "", false, "true|false"}, } { t.Run(fmt.Sprintf("%d %s %s", i, c.expectedType, c.validation), func(t *testing.T) { + t.Parallel() + resource := &Resource{ StructName: "TestType", Types: make(map[string]*FieldInfo), @@ -57,6 +61,8 @@ func TestFieldInfoFromValidation(t *testing.T) { } func TestResourceTypes(t *testing.T) { + t.Parallel() + testData := ` { "note": ".{0,1024}", @@ -147,6 +153,8 @@ func TestResourceTypes(t *testing.T) { } t.Run("structural test", func(t *testing.T) { + t.Parallel() + resource := NewResource("Struct", "path") resource.FieldProcessor = expectation.FieldProcessor diff --git a/fields/version_test.go b/fields/version_test.go index f2b7b7f..9637a98 100644 --- a/fields/version_test.go +++ b/fields/version_test.go @@ -13,6 +13,8 @@ import ( ) func TestLatestUnifiVersion(t *testing.T) { + t.Parallel() + assert := assert.New(t) require := require.New(t) diff --git a/unifi/account_test.go b/unifi/account_test.go index 6c1b4d6..4b6b8e7 100644 --- a/unifi/account_test.go +++ b/unifi/account_test.go @@ -9,6 +9,8 @@ import ( ) func TestAccountMarshalJSON(t *testing.T) { + t.Parallel() + for n, c := range map[string]struct { expectedJSON string acc unifi.Account @@ -27,6 +29,8 @@ func TestAccountMarshalJSON(t *testing.T) { }, } { t.Run(n, func(t *testing.T) { + t.Parallel() + actual, err := json.Marshal(&c.acc) if err != nil { t.Fatal(err) diff --git a/unifi/network_test.go b/unifi/network_test.go index 578343e..d83973b 100644 --- a/unifi/network_test.go +++ b/unifi/network_test.go @@ -9,6 +9,8 @@ import ( ) func TestNetworkUnmarshalJSON(t *testing.T) { + t.Parallel() + for n, c := range map[string]struct { expected func(n *unifi.Network) json string @@ -66,6 +68,8 @@ func TestNetworkUnmarshalJSON(t *testing.T) { }, } { t.Run(n, func(t *testing.T) { + t.Parallel() + // set some non-zero value defaults expected := unifi.Network{ InternetAccessEnabled: true, diff --git a/unifi/unifi.go b/unifi/unifi.go index 45cd996..41b7748 100644 --- a/unifi/unifi.go +++ b/unifi/unifi.go @@ -1,9 +1,10 @@ -package unifi // +package unifi import ( "bytes" "context" "encoding/json" + "errors" "fmt" "io" "net/http" @@ -183,7 +184,7 @@ func (c *Client) Login(ctx context.Context, user, pass string) error { c.version = si.Version if c.version == "" { - return fmt.Errorf("unable to determine controller version") + return errors.New("unable to determine controller version") } return nil diff --git a/unifi/user.go b/unifi/user.go index 06106c5..b939c8c 100644 --- a/unifi/user.go +++ b/unifi/user.go @@ -2,6 +2,7 @@ package unifi import ( "context" + "errors" "fmt" ) @@ -54,7 +55,7 @@ func (c *Client) CreateUser(ctx context.Context, site string, d *User) (*User, e } if len(respBody.Data) != 1 { - return nil, fmt.Errorf("malformed group response") + return nil, errors.New("malformed group response") } if err := respBody.Data[0].Meta.error(); err != nil {