Skip to content

Commit b88f2a9

Browse files
authored
chore: Remove unneeded Go linter exceptions (#3247)
* remove exceptions in tests * remove exceptions in prod code * ToTFMapOfString * fix MarshalYAML * JoinQuotedStrings * Revert "fix MarshalYAML" This reverts commit a2be534. * revert http_mocker changes * AllowOutOfOrder doc * fix linter
1 parent e22a647 commit b88f2a9

File tree

8 files changed

+23
-20
lines changed

8 files changed

+23
-20
lines changed

internal/common/conversion/string_framework.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func ToTFMapOfSlices(ctx context.Context, values map[string][]string) (basetypes
2424
return types.MapValueFrom(ctx, types.ListType{ElemType: types.StringType}, values)
2525
}
2626

27-
func ToTFMapOfString(ctx context.Context, diags *diag.Diagnostics, values *map[string]string) basetypes.MapValue { //nolint:gocritic // easy usage from sdk fields
27+
func ToTFMapOfString(ctx context.Context, diags *diag.Diagnostics, values map[string]string) basetypes.MapValue {
2828
if values == nil {
2929
return basetypes.NewMapNull(types.StringType)
3030
}

internal/service/advancedcluster/resource_advanced_cluster_test.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -2081,10 +2081,9 @@ func configAdvanced(t *testing.T, usePreviewProvider bool, projectID, clusterNam
20812081
if p.TlsCipherConfigMode != nil {
20822082
tlsCipherConfigModeStr = fmt.Sprintf(`tls_cipher_config_mode = %[1]q`, *p.TlsCipherConfigMode)
20832083
if p.CustomOpensslCipherConfigTls12 != nil && len(*p.CustomOpensslCipherConfigTls12) > 0 {
2084-
//nolint:gocritic // reason: simplifying string array construction
20852084
customOpensslCipherConfigTLS12Str = fmt.Sprintf(
2086-
`custom_openssl_cipher_config_tls12 = ["%s"]`,
2087-
strings.Join(*p.CustomOpensslCipherConfigTls12, `", "`),
2085+
`custom_openssl_cipher_config_tls12 = [%s]`,
2086+
acc.JoinQuotedStrings(*p.CustomOpensslCipherConfigTls12),
20882087
)
20892088
}
20902089
}

internal/service/advancedclustertpf/model_ClusterDescription20240805.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func NewLabelsObjType(ctx context.Context, diags *diag.Diagnostics, input *[]adm
110110
elms[key] = value
111111
}
112112
}
113-
return conversion.ToTFMapOfString(ctx, diags, &elms)
113+
return conversion.ToTFMapOfString(ctx, diags, elms)
114114
}
115115

116116
func NewReplicationSpecsObjType(ctx context.Context, input *[]admin.ReplicationSpec20240805, diags *diag.Diagnostics, apiInfo *ExtraAPIInfo) types.List {
@@ -159,7 +159,7 @@ func convertReplicationSpecs(ctx context.Context, input *[]admin.ReplicationSpec
159159
Id: types.StringValue(legacyID),
160160
ExternalId: types.StringValue(conversion.SafeValue(item.Id)),
161161
NumShards: types.Int64Value(1),
162-
ContainerId: conversion.ToTFMapOfString(ctx, diags, &containerIDs),
162+
ContainerId: conversion.ToTFMapOfString(ctx, diags, containerIDs),
163163
RegionConfigs: regionConfigs,
164164
ZoneId: types.StringValue(conversion.SafeValue(item.ZoneId)),
165165
ZoneName: types.StringValue(conversion.SafeValue(item.ZoneName)),
@@ -218,7 +218,7 @@ func convertReplicationSpecsLegacy(ctx context.Context, input *[]admin.Replicati
218218
}
219219
containerIDs := selectContainerIDs(&item, apiInfo.ContainerIDs)
220220
tfModels = append(tfModels, TFReplicationSpecsModel{
221-
ContainerId: conversion.ToTFMapOfString(ctx, diags, &containerIDs),
221+
ContainerId: conversion.ToTFMapOfString(ctx, diags, containerIDs),
222222
ExternalId: types.StringValue(""), // Not meaningful with legacy schema
223223
Id: types.StringValue(legacyID),
224224
RegionConfigs: regionConfigs,
@@ -237,7 +237,7 @@ func NewTagsObjType(ctx context.Context, diags *diag.Diagnostics, input *[]admin
237237
elms[item.GetKey()] = item.GetValue()
238238
}
239239
}
240-
return conversion.ToTFMapOfString(ctx, diags, &elms)
240+
return conversion.ToTFMapOfString(ctx, diags, elms)
241241
}
242242

243243
func NewPrivateEndpointObjType(ctx context.Context, input *[]admin.ClusterDescriptionConnectionStringsPrivateEndpoint, diags *diag.Diagnostics) types.List {

internal/service/cluster/resource_cluster_test.go

+6-9
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"fmt"
55
"os"
66
"regexp"
7-
"strings"
87
"testing"
98
"time"
109

@@ -1472,10 +1471,9 @@ func configAdvancedConf(projectID, name, autoscalingEnabled string,
14721471
if p.TlsCipherConfigMode != nil {
14731472
tlsCipherConfigModeStr = fmt.Sprintf(`tls_cipher_config_mode = %[1]q`, *p.TlsCipherConfigMode)
14741473
if p.CustomOpensslCipherConfigTls12 != nil && len(*p.CustomOpensslCipherConfigTls12) > 0 {
1475-
//nolint:gocritic // reason: simplifying string array construction
14761474
customOpensslCipherConfigTLS12Str = fmt.Sprintf(
1477-
`custom_openssl_cipher_config_tls12 = ["%s"]`,
1478-
strings.Join(*p.CustomOpensslCipherConfigTls12, `", "`),
1475+
`custom_openssl_cipher_config_tls12 = [%s]`,
1476+
acc.JoinQuotedStrings(*p.CustomOpensslCipherConfigTls12),
14791477
)
14801478
}
14811479
}
@@ -1577,10 +1575,9 @@ func configAdvancedConfPartial(projectID, name, autoscalingEnabled string, p *ad
15771575
if p.TlsCipherConfigMode != nil {
15781576
tlsCipherConfigModeStr = fmt.Sprintf(`tls_cipher_config_mode = %[1]q`, *p.TlsCipherConfigMode)
15791577
if p.CustomOpensslCipherConfigTls12 != nil && len(*p.CustomOpensslCipherConfigTls12) > 0 {
1580-
//nolint:gocritic // reason: simplifying string array construction
15811578
customOpensslCipherConfigTLS12Str = fmt.Sprintf(
1582-
`custom_openssl_cipher_config_tls12 = ["%s"]`,
1583-
strings.Join(*p.CustomOpensslCipherConfigTls12, `", "`),
1579+
`custom_openssl_cipher_config_tls12 = [%s]`,
1580+
acc.JoinQuotedStrings(*p.CustomOpensslCipherConfigTls12),
15841581
)
15851582
}
15861583
}
@@ -1900,8 +1897,8 @@ func testAccMongoDBAtlasClusterAWSConfigdWithLabels(projectID, name, backupEnabl
19001897
for _, label := range labels {
19011898
labelsConf += fmt.Sprintf(`
19021899
labels {
1903-
key = "%s"
1904-
value = "%s"
1900+
key = %q
1901+
value = %q
19051902
}
19061903
`, label.Key, label.Value)
19071904
}

internal/service/encryptionatrestprivateendpoint/data_source.go

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//nolint:gocritic
21
package encryptionatrestprivateendpoint
32

43
import (

internal/service/encryptionatrestprivateendpoint/plural_data_source.go

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//nolint:gocritic
21
package encryptionatrestprivateendpoint
32

43
import (

internal/testutil/acc/advanced_cluster.go

+9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package acc
33
import (
44
"context"
55
"fmt"
6+
"strings"
67
"time"
78

89
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
@@ -232,3 +233,11 @@ func ConfigBasicDedicated(projectID, name, zoneName string) string {
232233
}
233234
`, projectID, name, zoneNameLine)
234235
}
236+
237+
func JoinQuotedStrings(list []string) string {
238+
quoted := make([]string, len(list))
239+
for i, item := range list {
240+
quoted[i] = fmt.Sprintf("%q", item)
241+
}
242+
return strings.Join(quoted, ", ")
243+
}

internal/testutil/unit/http_mocker.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type MockHTTPDataConfig struct {
3030
IsDiffMustSubstrings []string // Only include diff request for specific substrings, for example /clusters (avoids project create requests)
3131
QueryVars []string // Substitute this query vars. Useful when differentiating responses based on query args, for example ?providerName=AWS/AZURE returns different responses
3232
AllowMissingRequests bool // When false will require all API calls to be made.
33-
AllowOutOfOrder bool // When true will allow a GET request returned after a POST to be returned before the POST.
33+
AllowOutOfOrder bool // When true will allow a GET request returned after a POST to be returned before the POST. Not used but kept for debugging.
3434
}
3535

3636
func (c MockHTTPDataConfig) WithAllowOutOfOrder() MockHTTPDataConfig { //nolint: gocritic // Want each test run to have its own config (hugeParam: c is heavy (112 bytes); consider passing it by pointer)

0 commit comments

Comments
 (0)