Skip to content

Commit

Permalink
tests/provider: Enable staticcheck S1034 check (hashicorp#8292)
Browse files Browse the repository at this point in the history
tests/provider: Enable staticcheck S1034 check
  • Loading branch information
nywilken authored Apr 26, 2019
2 parents 89aec29 + 0a4d6d7 commit baf874c
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 26 deletions.
6 changes: 3 additions & 3 deletions aws/iam_policy_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,12 @@ func (cs *IAMPolicyStatementConditionSet) UnmarshalJSON(b []byte) error {

for test_key, test_value := range data {
for var_key, var_values := range test_value {
switch var_values.(type) {
switch var_values := var_values.(type) {
case string:
out = append(out, IAMPolicyStatementCondition{Test: test_key, Variable: var_key, Values: []string{var_values.(string)}})
out = append(out, IAMPolicyStatementCondition{Test: test_key, Variable: var_key, Values: []string{var_values}})
case []interface{}:
values := []string{}
for _, v := range var_values.([]interface{}) {
for _, v := range var_values {
values = append(values, v.(string))
}
out = append(out, IAMPolicyStatementCondition{Test: test_key, Variable: var_key, Values: values})
Expand Down
6 changes: 3 additions & 3 deletions aws/resource_aws_iam_server_certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,11 @@ func normalizeCert(cert interface{}) string {
}

var rawCert string
switch cert.(type) {
switch cert := cert.(type) {
case string:
rawCert = cert.(string)
rawCert = cert
case *string:
rawCert = *cert.(*string)
rawCert = *cert
default:
return ""
}
Expand Down
4 changes: 2 additions & 2 deletions aws/resource_aws_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ func resourceAwsInstance() *schema.Resource {
return false
},
StateFunc: func(v interface{}) string {
switch v.(type) {
switch v := v.(type) {
case string:
return userDataHashSum(v.(string))
return userDataHashSum(v)
default:
return ""
}
Expand Down
4 changes: 2 additions & 2 deletions aws/resource_aws_key_pair.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ func resourceAwsKeyPair() *schema.Resource {
Required: true,
ForceNew: true,
StateFunc: func(v interface{}) string {
switch v.(type) {
switch v := v.(type) {
case string:
return strings.TrimSpace(v.(string))
return strings.TrimSpace(v)
default:
return ""
}
Expand Down
4 changes: 2 additions & 2 deletions aws/resource_aws_launch_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ func resourceAwsLaunchConfiguration() *schema.Resource {
ForceNew: true,
ConflictsWith: []string{"user_data_base64"},
StateFunc: func(v interface{}) string {
switch v.(type) {
switch v := v.(type) {
case string:
return userDataHashSum(v.(string))
return userDataHashSum(v)
default:
return ""
}
Expand Down
12 changes: 6 additions & 6 deletions aws/resource_aws_opsworks_application.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ func resourceAwsOpsworksApplication() *schema.Resource {
Type: schema.TypeString,
Required: true,
StateFunc: func(v interface{}) string {
switch v.(type) {
switch v := v.(type) {
case string:
return strings.TrimSpace(v.(string))
return strings.TrimSpace(v)
default:
return ""
}
Expand All @@ -181,9 +181,9 @@ func resourceAwsOpsworksApplication() *schema.Resource {
Required: true,
Sensitive: true,
StateFunc: func(v interface{}) string {
switch v.(type) {
switch v := v.(type) {
case string:
return strings.TrimSpace(v.(string))
return strings.TrimSpace(v)
default:
return ""
}
Expand All @@ -193,9 +193,9 @@ func resourceAwsOpsworksApplication() *schema.Resource {
Type: schema.TypeString,
Optional: true,
StateFunc: func(v interface{}) string {
switch v.(type) {
switch v := v.(type) {
case string:
return strings.TrimSpace(v.(string))
return strings.TrimSpace(v)
default:
return ""
}
Expand Down
4 changes: 2 additions & 2 deletions aws/resource_aws_s3_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -2280,9 +2280,9 @@ func removeNil(data map[string]interface{}) map[string]interface{} {
continue
}

switch v.(type) {
switch v := v.(type) {
case map[string]interface{}:
withoutNil[k] = removeNil(v.(map[string]interface{}))
withoutNil[k] = removeNil(v)
default:
withoutNil[k] = v
}
Expand Down
4 changes: 2 additions & 2 deletions aws/resource_aws_security_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -1337,9 +1337,9 @@ func idHash(rType, protocol string, toPort, fromPort int64, self bool) string {

// protocolStateFunc ensures we only store a string in any protocol field
func protocolStateFunc(v interface{}) string {
switch v.(type) {
switch v := v.(type) {
case string:
p := protocolForValue(v.(string))
p := protocolForValue(v)
return p
default:
log.Printf("[WARN] Non String value given for Protocol: %#v", v)
Expand Down
4 changes: 2 additions & 2 deletions aws/resource_aws_spot_fleet_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,9 @@ func resourceAwsSpotFleetRequest() *schema.Resource {
Optional: true,
ForceNew: true,
StateFunc: func(v interface{}) string {
switch v.(type) {
switch v := v.(type) {
case string:
return userDataHashSum(v.(string))
return userDataHashSum(v)
default:
return ""
}
Expand Down
3 changes: 1 addition & 2 deletions staticcheck.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ checks = [
"-ST1000",
"-ST1003",
"-ST1005",
"-ST1012",
"-S1034"
"-ST1012"
]

0 comments on commit baf874c

Please sign in to comment.