diff --git a/.golangci.yml b/.golangci.yml index 0fac662e..1be17acc 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -16,7 +16,6 @@ issues: - should not use underscores in package names # EXC0002 golint: Annoying issue about not having a comment. The rare codebase has such comments - (comment on exported (method|function|type|const)|should have( a package)? comment|comment should be of the form) - - (struct (of|with)|could be) exclude-use-default: false exclude-rules: # exclude linters impossible to exclude via //nolint - path: ^kentikapi/models/enum_ # these files are generated and shouldn't be edited with //nolint @@ -28,20 +27,20 @@ issues: # Disabled linters: # - cyclop - duplicates functionality of gocyclo # - exhaustivestruct - breaks "Make the zero value useful" proverb, meant to be used only for special cases -# - funlen - only test functions exceeds the line limit of 60 - too strict, these functions are easily readable +# - funlen - not needed - gocyclo ensures that functions complexity is not too high # - godox - requires all TODOs to be removed - too strict +# - golint - deprecated (since v1.41.0) due to: The repository of the linter has been archived by the owner # - gomoddirectives - does not allow "replace" directives - too strict # - goerr113 - following check is too strict: "do not define dynamic errors, use wrapped static errors instead", # the check cannot be disabled # - interfacer - deprecated (since v1.38.0) due to: The repository of the linter has been archived by the owner # - maligned - deprecated (since v1.38.0) due to: The repository of the linter has been archived by the owner # - nlreturn - leads to using too many line breaks -# - prealloc - from docs: - # XXX: we don't recommend using this linter before doing performance profiling. - # For most programs usage of prealloc will be a premature optimization. +# - paralleltest - premature optimization +# - prealloc - considered a premature optimization. # - scopelint - deprecated (since v1.39.0) due to: The repository of the linter has been deprecated by the owner # - thelper - enforcing t.Helper() everywhere is too strict -# - wrapcheck - valuable linter which I think needs higher level knowledge on the project to be fixed +# - wrapcheck - valuable linter, TODO: ignore false-positives (interfaces, internal imports) and adjust the code to comply # - wsl - leads to using too many line breaks linters: enable: @@ -70,7 +69,6 @@ linters: - gofumpt - goheader - goimports - - revive - gomnd - gomodguard - goprintffuncname @@ -88,7 +86,6 @@ linters: - nilerr - noctx - nolintlint - - paralleltest - predeclared - revive - rowserrcheck @@ -107,8 +104,6 @@ linters: - whitespace linters-settings: - dupl: - tests: false errcheck: check-type-assertions: true check-blank: true @@ -116,15 +111,14 @@ linters-settings: # Check whether fmt.Errorf uses the %w verb for formatting errors - too strict errorf: false gocyclo: - min-complexity: 11 - golint: - min-confidence: 0 - gosec: - tests: false + min-complexity: 10 govet: + disable: + # Reordering struct fields may decrease readability + - fieldalignment enable-all: true lll: - # lines longer than 127 will be reported, 120 is default + # TODO: 120 (default) should be achieved to increase comfort of window split view line-length: 127 nakedret: max-func-lines: 5 \ No newline at end of file diff --git a/apiv6/examples/cloud_export/main.go b/apiv6/examples/cloud_export/main.go index 73a6673c..66000e2c 100644 --- a/apiv6/examples/cloud_export/main.go +++ b/apiv6/examples/cloud_export/main.go @@ -40,7 +40,7 @@ func runCRUD(client *kentikapi.Client) error { createReqPayload := *cloudexport.NewV202101beta1CreateCloudExportRequest() createReqPayload.Export = export - createResp, httpResp, err := client.CloudExportAdminServiceApi. + createResp, httpResp, err := client.CloudExportAdminServiceAPI. ExportCreate(context.Background()). Body(createReqPayload). Execute() @@ -57,7 +57,7 @@ func runCRUD(client *kentikapi.Client) error { updateReqPayload := *cloudexport.NewV202101beta1UpdateCloudExportRequest() updateReqPayload.Export = created - updateResp, httpResp, err := client.CloudExportAdminServiceApi. + updateResp, httpResp, err := client.CloudExportAdminServiceAPI. ExportUpdate(context.Background(), *created.Id). Body(updateReqPayload). Execute() @@ -68,7 +68,7 @@ func runCRUD(client *kentikapi.Client) error { fmt.Println() fmt.Println("### GET") - getResp, httpResp, err := client.CloudExportAdminServiceApi. + getResp, httpResp, err := client.CloudExportAdminServiceAPI. ExportGet(context.Background(), *created.Id). Execute() if err != nil { @@ -78,7 +78,7 @@ func runCRUD(client *kentikapi.Client) error { fmt.Println() fmt.Println("### DELETE") - deleteResp, httpResp, err := client.CloudExportAdminServiceApi. + deleteResp, httpResp, err := client.CloudExportAdminServiceAPI. ExportDelete(context.Background(), *created.Id). Execute() if err != nil { @@ -93,7 +93,7 @@ func runCRUD(client *kentikapi.Client) error { func runGetAll(client *kentikapi.Client) error { fmt.Println("### GET ALL") - getAllResp, httpResp, err := client.CloudExportAdminServiceApi. + getAllResp, httpResp, err := client.CloudExportAdminServiceAPI. ExportList(context.Background()). Execute() if err != nil { diff --git a/apiv6/examples/demos/cloud_export_demo/main.go b/apiv6/examples/demos/cloud_export_demo/main.go index 935cbdb7..e7989801 100644 --- a/apiv6/examples/demos/cloud_export_demo/main.go +++ b/apiv6/examples/demos/cloud_export_demo/main.go @@ -43,7 +43,7 @@ func createCloudExport(client *kentikapi.Client) string { createReqPayload := *cloudexport.NewV202101beta1CreateCloudExportRequest() createReqPayload.Export = export - createResp, _, err := client.CloudExportAdminServiceApi. + createResp, _, err := client.CloudExportAdminServiceAPI. ExportCreate(context.Background()). Body(createReqPayload). Execute() @@ -56,7 +56,7 @@ func createCloudExport(client *kentikapi.Client) string { func getCloudExport(client *kentikapi.Client, id string) *cloudexport.V202101beta1CloudExport { fmt.Printf("Retrieving cloud export of ID = %s\n", id) - getResp, _, err := client.CloudExportAdminServiceApi. + getResp, _, err := client.CloudExportAdminServiceAPI. ExportGet(context.Background(), id). Execute() demos.ExitOnError(err) @@ -70,7 +70,7 @@ func updateCloudExport(client *kentikapi.Client, export *cloudexport.V202101beta updateReqPayload := *cloudexport.NewV202101beta1UpdateCloudExportRequest() updateReqPayload.Export = export - updateResp, _, err := client.CloudExportAdminServiceApi. + updateResp, _, err := client.CloudExportAdminServiceAPI. ExportUpdate(context.Background(), *export.Id). Body(updateReqPayload). Execute() @@ -81,7 +81,7 @@ func updateCloudExport(client *kentikapi.Client, export *cloudexport.V202101beta func deleteCloudExport(client *kentikapi.Client, id string) { fmt.Printf("Deleting cloud export of ID = %s\n", id) - deleteResp, _, err := client.CloudExportAdminServiceApi. + deleteResp, _, err := client.CloudExportAdminServiceAPI. ExportDelete(context.Background(), id). Execute() demos.ExitOnError(err) @@ -91,7 +91,7 @@ func deleteCloudExport(client *kentikapi.Client, id string) { } func getAllCloudExports(client *kentikapi.Client) { - getAllResp, _, err := client.CloudExportAdminServiceApi. + getAllResp, _, err := client.CloudExportAdminServiceAPI. ExportList(context.Background()). Execute() demos.ExitOnError(err) diff --git a/apiv6/examples/demos/retry_demo/main.go b/apiv6/examples/demos/retry_demo/main.go index 70892e6b..064b6183 100644 --- a/apiv6/examples/demos/retry_demo/main.go +++ b/apiv6/examples/demos/retry_demo/main.go @@ -53,7 +53,7 @@ func showRetryingOnMultipleCodes() error { }) demos.Step("List synthetic agents") - result, _, err := c.SyntheticsAdminServiceApi. + result, _, err := c.SyntheticsAdminServiceAPI. AgentsList(context.Background()). Execute() diff --git a/apiv6/examples/synthetics/main.go b/apiv6/examples/synthetics/main.go index 39af9857..52f587fe 100644 --- a/apiv6/examples/synthetics/main.go +++ b/apiv6/examples/synthetics/main.go @@ -64,7 +64,7 @@ func runCRUDTest(client *kentikapi.Client) error { createReqPayload := *synthetics.NewV202101beta1CreateTestRequest() createReqPayload.SetTest(*test) - createResp, httpResp, err := client.SyntheticsAdminServiceApi. + createResp, httpResp, err := client.SyntheticsAdminServiceAPI. TestCreate(context.Background()). Body(createReqPayload). Execute() @@ -82,7 +82,7 @@ func runCRUDTest(client *kentikapi.Client) error { setStatusReqPayload.Status = &status setStatusReqPayload.Id = &testID - statusResp, httpResp, err := client.SyntheticsAdminServiceApi. + statusResp, httpResp, err := client.SyntheticsAdminServiceAPI. TestStatusUpdate(context.Background(), testID). Body(setStatusReqPayload). Execute() @@ -94,7 +94,7 @@ func runCRUDTest(client *kentikapi.Client) error { fmt.Println() fmt.Println("### GET TEST") - getReq := client.SyntheticsAdminServiceApi.TestGet(context.Background(), testID) + getReq := client.SyntheticsAdminServiceAPI.TestGet(context.Background(), testID) getResp, httpResp, err := getReq.Execute() if err != nil { return fmt.Errorf("%v %v", err, httpResp) @@ -112,7 +112,7 @@ func runCRUDTest(client *kentikapi.Client) error { patchReqPayload.SetTest(*test) patchReqPayload.SetMask("test.name") - patchResp, httpResp, err := client.SyntheticsAdminServiceApi. + patchResp, httpResp, err := client.SyntheticsAdminServiceAPI. TestPatch(context.Background(), *test.Id). Body(patchReqPayload). Execute() @@ -123,7 +123,7 @@ func runCRUDTest(client *kentikapi.Client) error { fmt.Println() fmt.Println("### DELETE TEST") - deleteReq := client.SyntheticsAdminServiceApi.TestDelete(context.Background(), testID) + deleteReq := client.SyntheticsAdminServiceAPI.TestDelete(context.Background(), testID) deleteResp, httpResp, err := deleteReq.Execute() if err != nil { return fmt.Errorf("%v %v", err, httpResp) @@ -138,7 +138,7 @@ func runCRUDTest(client *kentikapi.Client) error { func runListTests(client *kentikapi.Client) error { fmt.Println("### LIST TESTS") - getAllReq := client.SyntheticsAdminServiceApi.TestsList(context.Background()) + getAllReq := client.SyntheticsAdminServiceAPI.TestsList(context.Background()) getAllResp, httpResp, err := getAllReq.Execute() if err != nil { return fmt.Errorf("%v %v", err, httpResp) @@ -167,7 +167,7 @@ func runGetHealthForTests(client *kentikapi.Client, testIDs []string) error { healthPayload.SetEndTime(time.Now()) healthPayload.SetIds(testIDs) - getHealthResp, httpResp, err := client.SyntheticsDataServiceApi. + getHealthResp, httpResp, err := client.SyntheticsDataServiceAPI. GetHealthForTests(context.Background()). Body(healthPayload). Execute() @@ -195,7 +195,7 @@ func runGetTraceForTest(client *kentikapi.Client, testID string) error { tracePayload.SetStartTime(time.Now().Add(-time.Hour)) tracePayload.SetEndTime(time.Now()) - getTraceResp, httpResp, err := client.SyntheticsDataServiceApi. + getTraceResp, httpResp, err := client.SyntheticsDataServiceAPI. GetTraceForTest(context.Background(), testID). Body(tracePayload). Execute() @@ -230,7 +230,7 @@ func runCRUDAgent(client *kentikapi.Client) error { agentID := "1717" fmt.Println("### GET AGENT") - getReq := client.SyntheticsAdminServiceApi.AgentGet(context.Background(), agentID) + getReq := client.SyntheticsAdminServiceAPI.AgentGet(context.Background(), agentID) getResp, httpResp, err := getReq.Execute() if err != nil { return fmt.Errorf("%v %v", err, httpResp) @@ -249,7 +249,7 @@ func runCRUDAgent(client *kentikapi.Client) error { patchReqPayload.SetAgent(agent) patchReqPayload.SetMask("agent.family") - patchResp, httpResp, err := client.SyntheticsAdminServiceApi. + patchResp, httpResp, err := client.SyntheticsAdminServiceAPI. AgentPatch(context.Background(), agentID). Body(patchReqPayload). Execute() @@ -261,7 +261,7 @@ func runCRUDAgent(client *kentikapi.Client) error { // NOTE: as we can't create agents through the API - let's not delete them // fmt.Println("### DELETE AGENT") - // deleteReq := client.SyntheticsAdminServiceApi.AgentDelete(context.Background(), agentID) + // deleteReq := client.SyntheticsAdminServiceAPI.AgentDelete(context.Background(), agentID) // deleteResp, httpResp, err := deleteReq.Execute() // if err != nil { // return fmt.Errorf("%v %v", err, httpResp) @@ -276,7 +276,7 @@ func runCRUDAgent(client *kentikapi.Client) error { func runListAgents(client *kentikapi.Client) error { fmt.Println("### LIST AGENTS") - getAllReq := client.SyntheticsAdminServiceApi.AgentsList(context.Background()) + getAllReq := client.SyntheticsAdminServiceAPI.AgentsList(context.Background()) getAllResp, httpResp, err := getAllReq.Execute() if err != nil { return fmt.Errorf("%v %v", err, httpResp) diff --git a/apiv6/examples/synthetics/mesh_test/main.go b/apiv6/examples/synthetics/mesh_test/main.go index f34fffb8..774d047d 100644 --- a/apiv6/examples/synthetics/mesh_test/main.go +++ b/apiv6/examples/synthetics/mesh_test/main.go @@ -37,7 +37,7 @@ func getMeshTestResults(testID string) *[]synthetics.V202101beta1MeshResponse { healthPayload.SetIds([]string{testID}) healthPayload.SetAugment(true) // if not set, returned Mesh pointer will be empty - getHealthResp, httpResp, err := client.SyntheticsDataServiceApi. + getHealthResp, httpResp, err := client.SyntheticsDataServiceAPI. GetHealthForTests(context.Background()). Body(healthPayload). Execute() diff --git a/apiv6/kentikapi/client.go b/apiv6/kentikapi/client.go index 95e16411..bcd13f0a 100644 --- a/apiv6/kentikapi/client.go +++ b/apiv6/kentikapi/client.go @@ -1,4 +1,3 @@ -//nolint:revive,stylecheck // Changing Api to API forces changes in generated files package kentikapi import ( @@ -18,11 +17,11 @@ const ( // Client is the root object for manipulating all the Kentik API resources. type Client struct { // cloudexport - CloudExportAdminServiceApi *cloudexport.CloudExportAdminServiceApiService + CloudExportAdminServiceAPI *cloudexport.CloudExportAdminServiceApiService // synthetics - SyntheticsAdminServiceApi *synthetics.SyntheticsAdminServiceApiService - SyntheticsDataServiceApi *synthetics.SyntheticsDataServiceApiService + SyntheticsAdminServiceAPI *synthetics.SyntheticsAdminServiceApiService + SyntheticsDataServiceAPI *synthetics.SyntheticsDataServiceApiService } // Config holds configuration of the Client. @@ -54,9 +53,9 @@ func NewClient(c Config) *Client { syntheticsClient := synthetics.NewAPIClient(makeSyntheticsConfig(c)) return &Client{ - CloudExportAdminServiceApi: cloudexportClient.CloudExportAdminServiceApi, - SyntheticsAdminServiceApi: syntheticsClient.SyntheticsAdminServiceApi, - SyntheticsDataServiceApi: syntheticsClient.SyntheticsDataServiceApi, + CloudExportAdminServiceAPI: cloudexportClient.CloudExportAdminServiceApi, + SyntheticsAdminServiceAPI: syntheticsClient.SyntheticsAdminServiceApi, + SyntheticsDataServiceAPI: syntheticsClient.SyntheticsDataServiceApi, } } diff --git a/apiv6/kentikapi/client_integration_test.go b/apiv6/kentikapi/client_integration_test.go index 4c0029ba..8099460e 100644 --- a/apiv6/kentikapi/client_integration_test.go +++ b/apiv6/kentikapi/client_integration_test.go @@ -25,10 +25,7 @@ const ( testAgentID = "968" ) -//nolint:errcheck // Conflict with defer Close() (additional info: https://github.com/kisielk/errcheck/issues/55) func TestClient_PatchAgent(t *testing.T) { - t.Parallel() - tests := []struct { name string retryMax *int @@ -164,10 +161,7 @@ func TestClient_PatchAgent(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { - t.Parallel() - // arrange h := newSpyHTTPHandler(t, tt.responses) s := httptest.NewServer(h) @@ -188,10 +182,11 @@ func TestClient_PatchAgent(t *testing.T) { }) // act - result, httpResp, err := c.SyntheticsAdminServiceApi. + result, httpResp, err := c.SyntheticsAdminServiceAPI. AgentPatch(context.Background(), testAgentID). Body(tt.request). Execute() + //nolint:errcheck // Additional info: https://github.com/kisielk/errcheck/issues/55 defer httpResp.Body.Close() // assert diff --git a/apiv6/kentikapi/httputil/httputil_test.go b/apiv6/kentikapi/httputil/httputil_test.go index 7e434207..888bfec3 100644 --- a/apiv6/kentikapi/httputil/httputil_test.go +++ b/apiv6/kentikapi/httputil/httputil_test.go @@ -22,11 +22,7 @@ import ( // 4. retryingClient.retryableRoundTripper.retryableClient.httpClient.Do() // 5. retryingClient.retryableRoundTripper.retryableClient.httpClient.httpTransport.RoundTrip() -//nolint:errcheck // https://github.com/kisielk/errcheck/issues/55 -// Closing a response you only read from cannot yield a meaningful error. func TestRetryingClient_Do_ReturnsHTTPTransportError(t *testing.T) { - t.Parallel() - // arrange c := httputil.NewRetryingClient(httputil.ClientConfig{}) @@ -35,9 +31,7 @@ func TestRetryingClient_Do_ReturnsHTTPTransportError(t *testing.T) { // act resp, err := c.Do(req.WithContext(context.Background())) - if err != nil { - return - } + //nolint:errcheck,staticcheck // https://github.com/kisielk/errcheck/issues/55 defer resp.Body.Close() // assert @@ -48,11 +42,7 @@ func TestRetryingClient_Do_ReturnsHTTPTransportError(t *testing.T) { assert.Equal(t, "no such host", dnsErr.Err) } -//nolint:errcheck // https://github.com/kisielk/errcheck/issues/55 -// Closing a response you only read from cannot yield a meaningful error. func TestRetryingClientWithSpyHTTPTransport_Do(t *testing.T) { - t.Parallel() - const retryMax = 5 tests := []struct { @@ -85,10 +75,7 @@ func TestRetryingClientWithSpyHTTPTransport_Do(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { - t.Parallel() - // arrange st := spyTransport{transportError: tt.transportError} c := httputil.NewRetryingClient(httputil.ClientConfig{ @@ -107,9 +94,7 @@ func TestRetryingClientWithSpyHTTPTransport_Do(t *testing.T) { // act resp, err := c.Do(req.WithContext(context.Background())) - if err != nil { - return - } + //nolint:errcheck,staticcheck // https://github.com/kisielk/errcheck/issues/55 defer resp.Body.Close() // assert diff --git a/examples/custom_applications_example_test.go b/examples/custom_applications_example_test.go index 3ee20525..6941d013 100644 --- a/examples/custom_applications_example_test.go +++ b/examples/custom_applications_example_test.go @@ -12,8 +12,6 @@ import ( ) func TestCustomApplicationsAPIExample(t *testing.T) { - t.Parallel() - assert := assert.New(t) assert.NoError(runCRUDCustomApplications()) assert.NoError(runGetAllCustomApplications()) diff --git a/kentikapi/internal/api_payloads/query_test.go b/kentikapi/internal/api_payloads/query_test.go index 631daeab..6532ec65 100644 --- a/kentikapi/internal/api_payloads/query_test.go +++ b/kentikapi/internal/api_payloads/query_test.go @@ -12,8 +12,6 @@ import ( ) func TestQueryChartResponsePNGToQueryChartResult(t *testing.T) { - t.Parallel() - // arrange data := "ImagePNGEncodedBase64str" decodedData := base64Decode(t, data) @@ -29,8 +27,6 @@ func TestQueryChartResponsePNGToQueryChartResult(t *testing.T) { } func TestQueryChartResponseJPEGToQueryChartResult(t *testing.T) { - t.Parallel() - // arrange data := "ImageJPGEncodedBase64str" decodedData := base64Decode(t, data) @@ -46,8 +42,6 @@ func TestQueryChartResponseJPEGToQueryChartResult(t *testing.T) { } func TestQueryChartResponseSVGToQueryChartResult(t *testing.T) { - t.Parallel() - // arrange data := "ImageSVGEncodedBase64str" decodedData := base64Decode(t, data) @@ -63,8 +57,6 @@ func TestQueryChartResponseSVGToQueryChartResult(t *testing.T) { } func TestQueryChartResponsePDFToQueryChartResult(t *testing.T) { - t.Parallel() - // arrange data := "ApplicationPDFEncodedBase64str==" decodedData := base64Decode(t, data) @@ -80,8 +72,6 @@ func TestQueryChartResponsePDFToQueryChartResult(t *testing.T) { } func TestUnknownFormatResultsInError(t *testing.T) { - t.Parallel() - // arrange data := "ImageBMPEncodedBase64str==" response := api_payloads.QueryChartResponse{DataURI: "data:image/bmp;base64," + data} @@ -94,8 +84,6 @@ func TestUnknownFormatResultsInError(t *testing.T) { } func TestUnknownEncodingResultsInError(t *testing.T) { - t.Parallel() - // arrange data := "ImagePNGEncodedBase32str==" response := api_payloads.QueryChartResponse{DataURI: "data:image/png;base32," + data} @@ -108,8 +96,6 @@ func TestUnknownEncodingResultsInError(t *testing.T) { } func TestFormatQueryTimeNonNil(t *testing.T) { - t.Parallel() - // arrange datetime := time.Date(2001, 3, 9, 6, 45, 53, 111, time.UTC) @@ -122,8 +108,6 @@ func TestFormatQueryTimeNonNil(t *testing.T) { } func TestFormatQueryTimeNil(t *testing.T) { - t.Parallel() - // arrange var datetime *time.Time diff --git a/kentikapi/internal/api_payloads/types_test.go b/kentikapi/internal/api_payloads/types_test.go index 6e4dc403..61cca0e8 100644 --- a/kentikapi/internal/api_payloads/types_test.go +++ b/kentikapi/internal/api_payloads/types_test.go @@ -9,8 +9,6 @@ import ( ) func TestBoolAsString_UnmarshalJSON(t *testing.T) { - t.Parallel() - tests := []struct { input string expectedResult api_payloads.BoolAsStringOrInt @@ -52,10 +50,7 @@ func TestBoolAsString_UnmarshalJSON(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.input, func(t *testing.T) { - t.Parallel() - var result api_payloads.BoolAsStringOrInt err := json.Unmarshal([]byte(tt.input), &result) diff --git a/kentikapi/internal/resources/alerting_test.go b/kentikapi/internal/resources/alerting_test.go index e9993d66..7e698aeb 100644 --- a/kentikapi/internal/resources/alerting_test.go +++ b/kentikapi/internal/resources/alerting_test.go @@ -18,8 +18,6 @@ var ( ) func TestCrerateManualMitigation(t *testing.T) { - t.Parallel() - createResponsePayload := ` { "response": { @@ -44,8 +42,6 @@ func TestCrerateManualMitigation(t *testing.T) { } func TestGetActiveAlerts(t *testing.T) { - t.Parallel() - getResponsePayload := ` [ { @@ -143,8 +139,6 @@ func TestGetActiveAlerts(t *testing.T) { } func TestGetAlertsHistory(t *testing.T) { - t.Parallel() - getResponsePayload := ` [ { diff --git a/kentikapi/internal/resources/custom_applications_test.go b/kentikapi/internal/resources/custom_applications_test.go index 0bc2a3fc..9768c22d 100644 --- a/kentikapi/internal/resources/custom_applications_test.go +++ b/kentikapi/internal/resources/custom_applications_test.go @@ -15,8 +15,6 @@ import ( ) func TestGetAll(t *testing.T) { - t.Parallel() - getResponsePayload := ` [ { @@ -78,8 +76,6 @@ func TestGetAll(t *testing.T) { } func TestCreateCustomApplication(t *testing.T) { - t.Parallel() - createResponsePayload := ` { "name": "apitest-customapp-1", @@ -134,8 +130,6 @@ func TestCreateCustomApplication(t *testing.T) { } func TestUpdateCustomApplication(t *testing.T) { - t.Parallel() - updateResponsePayload := ` { "id": 207, @@ -194,8 +188,6 @@ func TestUpdateCustomApplication(t *testing.T) { } func TestDeleteCustomApplication(t *testing.T) { - t.Parallel() - // arrange deleteResponsePayload := "" // deleting custom application responds with empty body transport := &api_connection.StubTransport{ResponseBody: deleteResponsePayload} diff --git a/kentikapi/internal/resources/custom_dimensions_test.go b/kentikapi/internal/resources/custom_dimensions_test.go index b3d52b61..50a581c9 100644 --- a/kentikapi/internal/resources/custom_dimensions_test.go +++ b/kentikapi/internal/resources/custom_dimensions_test.go @@ -17,8 +17,6 @@ import ( ) func TestCreateCustomDimension(t *testing.T) { - t.Parallel() - // arrange createResponsePayload := ` { @@ -64,8 +62,6 @@ func TestCreateCustomDimension(t *testing.T) { } func TestUpdateCustomDimension(t *testing.T) { - t.Parallel() - // arrange updateResponsePayload := ` { @@ -106,8 +102,6 @@ func TestUpdateCustomDimension(t *testing.T) { } func TestGetCustomDimension(t *testing.T) { - t.Parallel() - tests := []struct { name string transportError error @@ -317,10 +311,7 @@ func TestGetCustomDimension(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { - t.Parallel() - // arrange transport := &api_connection.StubTransport{ResponseBody: tt.responseBody} customDimensionsAPI := resources.NewCustomDimensionsAPI(transport) @@ -346,8 +337,6 @@ func TestGetCustomDimension(t *testing.T) { } func TestGetAllCustomDimensions(t *testing.T) { - t.Parallel() - // arrange getResponsePayload := ` { @@ -431,8 +420,6 @@ func TestGetAllCustomDimensions(t *testing.T) { } func TestDeleteCustomDimension(t *testing.T) { - t.Parallel() - // arrange deleteResponsePayload := "" // deleting device responds with empty body transport := &api_connection.StubTransport{ResponseBody: deleteResponsePayload} @@ -452,8 +439,6 @@ func TestDeleteCustomDimension(t *testing.T) { } func TestCreatePopulator(t *testing.T) { - t.Parallel() - // arrange createResponsePayload := ` { @@ -580,8 +565,6 @@ func TestCreatePopulator(t *testing.T) { } func TestUpdatePopulator(t *testing.T) { - t.Parallel() - // arrange updateResponsePayload := ` { @@ -660,8 +643,6 @@ func TestUpdatePopulator(t *testing.T) { } func TestDeletePopulator(t *testing.T) { - t.Parallel() - // arrange deleteResponsePayload := "" // deleting device responds with empty body transport := &api_connection.StubTransport{ResponseBody: deleteResponsePayload} diff --git a/kentikapi/internal/resources/device_labels_test.go b/kentikapi/internal/resources/device_labels_test.go index fb50278b..4378c0fd 100644 --- a/kentikapi/internal/resources/device_labels_test.go +++ b/kentikapi/internal/resources/device_labels_test.go @@ -15,8 +15,6 @@ import ( ) func TestCreateDeviceLabel(t *testing.T) { - t.Parallel() - // arrange createResponsePayload := ` { @@ -59,8 +57,6 @@ func TestCreateDeviceLabel(t *testing.T) { } func TestUpdateDeviceLabel(t *testing.T) { - t.Parallel() - // arrange updateResponsePayload := ` { @@ -103,8 +99,6 @@ func TestUpdateDeviceLabel(t *testing.T) { } func TestGetLabel(t *testing.T) { - t.Parallel() - // arrange getResponsePayload := ` { @@ -155,8 +149,6 @@ func TestGetLabel(t *testing.T) { } func TestGetAllLabels(t *testing.T) { - t.Parallel() - // arrange getResponsePayload := ` [ @@ -236,8 +228,6 @@ func TestGetAllLabels(t *testing.T) { } func TestDeleteDeviceLabel(t *testing.T) { - t.Parallel() - // arrange deleteResponsePayload := ` { diff --git a/kentikapi/internal/resources/devices_test.go b/kentikapi/internal/resources/devices_test.go index 65470b7c..8f7ce321 100644 --- a/kentikapi/internal/resources/devices_test.go +++ b/kentikapi/internal/resources/devices_test.go @@ -18,8 +18,6 @@ import ( ) func TestCreateDeviceRouter(t *testing.T) { - t.Parallel() - // arrange createResponsePayload := ` { @@ -212,8 +210,6 @@ func TestCreateDeviceRouter(t *testing.T) { } func TestCreateDeviceDNS(t *testing.T) { - t.Parallel() - // arrange createResponsePayload := ` { @@ -365,8 +361,6 @@ func TestCreateDeviceDNS(t *testing.T) { } func TestUpdatetDeviceRouter(t *testing.T) { - t.Parallel() - // arrange updateResponsePayload := ` { @@ -562,8 +556,6 @@ func TestUpdatetDeviceRouter(t *testing.T) { } func TestGetDevice(t *testing.T) { - t.Parallel() - tests := []struct { name string transportError error @@ -1088,10 +1080,7 @@ func TestGetDevice(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { - t.Parallel() - // arrange transport := &api_connection.StubTransport{ResponseBody: tt.responseBody} devicesAPI := resources.NewDevicesAPI(transport) @@ -1117,8 +1106,6 @@ func TestGetDevice(t *testing.T) { } func TestGetAllDevices(t *testing.T) { - t.Parallel() - // arrange getResponsePayload := ` { @@ -1389,8 +1376,6 @@ func TestGetAllDevices(t *testing.T) { } func TestDeleteDevice(t *testing.T) { - t.Parallel() - // arrange deleteResponsePayload := "" // deleting device responds with empty body transport := &api_connection.StubTransport{ResponseBody: deleteResponsePayload} @@ -1410,8 +1395,6 @@ func TestDeleteDevice(t *testing.T) { } func TestApplyLabels(t *testing.T) { - t.Parallel() - // arrange applyLabelsResponsePayload := ` { @@ -1488,8 +1471,6 @@ func TestApplyLabels(t *testing.T) { } func TestGetInterfaceMinimal(t *testing.T) { - t.Parallel() - // arrange getResponsePayload := ` { @@ -1557,8 +1538,6 @@ func TestGetInterfaceMinimal(t *testing.T) { } func TestGetInterfaceFull(t *testing.T) { - t.Parallel() - // arrange getResponsePayload := ` { @@ -1676,8 +1655,6 @@ func TestGetInterfaceFull(t *testing.T) { } func TestGetAllInterfaces(t *testing.T) { - t.Parallel() - // arrange getResponsePayload := ` [ @@ -1867,8 +1844,6 @@ func TestGetAllInterfaces(t *testing.T) { } func TestCreateInterfaceMinimal(t *testing.T) { - t.Parallel() - // arrange getResponsePayload := ` { @@ -1924,8 +1899,6 @@ func TestCreateInterfaceMinimal(t *testing.T) { } func TestCreateInterfaceFull(t *testing.T) { - t.Parallel() - // arrange getResponsePayload := ` { @@ -2026,8 +1999,6 @@ func TestCreateInterfaceFull(t *testing.T) { } func TestDeleteInterface(t *testing.T) { - t.Parallel() - // arrange deleteResponsePayload := "{}" transport := &api_connection.StubTransport{ResponseBody: deleteResponsePayload} @@ -2048,8 +2019,6 @@ func TestDeleteInterface(t *testing.T) { } func TestUpdateInterfaceMinimal(t *testing.T) { - t.Parallel() - updateResponsePayload := ` { "id": "43", @@ -2127,8 +2096,6 @@ func TestUpdateInterfaceMinimal(t *testing.T) { } func TestUpdateInterfaceFull(t *testing.T) { - t.Parallel() - updateResponsePayload := ` { "id": "43", diff --git a/kentikapi/internal/resources/my_kentik_portal_test.go b/kentikapi/internal/resources/my_kentik_portal_test.go index 6dd54f7f..d21fc195 100644 --- a/kentikapi/internal/resources/my_kentik_portal_test.go +++ b/kentikapi/internal/resources/my_kentik_portal_test.go @@ -14,8 +14,6 @@ import ( ) func TestTenantsList(t *testing.T) { - t.Parallel() - // arrange getAllResponse := ` [ @@ -102,8 +100,6 @@ func TestTenantsList(t *testing.T) { } func TestGetTenantInfo(t *testing.T) { - t.Parallel() - getTenantInfoResponse := ` { "id": 577, @@ -169,8 +165,6 @@ func TestGetTenantInfo(t *testing.T) { } func TestTenantUserCreate(t *testing.T) { - t.Parallel() - createTenantUserResponse := ` { "id": "158564", @@ -206,8 +200,6 @@ func TestTenantUserCreate(t *testing.T) { } func TestTenantUserDelete(t *testing.T) { - t.Parallel() - // arrange deleteResponsePayload := "" transport := &api_connection.StubTransport{ResponseBody: deleteResponsePayload} diff --git a/kentikapi/internal/resources/plans_test.go b/kentikapi/internal/resources/plans_test.go index 07dbd657..bc4f4c6f 100644 --- a/kentikapi/internal/resources/plans_test.go +++ b/kentikapi/internal/resources/plans_test.go @@ -12,8 +12,6 @@ import ( ) func TestGetAllPlans(t *testing.T) { - t.Parallel() - // arrange getResponsePayload := ` { diff --git a/kentikapi/internal/resources/query_test.go b/kentikapi/internal/resources/query_test.go index b525bef3..b57ea376 100644 --- a/kentikapi/internal/resources/query_test.go +++ b/kentikapi/internal/resources/query_test.go @@ -15,8 +15,6 @@ import ( ) func TestQuerySQL(t *testing.T) { - t.Parallel() - // arrange querySQL := ` SELECT i_start_time, @@ -86,8 +84,6 @@ func TestQuerySQL(t *testing.T) { } func TestQueryData(t *testing.T) { - t.Parallel() - // arrange queryResponsePayload := ` { @@ -217,8 +213,6 @@ func TestQueryData(t *testing.T) { } func TestQueryChart(t *testing.T) { - t.Parallel() - // arrange data := "ImageDataEncodedBase64==" queryResponsePayload := `{"dataUri": "data:image/png;base64,ImageDataEncodedBase64=="}` @@ -361,8 +355,6 @@ func TestQueryChart(t *testing.T) { } func TestQueryURL(t *testing.T) { - t.Parallel() - // arrange unquotedResponse := "https://portal.kentik.com/portal/#Charts/shortUrl/e0d24b3cc8dfe41f9093668e531cbe96" queryResponsePayload := `"` + unquotedResponse + `"` // actual response is url in quotation marks diff --git a/kentikapi/internal/resources/saved_filters_test.go b/kentikapi/internal/resources/saved_filters_test.go index e21f5ba1..fb600146 100644 --- a/kentikapi/internal/resources/saved_filters_test.go +++ b/kentikapi/internal/resources/saved_filters_test.go @@ -12,8 +12,6 @@ import ( ) func TestSavedFiltersList(t *testing.T) { - t.Parallel() - getAllresponsePayload := ` [ { @@ -138,8 +136,6 @@ func TestSavedFiltersList(t *testing.T) { } func TestGetSavedFilterInfo(t *testing.T) { - t.Parallel() - getResponsePayload := ` { "id": 8275, @@ -204,8 +200,6 @@ func TestGetSavedFilterInfo(t *testing.T) { } func TestCreateSavedFilter(t *testing.T) { - t.Parallel() - postResponsePayload := ` { "filter_name":"test_filter1", @@ -294,8 +288,6 @@ func TestCreateSavedFilter(t *testing.T) { } func TestUpdateSavedFilter(t *testing.T) { - t.Parallel() - updateResponsePayload := ` { "id":8153, @@ -359,8 +351,6 @@ func TestUpdateSavedFilter(t *testing.T) { } func TestDeleteSavedFilter(t *testing.T) { - t.Parallel() - deleteResponsePayload := "" transport := &api_connection.StubTransport{ResponseBody: deleteResponsePayload} diff --git a/kentikapi/internal/resources/sites_test.go b/kentikapi/internal/resources/sites_test.go index ea54eb5a..a4797b24 100644 --- a/kentikapi/internal/resources/sites_test.go +++ b/kentikapi/internal/resources/sites_test.go @@ -13,8 +13,6 @@ import ( ) func TestGetSite(t *testing.T) { - t.Parallel() - // arrange getResponsePayload := ` { @@ -49,8 +47,6 @@ func TestGetSite(t *testing.T) { } func TestGetAllSites(t *testing.T) { - t.Parallel() - // arrange getResponsePayload := ` { @@ -117,8 +113,6 @@ func TestGetAllSites(t *testing.T) { } func TestCreateSite(t *testing.T) { - t.Parallel() - // arrange createResponsePayload := ` { @@ -159,8 +153,6 @@ func TestCreateSite(t *testing.T) { } func TestUpdateSite(t *testing.T) { - t.Parallel() - // arrange updateResponsePayload := ` { @@ -201,8 +193,6 @@ func TestUpdateSite(t *testing.T) { } func TestDeleteSite(t *testing.T) { - t.Parallel() - // arrange deleteResponsePayload := "" // deleting site responds with empty body transport := &api_connection.StubTransport{ResponseBody: deleteResponsePayload} diff --git a/kentikapi/internal/utils/convert_test.go b/kentikapi/internal/utils/convert_test.go index 67c5eeb2..3c01706d 100644 --- a/kentikapi/internal/utils/convert_test.go +++ b/kentikapi/internal/utils/convert_test.go @@ -9,8 +9,6 @@ import ( ) func TestConvertOrNoneReturnsValue(t *testing.T) { - t.Parallel() - // given input := new(string) *input = "42" @@ -27,8 +25,6 @@ func TestConvertOrNoneReturnsValue(t *testing.T) { } func TestConvertOrNoneReturnsNil(t *testing.T) { - t.Parallel() - // given var input *string var output *int @@ -43,8 +39,6 @@ func TestConvertOrNoneReturnsNil(t *testing.T) { } func TestConvertOrNoneReturnsError(t *testing.T) { - t.Parallel() - // given input := new(string) *input = "0xFF" @@ -59,8 +53,6 @@ func TestConvertOrNoneReturnsError(t *testing.T) { } func TestConvertListSuccess(t *testing.T) { - t.Parallel() - // given input := [...]string{"-13", "22", "742"} var output []int @@ -77,8 +69,6 @@ func TestConvertListSuccess(t *testing.T) { } func TestConvertListError(t *testing.T) { - t.Parallel() - // given input := []string{"42", "0xFF"} var output []int diff --git a/kentikapi/internal/validation/validate.go b/kentikapi/internal/validation/validate.go index de2a64fd..0f02da64 100644 --- a/kentikapi/internal/validation/validate.go +++ b/kentikapi/internal/validation/validate.go @@ -44,7 +44,7 @@ func getTypeName(i interface{}) string { return tResource.Name() } -//nolint:exhaustive +//nolint:exhaustive,gocyclo func validate(method string, direction string, path string, v reflect.Value) []string { missing := make([]string, 0) diff --git a/kentikapi/tags_integration_test.go b/kentikapi/tags_integration_test.go index 149b6066..03c9f759 100644 --- a/kentikapi/tags_integration_test.go +++ b/kentikapi/tags_integration_test.go @@ -19,8 +19,6 @@ const ( ) func TestClient_GetAllTags(t *testing.T) { - t.Parallel() - tests := []struct { name string responseCode int @@ -85,10 +83,7 @@ func TestClient_GetAllTags(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { - t.Parallel() - // arrange h := testutil.NewSpyHTTPHandler(t, tt.responseCode, []byte(tt.responseBody)) s := httptest.NewServer(h) @@ -123,8 +118,6 @@ func TestClient_GetAllTags(t *testing.T) { } func TestClient_GetTag(t *testing.T) { - t.Parallel() - tests := []struct { name string responseCode int @@ -157,10 +150,7 @@ func TestClient_GetTag(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { - t.Parallel() - // arrange h := testutil.NewSpyHTTPHandler(t, tt.responseCode, []byte(tt.responseBody)) s := httptest.NewServer(h) @@ -195,8 +185,6 @@ func TestClient_GetTag(t *testing.T) { } func TestClient_CreateTag(t *testing.T) { - t.Parallel() - tests := []struct { name string tag models.Tag @@ -339,10 +327,7 @@ func TestClient_CreateTag(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { - t.Parallel() - // arrange h := testutil.NewSpyHTTPHandler(t, tt.responseCode, []byte(tt.responseBody)) s := httptest.NewServer(h) @@ -378,8 +363,6 @@ func TestClient_CreateTag(t *testing.T) { } func TestClient_UpdateTag(t *testing.T) { - t.Parallel() - tests := []struct { name string tag models.Tag @@ -510,10 +493,7 @@ func TestClient_UpdateTag(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { - t.Parallel() - // arrange h := testutil.NewSpyHTTPHandler(t, tt.responseCode, []byte(tt.responseBody)) s := httptest.NewServer(h) @@ -550,8 +530,6 @@ func TestClient_UpdateTag(t *testing.T) { } func TestClient_DeleteTag(t *testing.T) { - t.Parallel() - tests := []struct { name string responseCode int @@ -575,10 +553,7 @@ func TestClient_DeleteTag(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { - t.Parallel() - // arrange h := testutil.NewSpyHTTPHandler(t, tt.responseCode, []byte(tt.responseBody)) s := httptest.NewServer(h) diff --git a/kentikapi/users_integration_test.go b/kentikapi/users_integration_test.go index 98a3394f..402cdf26 100644 --- a/kentikapi/users_integration_test.go +++ b/kentikapi/users_integration_test.go @@ -28,8 +28,6 @@ const ( type object = map[string]interface{} func TestClient_GetAllUsers(t *testing.T) { - t.Parallel() - tests := []struct { name string responseCode int @@ -162,10 +160,7 @@ func TestClient_GetAllUsers(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { - t.Parallel() - // arrange h := testutil.NewSpyHTTPHandler(t, tt.responseCode, []byte(tt.responseBody)) s := httptest.NewServer(h) @@ -200,8 +195,6 @@ func TestClient_GetAllUsers(t *testing.T) { } func TestClient_GetUser(t *testing.T) { - t.Parallel() - tests := []struct { name string responses []testutil.HTTPResponse @@ -316,10 +309,7 @@ func TestClient_GetUser(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { - t.Parallel() - // arrange h := testutil.NewMultipleResponseSpyHTTPHandler(t, tt.responses) s := httptest.NewServer(h) @@ -360,8 +350,6 @@ func TestClient_GetUser(t *testing.T) { } func TestClient_CreateUser(t *testing.T) { - t.Parallel() - tests := []struct { name string retryMax *int @@ -541,10 +529,7 @@ func TestClient_CreateUser(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { - t.Parallel() - // arrange h := testutil.NewMultipleResponseSpyHTTPHandler(t, tt.responses) s := httptest.NewServer(h) @@ -587,8 +572,6 @@ func TestClient_CreateUser(t *testing.T) { } func TestClient_UpdateUser(t *testing.T) { - t.Parallel() - tests := []struct { name string user models.User @@ -686,10 +669,7 @@ func TestClient_UpdateUser(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { - t.Parallel() - // arrange h := testutil.NewSpyHTTPHandler(t, tt.responseCode, []byte(tt.responseBody)) s := httptest.NewServer(h) @@ -726,8 +706,6 @@ func TestClient_UpdateUser(t *testing.T) { } func TestClient_DeleteUser(t *testing.T) { - t.Parallel() - tests := []struct { name string responseCode int @@ -751,10 +729,7 @@ func TestClient_DeleteUser(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { - t.Parallel() - // arrange h := testutil.NewSpyHTTPHandler(t, tt.responseCode, []byte(tt.responseBody)) s := httptest.NewServer(h)