Skip to content

Commit aa2daca

Browse files
pigletflyyaron2
authored and
Chen Cong
committed
Use revive instead of golint (dapr#1685)
Signed-off-by: pigletfly <[email protected]> Co-authored-by: Yaron Schneider <[email protected]> Signed-off-by: Chen Cong <[email protected]>
1 parent 89a66a9 commit aa2daca

File tree

18 files changed

+54
-28
lines changed

18 files changed

+54
-28
lines changed

.github/workflows/components-contrib.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
GOOS: ${{ matrix.target_os }}
3434
GOARCH: ${{ matrix.target_arch }}
3535
GOPROXY: https://proxy.golang.org
36-
GOLANGCI_LINT_VER: v1.31
36+
GOLANGCI_LINT_VER: v1.45.2
3737
strategy:
3838
matrix:
3939
os: [ubuntu-latest, windows-latest, macOS-latest]

.golangci.yml

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ run:
2828
# won't be reported. Default value is empty list, but there is
2929
# no need to include all autogenerated files, we confidently recognize
3030
# autogenerated files. If it's not please let us know.
31-
skip-files:
31+
# skip-files:
3232
# - ".*\\.my\\.go$"
3333
# - lib/bad.go
3434

@@ -62,7 +62,7 @@ linters-settings:
6262

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

6767
funlen:
6868
lines: 60
@@ -88,9 +88,9 @@ linters-settings:
8888
disable:
8989
- shadow
9090
disable-all: false
91-
golint:
91+
revive:
9292
# minimal confidence for issues, default is 0.8
93-
min-confidence: 0.8
93+
confidence: 0.8
9494
gofmt:
9595
# simplify code: gofmt with `-s` option, true by default
9696
simplify: true
@@ -127,7 +127,7 @@ linters-settings:
127127
# Correct spellings using locale preferences for US or UK.
128128
# Default is to use a neutral variety of English.
129129
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
130-
locale: default
130+
# locale: Default
131131
ignore-words:
132132
- someword
133133
lll:
@@ -165,7 +165,7 @@ linters-settings:
165165
# See https://go-critic.github.io/overview#checks-overview
166166
# To check which checks are enabled run `GL_DEBUG=gocritic golangci-lint run`
167167
# By default list of stable checks is used.
168-
enabled-checks:
168+
# enabled-checks:
169169

170170
# Which checks should be disabled; can't be combined with 'enabled-checks'; default is empty
171171
disabled-checks:
@@ -246,3 +246,28 @@ linters:
246246
- exhaustive
247247
- noctx
248248
- gci
249+
- golint
250+
- tparallel
251+
- paralleltest
252+
- wrapcheck
253+
- tagliatelle
254+
- ireturn
255+
- exhaustivestruct
256+
- errchkjson
257+
- contextcheck
258+
- gomoddirectives
259+
- godot
260+
- cyclop
261+
- varnamelen
262+
- gosec
263+
- errorlint
264+
- forcetypeassert
265+
- ifshort
266+
- maintidx
267+
- nilnil
268+
- predeclared
269+
- tenv
270+
- thelper
271+
- wastedassign
272+
- containedctx
273+
- gosimple

bindings/azure/cosmosdb/cosmosdb.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"time"
2222

2323
"github.com/a8m/documentdb"
24-
"github.com/cenkalti/backoff/v4"
24+
backoff "github.com/cenkalti/backoff/v4"
2525

2626
"github.com/dapr/components-contrib/authentication/azure"
2727
"github.com/dapr/components-contrib/bindings"

bindings/azure/servicebusqueues/servicebusqueues_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
)
2626

