Skip to content

Commit 9e21acf

Browse files
committed
chore: remove redundant code and update build tags
Ran `golangci-lint run --fix` to: - Eliminates unnecessary blank lines and redundant code across multiple files to improve readability and maintainability. - Updates Go build tags by removing legacy `+build` comments, standardizing on `//go:build` syntax for test files. Updates linter configuration to use `wsl_v5` with custom settings in `.golangci.yml`. Replaced deprecated use of `swag.ReadJSON` and `swag.WriteJSON` with `jsonutils.ReadJSON` and `jsonutils.WriteJSON`. Signed-off-by: Ryan Johnson <ryan.johnson@broadcom.com>
1 parent bb65531 commit 9e21acf

File tree

106 files changed

+95
-209
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+95
-209
lines changed

.golangci.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ linters:
6363
- unparam
6464
- unused
6565
- whitespace
66-
- wsl
66+
- wsl_v5
6767
settings:
6868
funlen:
6969
lines: 150
@@ -72,6 +72,10 @@ linters:
7272
min-complexity: 60
7373
nestif:
7474
min-complexity: 14
75+
wsl_v5:
76+
allow-first-in-block: true
77+
allow-whole-block: false
78+
branch-max-lines: 2
7579
exclusions:
7680
generated: lax
7781
presets:

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ go 1.24.0
55
require (
66
github.com/go-openapi/strfmt v0.25.0
77
github.com/go-openapi/swag v0.25.1
8+
github.com/go-openapi/swag/jsonutils v0.25.1
89
github.com/go-test/deep v1.1.1
910
github.com/hashicorp/go-cty v1.5.0
1011
github.com/hashicorp/terraform-plugin-sdk/v2 v2.36.1
@@ -27,7 +28,6 @@ require (
2728
github.com/go-openapi/swag/conv v0.25.1 // indirect
2829
github.com/go-openapi/swag/fileutils v0.25.1 // indirect
2930
github.com/go-openapi/swag/jsonname v0.25.1 // indirect
30-
github.com/go-openapi/swag/jsonutils v0.25.1 // indirect
3131
github.com/go-openapi/swag/loading v0.25.1 // indirect
3232
github.com/go-openapi/swag/mangling v0.25.1 // indirect
3333
github.com/go-openapi/swag/netutils v0.25.1 // indirect

internal/authctx/helper.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ func ProviderConfigureContextWithDefaultTransportForTesting(_ context.Context, d
191191
config.TLSConfig.CaCert, _ = d.Get(caCert).(string)
192192

193193
var err error
194-
config.TMCConnection, err = client.NewHTTPClient(config.TLSConfig)
195194

195+
config.TMCConnection, err = client.NewHTTPClient(config.TLSConfig)
196196
if err != nil {
197197
panic(err)
198198
}
@@ -214,7 +214,6 @@ func setContext(config *TanzuContext) (TanzuContext, diag.Diagnostics) {
214214
}
215215

216216
err := config.Setup()
217-
218217
if err != nil {
219218
diags = append(diags, diag.Diagnostic{
220219
Severity: diag.Error,
@@ -242,7 +241,6 @@ func setContextWithDefaultTransport(config *TanzuContext) (TanzuContext, diag.Di
242241
}
243242

244243
err := config.SetupWithDefaultTransportForTesting()
245-
246244
if err != nil {
247245
diags = append(diags, diag.Diagnostic{
248246
Severity: diag.Error,

internal/authctx/saas.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ func getBearerToken(cspEndpoint, cspToken string, config *proxy.TLSConfig) (stri
6969
"application/x-www-form-urlencoded",
7070
encodedToken,
7171
)
72-
7372
if err == nil {
7473
defer resp.Body.Close()
7574
break

internal/client/proxy/tls_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ func TestGetConnectorTLSConfig(t *testing.T) {
244244
caCert1, _ := os.ReadFile(clientCertPath)
245245
caCertPool := x509.NewCertPool()
246246
caCertPool.AppendCertsFromPEM(caCert1)
247+
247248
return caCertPool
248249
}(),
249250
},
@@ -268,6 +269,7 @@ func TestGetConnectorTLSConfig(t *testing.T) {
268269
RootCAs: func() *x509.CertPool {
269270
caCertPool := x509.NewCertPool()
270271
caCertPool.AppendCertsFromPEM([]byte(caCert))
272+
271273
return caCertPool
272274
}(),
273275
},

internal/client/targetlocation/targetlocation_resource.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ func (c *Client) TargetLocationResourceServiceList(request *targetlocationsmodel
5858
}
5959

6060
requestURL, err := buildTargetLocationsRequestURL(request)
61-
6261
if err != nil {
6362
return nil, err
6463
}
@@ -128,7 +127,6 @@ func buildTargetLocationsRequestURL(request *targetlocationsmodel.ListBackupLoca
128127
}
129128

130129
err := buildQueryParams(&queryParams, "", requestMap)
131-
132130
if err != nil {
133131
return "", errors.New("couldn't create request url")
134132
}
@@ -152,7 +150,6 @@ func buildQueryParams(queryParams *url.Values, parentParam string, request map[s
152150
switch value := value.(type) {
153151
case map[string]interface{}:
154152
err = buildQueryParams(queryParams, parent, value)
155-
156153
if err != nil {
157154
return err
158155
}

internal/client/transport/methods.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ func (c *Client) Patch(url string, request Request, response Response) error {
3838

3939
func (c *Client) invokeAction(httpMethodType string, url string, request Request, response Response) error {
4040
requestURL := fmt.Sprintf("%s/%s", c.Host, strings.TrimPrefix(url, "/"))
41-
body, err := request.MarshalBinary()
4241

42+
body, err := request.MarshalBinary()
4343
if err != nil {
4444
return errors.Wrap(err, "marshall request body")
4545
}

internal/helper/converter/construct_tf_schema.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ func (converter *TFSchemaModelConverter[T]) buildTFValue(modelJSONData *map[stri
4040
var modelValue interface{}
4141

4242
modelField := mapValue.Field
43-
modelValue, err = converter.getModelValue(modelJSONData, modelField, arrIndexer)
4443

44+
modelValue, err = converter.getModelValue(modelJSONData, modelField, arrIndexer)
4545
if err == nil {
4646
tfSchemaValue = mapValue.EvalFunc(ConstructTFSchema, modelValue)
4747
} else if strings.Contains(err.Error(), arrayCannotBeReachedMsg) && strings.HasSuffix(modelField, ArrayFieldMarker) {

internal/helper/converter/converter.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,27 +76,23 @@ func (converter *TFSchemaModelConverter[T]) FillTFSchema(modelPtr T, data *schem
7676
)
7777

7878
jsonBytes, err := modelPtr.MarshalBinary()
79-
8079
if err != nil {
8180
return err
8281
}
8382

8483
err = json.Unmarshal(jsonBytes, &modelJSONData)
85-
8684
if err != nil {
8785
return err
8886
}
8987

9088
for mapKey, mapValue := range *converter.TFModelMap {
9189
tfValue, err = converter.buildTFValue(&modelJSONData, mapValue, &arrIndexer)
92-
9390
if err != nil {
9491
return err
9592
}
9693

9794
if tfValue != nil {
9895
err = data.Set(mapKey, tfValue)
99-
10096
if err != nil {
10197
return err
10298
}

internal/helper/openapi_v3_schema_validator/openapi_v3_schema_validator.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ func validateStringFormat(parentKey string, variableValue interface{}, variableS
203203

204204
if regexPattern, ok := variableSchema[string(PatternKey)]; ok {
205205
regex, err := regexp.Compile(regexPattern.(string))
206-
207206
if err == nil {
208207
if !regex.MatchString(variableValue.(string)) {
209208
errs = append(errs, errors.Errorf("Key '%s' doesn't match regular expression '%s', value provided: '%s'", parentKey, regexPattern, variableValue))

0 commit comments

Comments
 (0)