Skip to content

Commit

Permalink
fix: enable failing gosimple check
Browse files Browse the repository at this point in the history
Signed-off-by: Ruihua Wen <[email protected]>
  • Loading branch information
SpiffyEight77 committed Oct 1, 2024
1 parent d0852b5 commit 319ec47
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 14 deletions.
4 changes: 0 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ issues:
max-per-linter: 0
max-same-issues: 0
exclude-rules:
#TODO: Enable failing gosimple checks
- linters:
- gosimple
text: "S(1007|1034|1039|1009)"
# TODO: Enable failing staticchecks
- linters:
- staticcheck
Expand Down
4 changes: 2 additions & 2 deletions digitalocean/droplet/resource_droplet.go
Original file line number Diff line number Diff line change
Expand Up @@ -809,9 +809,9 @@ func dropletStateRefreshFunc(

// See if we can access our attribute
if attr, ok := d.GetOkExists(attribute); ok {
switch attr.(type) {
switch attr := attr.(type) {
case bool:
return &droplet, strconv.FormatBool(attr.(bool)), nil
return &droplet, strconv.FormatBool(attr), nil
default:
return &droplet, attr.(string), nil
}
Expand Down
4 changes: 2 additions & 2 deletions digitalocean/tag/resource_tag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func testAccCheckDigitalOceanTagExists(n string, tag *godo.Tag) resource.TestChe
}
}

var testAccCheckDigitalOceanTagConfig_basic = fmt.Sprintf(`
var testAccCheckDigitalOceanTagConfig_basic = `
resource "digitalocean_tag" "foobar" {
name = "foobar"
}`)
}`
2 changes: 1 addition & 1 deletion digitalocean/tag/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

var tagNameRe = regexp.MustCompile("^[a-zA-Z0-9:\\-_]{1,255}$")
var tagNameRe = regexp.MustCompile(`^[a-zA-Z0-9:\-_]{1,255}$`)

func TagsSchema() *schema.Schema {
return &schema.Schema{
Expand Down
4 changes: 2 additions & 2 deletions digitalocean/util/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ func HashStringIgnoreCase(v interface{}) int {
// HashStringStateFunc implements a schema.SchemaStateFunc with HashString
func HashStringStateFunc() schema.SchemaStateFunc {
return func(v interface{}) string {
switch v.(type) {
switch v := v.(type) {
case string:
return HashString(v.(string))
return HashString(v)
default:
return ""
}
Expand Down
4 changes: 2 additions & 2 deletions digitalocean/volume/resource_volume_attachment.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func resourceDigitalOceanVolumeAttachmentCreate(ctx context.Context, d *schema.R
return diag.Errorf("Error retrieving volume: %s", err)
}

if volume.DropletIDs == nil || len(volume.DropletIDs) == 0 || volume.DropletIDs[0] != dropletId {
if len(volume.DropletIDs) == 0 || volume.DropletIDs[0] != dropletId {

// Only one volume can be attached at one time to a single droplet.
err := resource.RetryContext(ctx, 5*time.Minute, func() *resource.RetryError {
Expand Down Expand Up @@ -103,7 +103,7 @@ func resourceDigitalOceanVolumeAttachmentRead(ctx context.Context, d *schema.Res
return diag.Errorf("Error retrieving volume: %s", err)
}

if volume.DropletIDs == nil || len(volume.DropletIDs) == 0 || volume.DropletIDs[0] != dropletId {
if len(volume.DropletIDs) == 0 || volume.DropletIDs[0] != dropletId {
log.Printf("[DEBUG] Volume Attachment (%s) not found, removing from state", d.Id())
d.SetId("")
}
Expand Down
2 changes: 1 addition & 1 deletion digitalocean/volume/resource_volume_attachment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func testAccCheckDigitalOceanVolumeAttachmentExists(rn string) resource.TestChec
return err
}

if got.DropletIDs == nil || len(got.DropletIDs) == 0 || got.DropletIDs[0] != dropletId {
if len(got.DropletIDs) == 0 || got.DropletIDs[0] != dropletId {
return fmt.Errorf("wrong volume attachment found for volume %s, got %q wanted %q", volumeId, got.DropletIDs[0], dropletId)
}

Expand Down

0 comments on commit 319ec47

Please sign in to comment.