Skip to content

Commit

Permalink
Use revive instead of golint
Browse files Browse the repository at this point in the history
Signed-off-by: pigletfly <[email protected]>
  • Loading branch information
pigletfly committed May 5, 2022
1 parent bfd87eb commit da368a1
Show file tree
Hide file tree
Showing 18 changed files with 54 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/components-contrib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
GOOS: ${{ matrix.target_os }}
GOARCH: ${{ matrix.target_arch }}
GOPROXY: https://proxy.golang.org
GOLANGCI_LINT_VER: v1.31
GOLANGCI_LINT_VER: v1.45.2
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
Expand Down
37 changes: 31 additions & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ run:
# won't be reported. Default value is empty list, but there is
# no need to include all autogenerated files, we confidently recognize
# autogenerated files. If it's not please let us know.
skip-files:
# skip-files:
# - ".*\\.my\\.go$"
# - lib/bad.go

Expand Down Expand Up @@ -62,7 +62,7 @@ linters-settings:

# path to a file containing a list of functions to exclude from checking
# see https://github.com/kisielk/errcheck#excluding-functions for details
exclude:
# exclude:

funlen:
lines: 60
Expand All @@ -88,9 +88,9 @@ linters-settings:
disable:
- shadow
disable-all: false
golint:
revive:
# minimal confidence for issues, default is 0.8
min-confidence: 0.8
confidence: 0.8
gofmt:
# simplify code: gofmt with `-s` option, true by default
simplify: true
Expand Down Expand Up @@ -127,7 +127,7 @@ linters-settings:
# Correct spellings using locale preferences for US or UK.
# Default is to use a neutral variety of English.
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
locale: default
# locale: Default
ignore-words:
- someword
lll:
Expand Down Expand Up @@ -165,7 +165,7 @@ linters-settings:
# See https://go-critic.github.io/overview#checks-overview
# To check which checks are enabled run `GL_DEBUG=gocritic golangci-lint run`
# By default list of stable checks is used.
enabled-checks:
# enabled-checks:

# Which checks should be disabled; can't be combined with 'enabled-checks'; default is empty
disabled-checks:
Expand Down Expand Up @@ -246,3 +246,28 @@ linters:
- exhaustive
- noctx
- gci
- golint
- tparallel
- paralleltest
- wrapcheck
- tagliatelle
- ireturn
- exhaustivestruct
- errchkjson
- contextcheck
- gomoddirectives
- godot
- cyclop
- varnamelen
- gosec
- errorlint
- forcetypeassert
- ifshort
- maintidx
- nilnil
- predeclared
- tenv
- thelper
- wastedassign
- containedctx
- gosimple
2 changes: 1 addition & 1 deletion bindings/azure/cosmosdb/cosmosdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"time"

"github.com/a8m/documentdb"
"github.com/cenkalti/backoff/v4"
backoff "github.com/cenkalti/backoff/v4"

"github.com/dapr/components-contrib/authentication/azure"
"github.com/dapr/components-contrib/bindings"
Expand Down
2 changes: 1 addition & 1 deletion bindings/azure/servicebusqueues/servicebusqueues_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
)

