Skip to content

Commit

Permalink
#patch: add linting
Browse files Browse the repository at this point in the history
  • Loading branch information
circa10a committed Feb 21, 2021
1 parent 0b73702 commit 0bf67c4
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.37
version: v1.37.1
42 changes: 42 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
linters:
enable:
- bodyclose
- cyclop
- deadcode
- depguard
- dogsled
- dupl
- errcheck
- errorlint
- exhaustive
- exportloopref
- forbidigo
- funlen
- goconst
- gocritic
- gocyclo
- gofmt
- goimports
- golint
- gomnd
- goprintffuncname
- gosec
- gosimple
- govet
- ineffassign
- interfacer
- lll
- misspell
- nakedret
- nolintlint
- rowserrcheck
- scopelint
- staticcheck
- structcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- varcheck
- whitespace
5 changes: 1 addition & 4 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
package main

import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/plugin"

"github.com/circa10a/terraform-provider-mcbroken/mcbroken"
)

func main() {
plugin.Serve(&plugin.ServeOpts{
ProviderFunc: func() *schema.Provider {
return mcbroken.Provider()
},
ProviderFunc: mcbroken.Provider,
})
}
3 changes: 2 additions & 1 deletion mcbroken/data_source_cities.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ func dataSourceCities() *schema.Resource {
}

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

Expand Down
4 changes: 2 additions & 2 deletions mcbroken/data_source_cities_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
)

func TestAccMcbrokenCities(t *testing.T) {
brokenNumberRegex, _ := regexp.Compile(`\d{1,3}(.\d{1,2})?`)
cityRegex, _ := regexp.Compile(`[a-zA-Z]+$`)
brokenNumberRegex := regexp.MustCompile(`\d{1,3}(.\d{1,2})?`)
cityRegex := regexp.MustCompile(`[a-zA-Z]+$`)
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { /* no precheck needed testAccPreCheck(t) */ },
ProviderFactories: testAccProviderFactories,
Expand Down
3 changes: 2 additions & 1 deletion mcbroken/data_source_city.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ func dataSourceCity() *schema.Resource {
}

func dataSourceCityRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
client := &http.Client{Timeout: 10 * time.Second}
var httpTimeout time.Duration = 10
client := &http.Client{Timeout: httpTimeout * time.Second}
providerConfig := m.(map[string]interface{})
url := providerConfig["url"].(string)
userChosenCity := d.Get("city").(string)
Expand Down
2 changes: 1 addition & 1 deletion mcbroken/data_source_city_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

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

0 comments on commit 0bf67c4

Please sign in to comment.