Skip to content

Commit

Permalink
tests/provider: Fix and enable linting for immediate dereference afte…
Browse files Browse the repository at this point in the history
…r AWS SDK Go pointer conversion

Reference: #12992

This is akin to `*&var`, which is flagged by the Go toolchain.
  • Loading branch information
bflad committed Mar 10, 2021
1 parent 6683ae4 commit 04056ea
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
16 changes: 16 additions & 0 deletions .semgrep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,22 @@ rules:
pattern: 'd.SetId(*$VALUE)'
severity: WARNING

- id: aws-go-sdk-pointer-conversion-immediate-dereference
fix: $VALUE
languages: [go]
message: Using AWS Go SDK pointer conversion, e.g. aws.String(), with immediate dereferencing is extraneous
paths:
include:
- aws/
patterns:
- pattern-either:
- pattern: '*aws.Bool($VALUE)'
- pattern: '*aws.Float64($VALUE)'
- pattern: '*aws.Int64($VALUE)'
- pattern: '*aws.String($VALUE)'
- pattern: '*aws.Time($VALUE)'
severity: WARNING

- id: helper-schema-Set-extraneous-NewSet-with-flattenStringList
languages: [go]
message: Prefer `flattenStringSet()` function for casting a list of string pointers to a set
Expand Down
2 changes: 1 addition & 1 deletion aws/resource_aws_cur_report_definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func resourceAwsCurReportDefinitionCreate(d *schema.ResourceData, meta interface
func resourceAwsCurReportDefinitionRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).costandusagereportconn

reportName := *aws.String(d.Id())
reportName := d.Id()

matchingReportDefinition, err := describeCurReportDefinition(conn, reportName)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion aws/resource_aws_launch_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ func resourceAwsLaunchConfigurationCreate(d *schema.ResourceData, meta interface
ebs.Iops = aws.Int64(int64(v))
}

if *aws.String(bd["device_name"].(string)) == *rootDeviceName {
if bd["device_name"].(string) == aws.StringValue(rootDeviceName) {
return fmt.Errorf("Root device (%s) declared as an 'ebs_block_device'. Use 'root_block_device' keyword.", *rootDeviceName)
}

Expand Down

0 comments on commit 04056ea

Please sign in to comment.