func TestParseMetadata(t *testing.T) {
var oneSecondDuration time.Duration = time.Second
oneSecondDuration := time.Second

testCases := []struct {
name string
Expand Down
2 changes: 1 addition & 1 deletion bindings/cron/cron.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"time"

"github.com/pkg/errors"
"github.com/robfig/cron/v3"
cron "github.com/robfig/cron/v3"

"github.com/dapr/components-contrib/bindings"
"github.com/dapr/kit/logger"
Expand Down
2 changes: 1 addition & 1 deletion bindings/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
)

// HTTPSource is a binding for an http url endpoint invocation
// nolint:golint
//revive:disable-next-line
type HTTPSource struct {
metadata httpMetadata
client *http.Client
Expand Down
2 changes: 1 addition & 1 deletion bindings/mysql/mysql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"testing"
"time"

"github.com/DATA-DOG/go-sqlmock"
sqlmock "github.com/DATA-DOG/go-sqlmock"
"github.com/stretchr/testify/assert"

"github.com/dapr/components-contrib/bindings"
Expand Down
2 changes: 1 addition & 1 deletion bindings/rabbitmq/rabbitmq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
func TestParseMetadata(t *testing.T) {
const queueName = "test-queue"
const host = "test-host"
var oneSecondTTL time.Duration = time.Second
oneSecondTTL := time.Second

testCases := []struct {
name string
Expand Down
2 changes: 1 addition & 1 deletion bindings/redis/redis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"context"
"testing"

"github.com/alicebob/miniredis/v2"
miniredis "github.com/alicebob/miniredis/v2"
"github.com/go-redis/redis/v8"
"github.com/stretchr/testify/assert"

Expand Down
1 change: 1 addition & 0 deletions bindings/zeebe/command/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type mockClient struct {
}

func (mcf mockClientFactory) Get(metadata bindings.Metadata) (zbc.Client, error) {
//nolint:staticcheck
mcf.metadata = metadata

if mcf.error != nil {
Expand Down
1 change: 1 addition & 0 deletions bindings/zeebe/jobworker/jobworker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type mockClient struct {
}

func (mcf mockClientFactory) Get(metadata bindings.Metadata) (zbc.Client, error) {
//nolint:staticcheck
mcf.metadata = metadata

if mcf.error != nil {
Expand Down
13 changes: 7 additions & 6 deletions nameresolution/consul/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ func mapAdvancedRegistration(config *AgentServiceRegistration) *consul.AgentServ
return mapped
}

//nolint:golint,stylecheck
//nolint:stylecheck
type HttpBasicAuth struct {
Username string
Password string
Expand All @@ -337,11 +337,12 @@ type Config struct {
Address string
Scheme string
Datacenter string
HttpAuth *HttpBasicAuth //nolint:golint,stylecheck
WaitTime time.Duration
Token string
TokenFile string
TLSConfig TLSConfig
//nolint:stylecheck
HttpAuth *HttpBasicAuth
WaitTime time.Duration
Token string
TokenFile string
TLSConfig TLSConfig
}

type TLSConfig struct {
Expand Down
1 change: 0 additions & 1 deletion pubsub/azure/servicebus/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ func NewPubsubMessageFromASBMessage(asbMsg *azservicebus.Message, topic string)
// Always set delivery count.
addToMetadata(pubsubMsg, DeliveryCountMetadataKey, strconv.FormatInt(int64(asbMsg.DeliveryCount), 10))

//nolint:golint,nestif
if asbMsg.SystemProperties != nil {
systemProps := asbMsg.SystemProperties
if systemProps.EnqueuedTime != nil {
Expand Down
6 changes: 3 additions & 3 deletions secretstores/secret_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ package secretstores

// SecretStore is the interface for a component that handles secrets management.
type SecretStore interface {
// Init authenticates with the actual secret store and performs other init operation
// Init authenticates with the actual secret store and performs other init operation.
Init(metadata Metadata) error
// GetSecret retrieves a secret using a key and returns a map of decrypted string/string values
// GetSecret retrieves a secret using a key and returns a map of decrypted string/string values.
GetSecret(req GetSecretRequest) (GetSecretResponse, error)
// BulkGetSecret retrieves all secrets in the store and returns a map of decrypted string/string values
// BulkGetSecret retrieves all secrets in the store and returns a map of decrypted string/string values.
BulkGetSecret(req BulkGetSecretRequest) (BulkGetSecretResponse, error)
}
2 changes: 1 addition & 1 deletion state/couchbase/couchbase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func TestETagToCas(t *testing.T) {
t.Run("with valid string", func(t *testing.T) {
casStr := "1572938024378368000"
ver := uint64(1572938024378368000)
var expectedCas gocb.Cas = gocb.Cas(ver)
expectedCas := gocb.Cas(ver)
cas, err := eTagToCas(casStr)
assert.Equal(t, nil, err)
assert.Equal(t, expectedCas, cas)
Expand Down
2 changes: 1 addition & 1 deletion state/postgresql/postgresdbaccess.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ func (p *postgresDBAccess) ensureStateTable(stateTableName string) error {
}

func tableExists(db *sql.DB, tableName string) (bool, error) {
var exists bool = false
exists := false
err := db.QueryRow("SELECT EXISTS (SELECT FROM pg_tables where tablename = $1)", tableName).Scan(&exists)

return exists, err
Expand Down
2 changes: 1 addition & 1 deletion state/postgresql/postgresql_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ func storeItemExists(t *testing.T, key string) bool {
assert.Nil(t, err)
defer db.Close()

var exists bool = false
exists := false
statement := fmt.Sprintf(`SELECT EXISTS (SELECT FROM %s WHERE key = $1)`, tableName)
err = db.QueryRow(statement, key).Scan(&exists)
assert.Nil(t, err)
Expand Down
1 change: 0 additions & 1 deletion state/redis/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,6 @@ func (r *StateStore) Multi(request *state.TransactionalStateRequest) error {

pipe := r.client.TxPipeline()
for _, o := range request.Operations {
//nolint:golint,nestif
if o.Operation == state.Upsert {
req := o.Request.(state.SetRequest)
ver, err := r.parseETag(&req)
Expand Down

0 comments on commit da368a1

Please sign in to comment.