Skip to content

Commit

Permalink
Finalised configuration for golangci-lint
Browse files Browse the repository at this point in the history
Lots of additional linters, pretty happy about it.
  • Loading branch information
detro committed Jul 11, 2022
1 parent 4221b3d commit c5d401d
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 13 deletions.
28 changes: 28 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,42 @@ linters:

# Additional linters enabled
enable:
- asciicheck
- bidichk
- bodyclose
- contextcheck
- cyclop
- decorder
- dogsled
- durationcheck
- errname
- errorlint
- exhaustive
- exportloopref
- gci
- gochecknoglobals
- goconst
- gocritic
- godot
- gofmt
- gomoddirectives
- goprintffuncname
- gosec
- ifshort
- importas
- makezero
- misspell
- nakedret
- nilerr
- nilnil
- nosprintfhostport
- prealloc
- predeclared
- revive
- tenv
- testpackage
- unconvert
- unparam
- wastedassign
- whitespace
- wrapcheck
7 changes: 4 additions & 3 deletions internal/client/client_test.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package client
package client_test

import (
"testing"

testifyAssert "github.com/stretchr/testify/assert"
"github.com/tfzk/terraform-provider-zookeeper/internal/client"
)

func initTest(t *testing.T) (*Client, *testifyAssert.Assertions) {
func initTest(t *testing.T) (*client.Client, *testifyAssert.Assertions) {
assert := testifyAssert.New(t)

client, err := NewClientFromEnv()
client, err := client.NewClientFromEnv()
assert.NoError(err)

return client, assert
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/data_source_znode_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package provider
package provider_test

import (
"fmt"
Expand Down
9 changes: 4 additions & 5 deletions internal/provider/provider_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package provider
package provider_test

import (
"fmt"
Expand All @@ -9,12 +9,13 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
testifyAssert "github.com/stretchr/testify/assert"
"github.com/tfzk/terraform-provider-zookeeper/internal/client"
"github.com/tfzk/terraform-provider-zookeeper/internal/provider"
)

func TestProvider(t *testing.T) {
assert := testifyAssert.New(t)

provider, err := New()
provider, err := provider.New()
assert.NoError(err)

assert.NoError(provider.InternalValidate())
Expand All @@ -29,9 +30,7 @@ func TestProvider(t *testing.T) {
// the provider and `terraform init` should be executed.
func providerFactoriesMap() map[string]func() (*schema.Provider, error) {
return map[string]func() (*schema.Provider, error){
"zookeeper": func() (*schema.Provider, error) {
return New()
},
"zookeeper": provider.New,
}
}

Expand Down
5 changes: 3 additions & 2 deletions internal/provider/resource_sequential_znode.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package provider

import (
"context"
"fmt"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand Down Expand Up @@ -95,11 +96,11 @@ func resourceSeqZNodeDelete(ctx context.Context, rscData *schema.ResourceData, p
return resourceZNodeDelete(ctx, rscData, prvClient)
}

func resourceSeqZNodeImport(_ context.Context, rscData *schema.ResourceData, prvClient interface{}) ([]*schema.ResourceData, error) {
func resourceSeqZNodeImport(_ context.Context, rscData *schema.ResourceData, _ interface{}) ([]*schema.ResourceData, error) {
// Re-create the original `path_prefix` for the imported `sequential_znode`,
// by removing the sequential suffix from the `id` (i.e. `path`)
if err := rscData.Set("path_prefix", client.RemoveSequentialSuffix(rscData.Id())); err != nil {
return nil, err
return nil, fmt.Errorf("failed to import Sequential ZNode: %w", err)
}

return []*schema.ResourceData{rscData}, nil
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/resource_sequential_znode_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package provider
package provider_test

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/resource_znode_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package provider
package provider_test

import (
"fmt"
Expand Down

0 comments on commit c5d401d

Please sign in to comment.