Skip to content

Commit 0bf67c4

Browse files
committed
#patch: add linting
1 parent 0b73702 commit 0bf67c4

File tree

7 files changed

+51
-10
lines changed

7 files changed

+51
-10
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ jobs:
3232
- name: golangci-lint
3333
uses: golangci/golangci-lint-action@v2
3434
with:
35-
version: v1.37
35+
version: v1.37.1

.golangci.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
linters:
2+
enable:
3+
- bodyclose
4+
- cyclop
5+
- deadcode
6+
- depguard
7+
- dogsled
8+
- dupl
9+
- errcheck
10+
- errorlint
11+
- exhaustive
12+
- exportloopref
13+
- forbidigo
14+
- funlen
15+
- goconst
16+
- gocritic
17+
- gocyclo
18+
- gofmt
19+
- goimports
20+
- golint
21+
- gomnd
22+
- goprintffuncname
23+
- gosec
24+
- gosimple
25+
- govet
26+
- ineffassign
27+
- interfacer
28+
- lll
29+
- misspell
30+
- nakedret
31+
- nolintlint
32+
- rowserrcheck
33+
- scopelint
34+
- staticcheck
35+
- structcheck
36+
- stylecheck
37+
- typecheck
38+
- unconvert
39+
- unparam
40+
- unused
41+
- varcheck
42+
- whitespace

main.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
package main
22

33
import (
4-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
54
"github.com/hashicorp/terraform-plugin-sdk/v2/plugin"
65

76
"github.com/circa10a/terraform-provider-mcbroken/mcbroken"
87
)
98

109
func main() {
1110
plugin.Serve(&plugin.ServeOpts{
12-
ProviderFunc: func() *schema.Provider {
13-
return mcbroken.Provider()
14-
},
11+
ProviderFunc: mcbroken.Provider,
1512
})
1613
}

mcbroken/data_source_cities.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ func dataSourceCities() *schema.Resource {
4040
}
4141

4242
func dataSourceCitiesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
43-
client := &http.Client{Timeout: 10 * time.Second}
43+
var httpTimeout time.Duration = 10
44+
client := &http.Client{Timeout: httpTimeout * time.Second}
4445
providerConfig := m.(map[string]interface{})
4546
url := providerConfig["url"].(string)
4647

mcbroken/data_source_cities_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88
)
99

1010
func TestAccMcbrokenCities(t *testing.T) {
11-
brokenNumberRegex, _ := regexp.Compile(`\d{1,3}(.\d{1,2})?`)
12-
cityRegex, _ := regexp.Compile(`[a-zA-Z]+$`)
11+
brokenNumberRegex := regexp.MustCompile(`\d{1,3}(.\d{1,2})?`)
12+
cityRegex := regexp.MustCompile(`[a-zA-Z]+$`)
1313
resource.ParallelTest(t, resource.TestCase{
1414
PreCheck: func() { /* no precheck needed testAccPreCheck(t) */ },
1515
ProviderFactories: testAccProviderFactories,

mcbroken/data_source_city.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ func dataSourceCity() *schema.Resource {
3030
}
3131

3232
func dataSourceCityRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
33-
client := &http.Client{Timeout: 10 * time.Second}
33+
var httpTimeout time.Duration = 10
34+
client := &http.Client{Timeout: httpTimeout * time.Second}
3435
providerConfig := m.(map[string]interface{})
3536
url := providerConfig["url"].(string)
3637
userChosenCity := d.Get("city").(string)

mcbroken/data_source_city_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
)
1111

1212
func TestAccMcbrokenCity(t *testing.T) {
13-
brokenNumberRegex, _ := regexp.Compile(`\d{1,3}(.\d{1,2})?`)
13+
brokenNumberRegex := regexp.MustCompile(`\d{1,3}(.\d{1,2})?`)
1414
resource.ParallelTest(t, resource.TestCase{
1515
PreCheck: func() { /* no precheck needed testAccPreCheck(t) */ },
1616
ProviderFactories: testAccProviderFactories,

0 commit comments

Comments
 (0)