From 0f32e768bd2a179dbd514b3f21a53b4533fbf5ff Mon Sep 17 00:00:00 2001 From: carnellj-genesys <109529583+carnellj-genesys@users.noreply.github.com> Date: Tue, 26 Mar 2024 10:05:06 -0400 Subject: [PATCH] NO-JIRA: Adding lint configuration (#935) --- ...esyscloud_architect_datatable_init_test.go | 4 ++++ ...source_genesyscloud_architect_datatable.go | 12 +++++----- ..._genesyscloud_architect_datatable_proxy.go | 10 +++----- golangci.yaml | 24 +++++++++++++++++++ 4 files changed, 37 insertions(+), 13 deletions(-) create mode 100644 golangci.yaml diff --git a/genesyscloud/architect_datatable/genesyscloud_architect_datatable_init_test.go b/genesyscloud/architect_datatable/genesyscloud_architect_datatable_init_test.go index 3065743ba..f10893d31 100644 --- a/genesyscloud/architect_datatable/genesyscloud_architect_datatable_init_test.go +++ b/genesyscloud/architect_datatable/genesyscloud_architect_datatable_init_test.go @@ -20,11 +20,15 @@ type registerTestInstance struct { // registerTestResources registers all resources used in the tests func (r *registerTestInstance) registerTestResources() { + r.resourceMapMutex.Lock() + defer r.resourceMapMutex.Unlock() providerResources["genesyscloud_architect_datatable"] = ResourceArchitectDatatable() } // registerTestDataSources registers all data sources used in the tests. func (r *registerTestInstance) registerTestDataSources() { + r.datasourceMapMutex.Lock() + defer r.datasourceMapMutex.Unlock() providerDataSources["genesyscloud_architect_datatable"] = DataSourceArchitectDatatable() } diff --git a/genesyscloud/architect_datatable/resource_genesyscloud_architect_datatable.go b/genesyscloud/architect_datatable/resource_genesyscloud_architect_datatable.go index 37ba4e45b..c7bdc4e48 100644 --- a/genesyscloud/architect_datatable/resource_genesyscloud_architect_datatable.go +++ b/genesyscloud/architect_datatable/resource_genesyscloud_architect_datatable.go @@ -115,19 +115,19 @@ func readArchitectDatatable(ctx context.Context, d *schema.ResourceData, meta in return retry.NonRetryableError(fmt.Errorf("Failed to read architect_datatable %s: %s", d.Id(), getErr)) } cc := consistency_checker.NewConsistencyCheck(ctx, d, meta, ResourceArchitectDatatable()) - d.Set("name", *datatable.Name) - d.Set("division_id", *datatable.Division.Id) + _ = d.Set("name", *datatable.Name) + _ = d.Set("division_id", *datatable.Division.Id) if datatable.Description != nil { - d.Set("description", *datatable.Description) + _ = d.Set("description", *datatable.Description) } else { - d.Set("description", nil) + _ = d.Set("description", nil) } if datatable.Schema != nil && datatable.Schema.Properties != nil { - d.Set("properties", flattenDatatableProperties(*datatable.Schema.Properties)) + _ = d.Set("properties", flattenDatatableProperties(*datatable.Schema.Properties)) } else { - d.Set("properties", nil) + _ = d.Set("properties", nil) } log.Printf("Read architect_datatable %s %s", d.Id(), *datatable.Name) diff --git a/genesyscloud/architect_datatable/resource_genesyscloud_architect_datatable_proxy.go b/genesyscloud/architect_datatable/resource_genesyscloud_architect_datatable_proxy.go index 1ed23bfff..880350895 100644 --- a/genesyscloud/architect_datatable/resource_genesyscloud_architect_datatable_proxy.go +++ b/genesyscloud/architect_datatable/resource_genesyscloud_architect_datatable_proxy.go @@ -74,7 +74,7 @@ func createOrUpdateArchitectDatatableFn(ctx context.Context, p *architectDatatab // create path and map variables path := p.architectApi.Configuration.BasePath + "/api/v2/flows/datatables" - if createAction == false { + if !createAction { action = http.MethodPut path += "/" + *datatable.Id } @@ -156,9 +156,7 @@ func getAllArchitectDatatableFn(ctx context.Context, p *architectDatatableProxy) return &totalRecords, nil } - for _, table := range *tables.Entities { - totalRecords = append(totalRecords, table) - } + totalRecords = append(totalRecords, *tables.Entities...) for pageNum := 2; pageNum <= *tables.PageCount; pageNum++ { tables, _, getErr := p.architectApi.GetFlowsDatatables("", pageNum, pageSize, "", "", nil, "") @@ -170,9 +168,7 @@ func getAllArchitectDatatableFn(ctx context.Context, p *architectDatatableProxy) break } - for _, table := range *tables.Entities { - totalRecords = append(totalRecords, table) - } + totalRecords = append(totalRecords, *tables.Entities...) } return &totalRecords, nil diff --git a/golangci.yaml b/golangci.yaml new file mode 100644 index 000000000..c075f92c7 --- /dev/null +++ b/golangci.yaml @@ -0,0 +1,24 @@ +linters: + enable: + - gosec + - godot + - misspell + - stylecheck + +linters-settings: + stylecheck: + # Select the Go version to target. The default is '1.13'. + go: "1.18" + checks: ["all","ST1*"] + +issues: + exclude-use-default: false + +output: + format: colored-line-number + + # print lines of code with issue, default is true + print-issued-lines: false + + # print linter name in the end of issue text, default is true + print-linter-name: true \ No newline at end of file