2727
func TestParseMetadata(t *testing.T) {
28-
var oneSecondDuration time.Duration = time.Second
28+
oneSecondDuration := time.Second
2929

3030
testCases := []struct {
3131
name string

bindings/cron/cron.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
"time"
2020

2121
"github.com/pkg/errors"
22-
"github.com/robfig/cron/v3"
22+
cron "github.com/robfig/cron/v3"
2323

2424
"github.com/dapr/components-contrib/bindings"
2525
"github.com/dapr/kit/logger"

bindings/http/http.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import (
3333
)
3434

3535
// HTTPSource is a binding for an http url endpoint invocation
36-
// nolint:golint
36+
//revive:disable-next-line
3737
type HTTPSource struct {
3838
metadata httpMetadata
3939
client *http.Client

bindings/mysql/mysql_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"testing"
2121
"time"
2222

23-
"github.com/DATA-DOG/go-sqlmock"
23+
sqlmock "github.com/DATA-DOG/go-sqlmock"
2424
"github.com/stretchr/testify/assert"
2525

2626
"github.com/dapr/components-contrib/bindings"

bindings/rabbitmq/rabbitmq_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
func TestParseMetadata(t *testing.T) {
2828
const queueName = "test-queue"
2929
const host = "test-host"
30-
var oneSecondTTL time.Duration = time.Second
30+
oneSecondTTL := time.Second
3131

3232
testCases := []struct {
3333
name string

bindings/redis/redis_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
"context"
1818
"testing"
1919

20-
"github.com/alicebob/miniredis/v2"
20+
miniredis "github.com/alicebob/miniredis/v2"
2121
"github.com/go-redis/redis/v8"
2222
"github.com/stretchr/testify/assert"
2323

bindings/zeebe/command/command_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ type mockClient struct {
3838
}
3939

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

4344
if mcf.error != nil {

bindings/zeebe/jobworker/jobworker_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ type mockClient struct {
3636
}
3737

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

4142
if mcf.error != nil {

nameresolution/consul/configuration.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ func mapAdvancedRegistration(config *AgentServiceRegistration) *consul.AgentServ
327327
return mapped
328328
}
329329

330-
//nolint:golint,stylecheck
330+
//nolint:stylecheck
331331
type HttpBasicAuth struct {
332332
Username string
333333
Password string
@@ -337,11 +337,12 @@ type Config struct {
337337
Address string
338338
Scheme string
339339
Datacenter string
340-
HttpAuth *HttpBasicAuth //nolint:golint,stylecheck
341-
WaitTime time.Duration
342-
Token string
343-
TokenFile string
344-
TLSConfig TLSConfig
340+
//nolint:stylecheck
341+
HttpAuth *HttpBasicAuth
342+
WaitTime time.Duration
343+
Token string
344+
TokenFile string
345+
TLSConfig TLSConfig
345346
}
346347

347348
type TLSConfig struct {

pubsub/azure/servicebus/message.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ func NewPubsubMessageFromASBMessage(asbMsg *azservicebus.Message, topic string)
114114
// Always set delivery count.
115115
addToMetadata(pubsubMsg, DeliveryCountMetadataKey, strconv.FormatInt(int64(asbMsg.DeliveryCount), 10))
116116

117-
//nolint:golint,nestif
118117
if asbMsg.SystemProperties != nil {
119118
systemProps := asbMsg.SystemProperties
120119
if systemProps.EnqueuedTime != nil {

secretstores/secret_store.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ package secretstores
1515

1616
// SecretStore is the interface for a component that handles secrets management.
1717
type SecretStore interface {
18-
// Init authenticates with the actual secret store and performs other init operation
18+
// Init authenticates with the actual secret store and performs other init operation.
1919
Init(metadata Metadata) error
20-
// GetSecret retrieves a secret using a key and returns a map of decrypted string/string values
20+
// GetSecret retrieves a secret using a key and returns a map of decrypted string/string values.
2121
GetSecret(req GetSecretRequest) (GetSecretResponse, error)
22-
// BulkGetSecret retrieves all secrets in the store and returns a map of decrypted string/string values
22+
// BulkGetSecret retrieves all secrets in the store and returns a map of decrypted string/string values.
2323
BulkGetSecret(req BulkGetSecretRequest) (BulkGetSecretResponse, error)
2424
}

state/couchbase/couchbase_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func TestETagToCas(t *testing.T) {
117117
t.Run("with valid string", func(t *testing.T) {
118118
casStr := "1572938024378368000"
119119
ver := uint64(1572938024378368000)
120-
var expectedCas gocb.Cas = gocb.Cas(ver)
120+
expectedCas := gocb.Cas(ver)
121121
cas, err := eTagToCas(casStr)
122122
assert.Equal(t, nil, err)
123123
assert.Equal(t, expectedCas, cas)

state/postgresql/postgresdbaccess.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ func (p *postgresDBAccess) ensureStateTable(stateTableName string) error {
411411
}
412412

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

417417
return exists, err

state/postgresql/postgresql_integration_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ func storeItemExists(t *testing.T, key string) bool {
556556
assert.Nil(t, err)
557557
defer db.Close()
558558

559-
var exists bool = false
559+
exists := false
560560
statement := fmt.Sprintf(`SELECT EXISTS (SELECT FROM %s WHERE key = $1)`, tableName)
561561
err = db.QueryRow(statement, key).Scan(&exists)
562562
assert.Nil(t, err)

state/redis/redis.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,6 @@ func (r *StateStore) Multi(request *state.TransactionalStateRequest) error {
403403

404404
pipe := r.client.TxPipeline()
405405
for _, o := range request.Operations {
406-
//nolint:golint,nestif
407406
if o.Operation == state.Upsert {
408407
req := o.Request.(state.SetRequest)
409408
ver, err := r.parseETag(&req)

0 commit comments

Comments
 (0)