Use revive instead of golint (#1685)
Signed-off-by: pigletfly <wangbing.adam@gmail.com> Co-authored-by: Yaron Schneider <schneider.yaron@live.com>
This commit is contained in:
parent
47db6cc2b1
commit
db99b43068
|
@ -33,7 +33,7 @@ jobs:
|
||||||
GOOS: ${{ matrix.target_os }}
|
GOOS: ${{ matrix.target_os }}
|
||||||
GOARCH: ${{ matrix.target_arch }}
|
GOARCH: ${{ matrix.target_arch }}
|
||||||
GOPROXY: https://proxy.golang.org
|
GOPROXY: https://proxy.golang.org
|
||||||
GOLANGCI_LINT_VER: v1.31
|
GOLANGCI_LINT_VER: v1.45.2
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macOS-latest]
|
os: [ubuntu-latest, windows-latest, macOS-latest]
|
||||||
|
|
|
@ -28,7 +28,7 @@ run:
|
||||||
# won't be reported. Default value is empty list, but there is
|
# won't be reported. Default value is empty list, but there is
|
||||||
# no need to include all autogenerated files, we confidently recognize
|
# no need to include all autogenerated files, we confidently recognize
|
||||||
# autogenerated files. If it's not please let us know.
|
# autogenerated files. If it's not please let us know.
|
||||||
skip-files:
|
# skip-files:
|
||||||
# - ".*\\.my\\.go$"
|
# - ".*\\.my\\.go$"
|
||||||
# - lib/bad.go
|
# - lib/bad.go
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ linters-settings:
|
||||||
|
|
||||||
# path to a file containing a list of functions to exclude from checking
|
# path to a file containing a list of functions to exclude from checking
|
||||||
# see https://github.com/kisielk/errcheck#excluding-functions for details
|
# see https://github.com/kisielk/errcheck#excluding-functions for details
|
||||||
exclude:
|
# exclude:
|
||||||
|
|
||||||
funlen:
|
funlen:
|
||||||
lines: 60
|
lines: 60
|
||||||
|
@ -88,9 +88,9 @@ linters-settings:
|
||||||
disable:
|
disable:
|
||||||
- shadow
|
- shadow
|
||||||
disable-all: false
|
disable-all: false
|
||||||
golint:
|
revive:
|
||||||
# minimal confidence for issues, default is 0.8
|
# minimal confidence for issues, default is 0.8
|
||||||
min-confidence: 0.8
|
confidence: 0.8
|
||||||
gofmt:
|
gofmt:
|
||||||
# simplify code: gofmt with `-s` option, true by default
|
# simplify code: gofmt with `-s` option, true by default
|
||||||
simplify: true
|
simplify: true
|
||||||
|
@ -127,7 +127,7 @@ linters-settings:
|
||||||
# Correct spellings using locale preferences for US or UK.
|
# Correct spellings using locale preferences for US or UK.
|
||||||
# Default is to use a neutral variety of English.
|
# Default is to use a neutral variety of English.
|
||||||
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
|
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
|
||||||
locale: default
|
# locale: Default
|
||||||
ignore-words:
|
ignore-words:
|
||||||
- someword
|
- someword
|
||||||
lll:
|
lll:
|
||||||
|
@ -165,7 +165,7 @@ linters-settings:
|
||||||
# See https://go-critic.github.io/overview#checks-overview
|
# See https://go-critic.github.io/overview#checks-overview
|
||||||
# To check which checks are enabled run `GL_DEBUG=gocritic golangci-lint run`
|
# To check which checks are enabled run `GL_DEBUG=gocritic golangci-lint run`
|
||||||
# By default list of stable checks is used.
|
# 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
|
# Which checks should be disabled; can't be combined with 'enabled-checks'; default is empty
|
||||||
disabled-checks:
|
disabled-checks:
|
||||||
|
@ -246,3 +246,28 @@ linters:
|
||||||
- exhaustive
|
- exhaustive
|
||||||
- noctx
|
- noctx
|
||||||
- gci
|
- 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
|
||||||
|
|
|
@ -21,7 +21,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/a8m/documentdb"
|
"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/authentication/azure"
|
||||||
"github.com/dapr/components-contrib/bindings"
|
"github.com/dapr/components-contrib/bindings"
|
||||||
|
|
|
@ -25,7 +25,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestParseMetadata(t *testing.T) {
|
func TestParseMetadata(t *testing.T) {
|
||||||
var oneSecondDuration time.Duration = time.Second
|
oneSecondDuration := time.Second
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
|
|
|
@ -19,7 +19,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/robfig/cron/v3"
|
cron "github.com/robfig/cron/v3"
|
||||||
|
|
||||||
"github.com/dapr/components-contrib/bindings"
|
"github.com/dapr/components-contrib/bindings"
|
||||||
"github.com/dapr/kit/logger"
|
"github.com/dapr/kit/logger"
|
||||||
|
|
|
@ -33,7 +33,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// HTTPSource is a binding for an http url endpoint invocation
|
// HTTPSource is a binding for an http url endpoint invocation
|
||||||
// nolint:golint
|
//revive:disable-next-line
|
||||||
type HTTPSource struct {
|
type HTTPSource struct {
|
||||||
metadata httpMetadata
|
metadata httpMetadata
|
||||||
client *http.Client
|
client *http.Client
|
||||||
|
|
|
@ -20,7 +20,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/DATA-DOG/go-sqlmock"
|
sqlmock "github.com/DATA-DOG/go-sqlmock"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
"github.com/dapr/components-contrib/bindings"
|
"github.com/dapr/components-contrib/bindings"
|
||||||
|
|
|
@ -27,7 +27,7 @@ import (
|
||||||
func TestParseMetadata(t *testing.T) {
|
func TestParseMetadata(t *testing.T) {
|
||||||
const queueName = "test-queue"
|
const queueName = "test-queue"
|
||||||
const host = "test-host"
|
const host = "test-host"
|
||||||
var oneSecondTTL time.Duration = time.Second
|
oneSecondTTL := time.Second
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
|
|
|
@ -17,7 +17,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/alicebob/miniredis/v2"
|
miniredis "github.com/alicebob/miniredis/v2"
|
||||||
"github.com/go-redis/redis/v8"
|
"github.com/go-redis/redis/v8"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ type mockClient struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mcf mockClientFactory) Get(metadata bindings.Metadata) (zbc.Client, error) {
|
func (mcf mockClientFactory) Get(metadata bindings.Metadata) (zbc.Client, error) {
|
||||||
|
//nolint:staticcheck
|
||||||
mcf.metadata = metadata
|
mcf.metadata = metadata
|
||||||
|
|
||||||
if mcf.error != nil {
|
if mcf.error != nil {
|
||||||
|
|
|
@ -36,6 +36,7 @@ type mockClient struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mcf mockClientFactory) Get(metadata bindings.Metadata) (zbc.Client, error) {
|
func (mcf mockClientFactory) Get(metadata bindings.Metadata) (zbc.Client, error) {
|
||||||
|
//nolint:staticcheck
|
||||||
mcf.metadata = metadata
|
mcf.metadata = metadata
|
||||||
|
|
||||||
if mcf.error != nil {
|
if mcf.error != nil {
|
||||||
|
|
|
@ -327,7 +327,7 @@ func mapAdvancedRegistration(config *AgentServiceRegistration) *consul.AgentServ
|
||||||
return mapped
|
return mapped
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint:golint,stylecheck
|
//nolint:stylecheck
|
||||||
type HttpBasicAuth struct {
|
type HttpBasicAuth struct {
|
||||||
Username string
|
Username string
|
||||||
Password string
|
Password string
|
||||||
|
@ -337,11 +337,12 @@ type Config struct {
|
||||||
Address string
|
Address string
|
||||||
Scheme string
|
Scheme string
|
||||||
Datacenter string
|
Datacenter string
|
||||||
HttpAuth *HttpBasicAuth //nolint:golint,stylecheck
|
//nolint:stylecheck
|
||||||
WaitTime time.Duration
|
HttpAuth *HttpBasicAuth
|
||||||
Token string
|
WaitTime time.Duration
|
||||||
TokenFile string
|
Token string
|
||||||
TLSConfig TLSConfig
|
TokenFile string
|
||||||
|
TLSConfig TLSConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
type TLSConfig struct {
|
type TLSConfig struct {
|
||||||
|
|
|
@ -114,7 +114,6 @@ func NewPubsubMessageFromASBMessage(asbMsg *azservicebus.Message, topic string)
|
||||||
// Always set delivery count.
|
// Always set delivery count.
|
||||||
addToMetadata(pubsubMsg, DeliveryCountMetadataKey, strconv.FormatInt(int64(asbMsg.DeliveryCount), 10))
|
addToMetadata(pubsubMsg, DeliveryCountMetadataKey, strconv.FormatInt(int64(asbMsg.DeliveryCount), 10))
|
||||||
|
|
||||||
//nolint:golint,nestif
|
|
||||||
if asbMsg.SystemProperties != nil {
|
if asbMsg.SystemProperties != nil {
|
||||||
systemProps := asbMsg.SystemProperties
|
systemProps := asbMsg.SystemProperties
|
||||||
if systemProps.EnqueuedTime != nil {
|
if systemProps.EnqueuedTime != nil {
|
||||||
|
|
|
@ -15,10 +15,10 @@ package secretstores
|
||||||
|
|
||||||
// SecretStore is the interface for a component that handles secrets management.
|
// SecretStore is the interface for a component that handles secrets management.
|
||||||
type SecretStore interface {
|
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
|
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)
|
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)
|
BulkGetSecret(req BulkGetSecretRequest) (BulkGetSecretResponse, error)
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,7 +117,7 @@ func TestETagToCas(t *testing.T) {
|
||||||
t.Run("with valid string", func(t *testing.T) {
|
t.Run("with valid string", func(t *testing.T) {
|
||||||
casStr := "1572938024378368000"
|
casStr := "1572938024378368000"
|
||||||
ver := uint64(1572938024378368000)
|
ver := uint64(1572938024378368000)
|
||||||
var expectedCas gocb.Cas = gocb.Cas(ver)
|
expectedCas := gocb.Cas(ver)
|
||||||
cas, err := eTagToCas(casStr)
|
cas, err := eTagToCas(casStr)
|
||||||
assert.Equal(t, nil, err)
|
assert.Equal(t, nil, err)
|
||||||
assert.Equal(t, expectedCas, cas)
|
assert.Equal(t, expectedCas, cas)
|
||||||
|
|
|
@ -411,7 +411,7 @@ func (p *postgresDBAccess) ensureStateTable(stateTableName string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func tableExists(db *sql.DB, tableName string) (bool, 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)
|
err := db.QueryRow("SELECT EXISTS (SELECT FROM pg_tables where tablename = $1)", tableName).Scan(&exists)
|
||||||
|
|
||||||
return exists, err
|
return exists, err
|
||||||
|
|
|
@ -556,7 +556,7 @@ func storeItemExists(t *testing.T, key string) bool {
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
defer db.Close()
|
defer db.Close()
|
||||||
|
|
||||||
var exists bool = false
|
exists := false
|
||||||
statement := fmt.Sprintf(`SELECT EXISTS (SELECT FROM %s WHERE key = $1)`, tableName)
|
statement := fmt.Sprintf(`SELECT EXISTS (SELECT FROM %s WHERE key = $1)`, tableName)
|
||||||
err = db.QueryRow(statement, key).Scan(&exists)
|
err = db.QueryRow(statement, key).Scan(&exists)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|
|
@ -403,7 +403,6 @@ func (r *StateStore) Multi(request *state.TransactionalStateRequest) error {
|
||||||
|
|
||||||
pipe := r.client.TxPipeline()
|
pipe := r.client.TxPipeline()
|
||||||
for _, o := range request.Operations {
|
for _, o := range request.Operations {
|
||||||
//nolint:golint,nestif
|
|
||||||
if o.Operation == state.Upsert {
|
if o.Operation == state.Upsert {
|
||||||
req := o.Request.(state.SetRequest)
|
req := o.Request.(state.SetRequest)
|
||||||
ver, err := r.parseETag(&req)
|
ver, err := r.parseETag(&req)
|
||||||
|
|
Loading…
Reference in New Issue