Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: tidy up lint config #577

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ issues:
- path: '(.+)_test\.go'
linters:
- errcheck
- unparam
# disabling both of these for the SDKv2-based code as it's idomatic for the SDK
- path: honeycombio/*
text: "Error return value of `d.Set` is not checked"
Expand Down
2 changes: 0 additions & 2 deletions client/board_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ func TestBoards(t *testing.T) {
})
require.NoError(t, err)
t.Cleanup(func() {
//nolint:errcheck
c.Columns.Delete(ctx, dataset, column.ID)
})

Expand Down Expand Up @@ -55,7 +54,6 @@ func TestBoards(t *testing.T) {
})
require.NoError(t, err)
t.Cleanup(func() {
//nolint:errcheck
c.SLOs.Delete(ctx, dataset, slo.ID)
c.DerivedColumns.Delete(ctx, dataset, sli.ID)
})
Expand Down
1 change: 0 additions & 1 deletion client/burn_alert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ func TestBurnAlerts(t *testing.T) {
require.NoError(t, err)

// remove SLO and SLI at the end of the test run
//nolint:errcheck
t.Cleanup(func() {
c.SLOs.Delete(ctx, dataset, slo.ID)
c.DerivedColumns.Delete(ctx, dataset, sli.ID)
Expand Down
1 change: 0 additions & 1 deletion client/column_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ func createRandomTestColumns(
})
require.NoError(t, err)

//nolint:errcheck
t.Cleanup(func() {
c.Columns.Delete(ctx, dataset, floatCol.ID)
c.Columns.Delete(ctx, dataset, col1.ID)
Expand Down
1 change: 0 additions & 1 deletion client/slo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ func TestSLOs(t *testing.T) {

// remove SLI DC at end of test run
t.Cleanup(func() {
//nolint:errcheck
c.DerivedColumns.Delete(ctx, dataset, sli.ID)
})

Expand Down
1 change: 0 additions & 1 deletion honeycombio/data_source_recipient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ func TestAccDataSourceHoneycombioRecipient_basic(t *testing.T) {
// update ID for removal later
testRecipients[i].ID = rcpt.ID
}
//nolint:errcheck
t.Cleanup(func() {
// remove Recipients at the of the test run
for _, r := range testRecipients {
Expand Down
1 change: 0 additions & 1 deletion honeycombio/data_source_recipients_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ func TestAccDataSourceHoneycombioRecipients_basic(t *testing.T) {
// update ID for removal later
testRecipients[i].ID = rcpt.ID
}
//nolint:errcheck
t.Cleanup(func() {
// remove Recipients at the of the test run
for _, r := range testRecipients {
Expand Down
1 change: 0 additions & 1 deletion honeycombio/data_source_trigger_recipient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ func TestAccDataSourceHoneycombioTriggerRecipient_basic(t *testing.T) {
},
})
require.NoError(t, err)
//nolint:errcheck
t.Cleanup(func() {
c.Triggers.Delete(ctx, dataset, trigger.ID)
})
Expand Down
2 changes: 0 additions & 2 deletions honeycombio/resource_board_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ func TestAccBoard_withSLOs(t *testing.T) {
})
require.NoError(t, err)

//nolint:errcheck
t.Cleanup(func() {
// remove SLOs, and SLIs at end of test run
c.SLOs.Delete(ctx, dataset, slo1.ID)
Expand Down Expand Up @@ -384,7 +383,6 @@ resource "honeycombio_board" "test" {
}`, dataset)
}

//nolint:unparam
func testAccCheckBoardExists(t *testing.T, name string) resource.TestCheckFunc {
return func(s *terraform.State) error {
resourceState, ok := s.RootModule().Resources[name]
Expand Down
20 changes: 4 additions & 16 deletions honeycombio/resource_slo.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,7 @@ func resourceSLOCreate(ctx context.Context, d *schema.ResourceData, meta interfa
}

dataset := d.Get("dataset").(string)
s, err := expandSLO(d)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unparam was correct to call out that this function could never return an error (the signature was tying to match a bunch of the other expand* helpers)

if err != nil {
return diag.FromErr(err)
}

s, err = client.SLOs.Create(ctx, dataset, s)
s, err := client.SLOs.Create(ctx, dataset, expandSLO(d))
if err != nil {
return diag.FromErr(err)
}
Expand Down Expand Up @@ -138,12 +133,7 @@ func resourceSLOUpdate(ctx context.Context, d *schema.ResourceData, meta interfa
}

dataset := d.Get("dataset").(string)
s, err := expandSLO(d)
if err != nil {
return diag.FromErr(err)
}

s, err = client.SLOs.Update(ctx, dataset, s)
s, err := client.SLOs.Update(ctx, dataset, expandSLO(d))
if err != nil {
return diag.FromErr(err)
}
Expand All @@ -167,15 +157,13 @@ func resourceSLODelete(ctx context.Context, d *schema.ResourceData, meta interfa
return nil
}

//nolint:unparam
func expandSLO(d *schema.ResourceData) (*honeycombio.SLO, error) {
s := &honeycombio.SLO{
func expandSLO(d *schema.ResourceData) *honeycombio.SLO {
return &honeycombio.SLO{
ID: d.Id(),
Name: d.Get("name").(string),
Description: d.Get("description").(string),
TimePeriodDays: d.Get("time_period").(int),
TargetPerMillion: helper.FloatToPPM(d.Get("target_percentage").(float64)),
SLI: honeycombio.SLIRef{Alias: d.Get("sli").(string)},
}
return s, nil
}
1 change: 0 additions & 1 deletion honeycombio/resource_slo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ func sloAccTestSetup(t *testing.T) (string, string) {
})
require.NoError(t, err)

//nolint:errcheck
t.Cleanup(func() {
// remove SLI DC at end of test run
c.DerivedColumns.Delete(ctx, dataset, sli.ID)
Expand Down
4 changes: 1 addition & 3 deletions internal/provider/burn_alert_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,6 @@ func TestAcc_BurnAlertResource_HandlesRecipientChangedOutsideOfTerraform(t *test
})
require.NoError(t, err, "failed to create test recipient")
t.Cleanup(func() {
//nolint:errcheck
c.Recipients.Delete(ctx, rcpt.ID)
})

Expand Down Expand Up @@ -575,7 +574,7 @@ func testAccEnsureSuccessBudgetRateAlert(t *testing.T, burnAlert *client.BurnAle
)
}

func testAccEnsureBurnAlertExists(t *testing.T, name string, burnAlert *client.BurnAlert) resource.TestCheckFunc { //nolint:unparam
func testAccEnsureBurnAlertExists(t *testing.T, name string, burnAlert *client.BurnAlert) resource.TestCheckFunc {
return func(s *terraform.State) error {
resourceState, ok := s.RootModule().Resources[name]
if !ok {
Expand Down Expand Up @@ -691,7 +690,6 @@ func burnAlertAccTestSetup(t *testing.T) (string, string) {
SLI: client.SLIRef{Alias: sli.Alias},
})
require.NoError(t, err)
//nolint:errcheck
t.Cleanup(func() {
// remove SLO, SLI DC at end of test run
c.SLOs.Delete(ctx, dataset, slo.ID)
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/dataset_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ resource "honeycombio_dataset" "test" {
}`, name, description, jsonDepth, protected)
}

func testAccEnsureDatasetExists(t *testing.T, name string) resource.TestCheckFunc { //nolint:unparam
func testAccEnsureDatasetExists(t *testing.T, name string) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[name]
if !ok {
Expand Down
1 change: 0 additions & 1 deletion internal/provider/derived_column_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ func TestAcc_DerivedColumnDataSource(t *testing.T) {
// update ID for removal later
testColumn.ID = col.ID
t.Cleanup(func() {
//nolint:errcheck
c.DerivedColumns.Delete(ctx, dataset, testColumn.ID)
})

Expand Down
1 change: 0 additions & 1 deletion internal/provider/derived_columns_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ func TestAcc_DerivedColumnsDataSource(t *testing.T) {
t.Cleanup(func() {
// remove DCs at the of the test run
for _, col := range testColumns {
//nolint:errcheck
c.DerivedColumns.Delete(ctx, dataset, col.ID)
}
})
Expand Down
1 change: 0 additions & 1 deletion internal/provider/slo_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ func TestAcc_SLODataSource(t *testing.T) {
})
require.NoError(t, err)

//nolint:errcheck
t.Cleanup(func() {
c.SLOs.Delete(ctx, dataset, slo.ID)
c.DerivedColumns.Delete(ctx, dataset, sli.ID)
Expand Down
1 change: 0 additions & 1 deletion internal/provider/slos_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ func TestAcc_SLOsDataSource(t *testing.T) {
testData[i].SLO.ID = slo.ID
}

//nolint:errcheck
t.Cleanup(func() {
// remove SLOs at the of the test run
for _, tc := range testData {
Expand Down
2 changes: 0 additions & 2 deletions internal/provider/trigger_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ func TestAcc_TriggerResourceUpdateRecipientByID(t *testing.T) {
t.Cleanup(func() {
// remove recipients at the of the test run
for _, col := range testRecipients {
//nolint:errcheck
c.DerivedColumns.Delete(ctx, dataset, col.ID)
}
})
Expand Down Expand Up @@ -532,7 +531,6 @@ func TestAcc_TriggerResourceHandlesRecipientChangedOutsideOfTerraform(t *testing
})
require.NoError(t, err, "failed to create test recipient")
t.Cleanup(func() {
//nolint:errcheck
c.Recipients.Delete(ctx, rcpt.ID)
})

Expand Down
2 changes: 1 addition & 1 deletion internal/provider/webhook_recipient_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ resource "honeycombio_webhook_recipient" "test" {
})
}

func testAccEnsureRecipientExists(t *testing.T, name string) resource.TestCheckFunc { //nolint:unparam
func testAccEnsureRecipientExists(t *testing.T, name string) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[name]
if !ok {
Expand Down