Skip to content

Commit dee3b8e

Browse files
Update golangci-lint (#606)
v1.49 now mostly supports Go 1.18 so it had lots of findings
1 parent bf062df commit dee3b8e

29 files changed

+87
-103
lines changed

.drone/drone.jsonnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ local grafanaVersions = ['9.1.0', '9.0.7', '8.5.5', '8.4.7', '8.3.7', '7.5.15'];
22
local images = {
33
go: 'golang:1.18',
44
python: 'python:3.9-alpine',
5-
lint: 'golangci/golangci-lint:v1.45',
5+
lint: 'golangci/golangci-lint:v1.49',
66
grafana(version): 'grafana/grafana:' + version,
77
};
88

.drone/drone.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ steps:
99
- commands:
1010
- golangci-lint --version
1111
- golangci-lint run ./...
12-
image: golangci/golangci-lint:v1.45
12+
image: golangci/golangci-lint:v1.49
1313
name: lint
1414
trigger:
1515
branch:
@@ -348,6 +348,6 @@ workspace:
348348
path: /drone/terraform-provider-grafana
349349
---
350350
kind: signature
351-
hmac: caf521c3c5837c7bbed6e18b4433e4e829e66b5ddc115fdeb2300e7445e5e3da
351+
hmac: 337e340b40f3e6e6fa45e74e98a2e4881bd7e45e1849b234042a39f94a0934e7
352352

353353
...

.golangci.toml

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
[run]
22
timeout = "10m"
3-
build-tags = [
4-
"cloud",
5-
"enterprise",
6-
]
7-
8-
[linters-settings.golint]
9-
min-confidence = 3
103

114
[linters-settings.goconst]
125
min-len = 5
@@ -15,14 +8,13 @@ min-occurrences = 5
158
[linters]
169
disable-all = true
1710
enable = [
18-
"bodyclose",
19-
"deadcode",
2011
"depguard",
2112
"dogsled",
13+
"exportloopref",
2214
"goconst",
2315
"gocritic",
16+
"gocyclo",
2417
"goimports",
25-
"golint",
2618
"goprintffuncname",
2719
"gosec",
2820
"gosimple",
@@ -31,17 +23,13 @@ enable = [
3123
"misspell",
3224
"nakedret",
3325
"rowserrcheck",
34-
"exportloopref",
3526
"staticcheck",
36-
"structcheck",
3727
"stylecheck",
3828
"typecheck",
3929
"unconvert",
40-
"unused",
41-
"varcheck",
42-
"whitespace",
43-
"gocyclo",
4430
"unparam",
31+
"unused",
32+
"whitespace"
4533
]
4634

4735
[[issues.exclude-rules]]

GNUmakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ golangci-lint:
5151
--rm \
5252
--volume "$(shell pwd):/src" \
5353
--workdir "/src" \
54-
golangci/golangci-lint:v1.45 golangci-lint run ./...
54+
golangci/golangci-lint:v1.49 golangci-lint run ./...
5555

5656
linkcheck:
5757
docker run -it --entrypoint sh -v "$$PWD:$$PWD" -w "$$PWD" python:3.9-alpine -c "pip3 install linkchecker && linkchecker --config .linkcheckerrc docs"

grafana/data_source_cloud_ips.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package grafana
22

33
import (
44
"context"
5-
"fmt"
65
"io"
76
"net/http"
87
"strings"
@@ -89,7 +88,7 @@ func dataSourceCloudIPsRead(ctx context.Context, d *schema.ResourceData, meta in
8988
}
9089

9190
if err := d.Set(attr, ipStr); err != nil {
92-
return diag.FromErr(fmt.Errorf("error setting %s: %v", attr, err))
91+
return diag.Errorf("error setting %s: %v", attr, err)
9392
}
9493
}
9594

grafana/data_source_folders.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package grafana
22

33
import (
44
"context"
5-
"fmt"
65

76
gapi "github.com/grafana/grafana-api-golang-client"
87
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
@@ -65,7 +64,7 @@ func readFolders(ctx context.Context, d *schema.ResourceData, meta interface{})
6564
d.SetId("grafana_folders")
6665

6766
if err := d.Set("folders", flattenFolders(folders)); err != nil {
68-
return diag.FromErr(fmt.Errorf("error setting item: %v", err))
67+
return diag.Errorf("error setting item: %v", err)
6968
}
7069

7170
return nil

grafana/data_source_oncall_action.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ func dataSourceOnCallActionRead(d *schema.ResourceData, m interface{}) error {
4848
return fmt.Errorf("more than one action found matching: %s", options.Name)
4949
}
5050

51-
custom_action := customActionsResponse.CustomActions[0]
51+
customAction := customActionsResponse.CustomActions[0]
5252

53-
d.SetId(custom_action.ID)
54-
d.Set("name", custom_action.Name)
53+
d.SetId(customAction.ID)
54+
d.Set("name", customAction.Name)
5555

5656
return nil
5757
}

grafana/data_source_oncall_user_group.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ func dataSourceOnCallUserGroupRead(d *schema.ResourceData, m interface{}) error
4848
return fmt.Errorf("couldn't find a user group matching: %s", options.SlackHandle)
4949
}
5050

51-
user_group := userGroupsResponse.UserGroups[0]
51+
userGroup := userGroupsResponse.UserGroups[0]
5252

53-
d.SetId(user_group.ID)
54-
d.Set("slack_id", user_group.SlackUserGroup.ID)
53+
d.SetId(userGroup.ID)
54+
d.Set("slack_id", userGroup.SlackUserGroup.ID)
5555

5656
return nil
5757
}

grafana/data_source_slack_channel.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ func dataSourceOnCallSlackChannelRead(d *schema.ResourceData, m interface{}) err
5050
return fmt.Errorf("more than one slack_channel found matching: %s", options.ChannelName)
5151
}
5252

53-
slack_channel := slackChannelsResponse.SlackChannels[0]
53+
slackChannel := slackChannelsResponse.SlackChannels[0]
5454

55-
d.SetId(slack_channel.SlackId)
56-
d.Set("name", slack_channel.Name)
57-
d.Set("slack_id", slack_channel.SlackId)
55+
d.SetId(slackChannel.SlackId)
56+
d.Set("name", slackChannel.Name)
57+
d.Set("slack_id", slackChannel.SlackId)
5858

5959
return nil
6060
}

grafana/provider.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ func createGrafanaClient(d *schema.ResourceData) (string, *gapi.Config, *gapi.Cl
332332
}
333333

334334
apiURL := d.Get("url").(string)
335-
cli.Transport = logging.NewTransport("Grafana", transport)
335+
cli.Transport = logging.NewSubsystemLoggingHTTPTransport("Grafana", transport)
336336
cfg := gapi.Config{
337337
Client: cli,
338338
NumRetries: d.Get("retries").(int),
@@ -405,8 +405,8 @@ func createSMClient(d *schema.ResourceData) (string, *smapi.Client) {
405405

406406
func createOnCallClient(d *schema.ResourceData) (*onCallAPI.Client, error) {
407407
aToken := d.Get("oncall_access_token").(string)
408-
base_url := d.Get("oncall_url").(string)
409-
return onCallAPI.New(base_url, aToken)
408+
baseURL := d.Get("oncall_url").(string)
409+
return onCallAPI.New(baseURL, aToken)
410410
}
411411

412412
// getJSONMap is a helper function that parses the given environment variable as a JSON object

0 commit comments

Comments
 (0)