diff --git a/.github/workflows/components-contrib.yml b/.github/workflows/components-contrib.yml index c4185e2bf..9871ff236 100644 --- a/.github/workflows/components-contrib.yml +++ b/.github/workflows/components-contrib.yml @@ -35,7 +35,7 @@ jobs: GOOS: ${{ matrix.target_os }} GOARCH: ${{ matrix.target_arch }} GOPROXY: https://proxy.golang.org - GOLANGCI_LINT_VER: "v1.48.0" + GOLANGCI_LINT_VER: "v1.50.1" strategy: matrix: os: [ubuntu-latest, windows-latest, macOS-latest] diff --git a/.golangci.yml b/.golangci.yml index c10f1e9a3..abe2e9ce0 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -277,3 +277,6 @@ linters: - rowserrcheck - sqlclosecheck - structcheck + - deadcode + - nosnakecase + - varcheck diff --git a/bindings/alicloud/dingtalk/webhook/webhook_test.go b/bindings/alicloud/dingtalk/webhook/webhook_test.go index 895ad2b36..b527171af 100644 --- a/bindings/alicloud/dingtalk/webhook/webhook_test.go +++ b/bindings/alicloud/dingtalk/webhook/webhook_test.go @@ -37,7 +37,7 @@ func TestPublishMsg(t *testing.T) { //nolint:paralleltest w.WriteHeader(http.StatusOK) _, err := w.Write([]byte("{\"errcode\":0}")) require.NoError(t, err) - if r.Method != "POST" { + if r.Method != http.MethodPost { t.Errorf("Expected 'POST' request, got '%s'", r.Method) } if r.URL.EscapedPath() != "/test" { diff --git a/bindings/gcp/bucket/bucket.go b/bindings/gcp/bucket/bucket.go index b1f80fb43..9a83b1e96 100644 --- a/bindings/gcp/bucket/bucket.go +++ b/bindings/gcp/bucket/bucket.go @@ -196,7 +196,7 @@ func (g *GCPStorage) create(ctx context.Context, req *bindings.InvokeRequest) (* func (g *GCPStorage) get(ctx context.Context, req *bindings.InvokeRequest) (*bindings.InvokeResponse, error) { metadata, err := g.metadata.mergeWithRequestMetadata(req) if err != nil { - return nil, fmt.Errorf("gcp binding binding error. error merge metadata : %w", err) + return nil, fmt.Errorf("gcp binding error. error merge metadata : %w", err) } var key string diff --git a/bindings/rethinkdb/statechange/statechange.go b/bindings/rethinkdb/statechange/statechange.go index 9e642cf5c..c6203bfcf 100644 --- a/bindings/rethinkdb/statechange/statechange.go +++ b/bindings/rethinkdb/statechange/statechange.go @@ -28,7 +28,7 @@ import ( "github.com/dapr/kit/logger" ) -// Binding represents RethinkDB change change state input binding which fires handler with +// Binding represents RethinkDB change state input binding which fires handler with // both the previous and current state store content each time there is a change. type Binding struct { logger logger.Logger diff --git a/pubsub/jetstream/metadata_test.go b/pubsub/jetstream/metadata_test.go index 9ee8c8365..94314a2d2 100644 --- a/pubsub/jetstream/metadata_test.go +++ b/pubsub/jetstream/metadata_test.go @@ -126,7 +126,7 @@ func TestParseMetadata(t *testing.T) { expectErr: true, }, { - desc: "Invalid metadata with missing tls client client", + desc: "Invalid metadata with missing tls client", input: pubsub.Metadata{Base: mdata.Base{ Properties: map[string]string{ "natsURL": "nats://localhost:4222", diff --git a/pubsub/rabbitmq/rabbitmq.go b/pubsub/rabbitmq/rabbitmq.go index 821e00c8c..0e4280908 100644 --- a/pubsub/rabbitmq/rabbitmq.go +++ b/pubsub/rabbitmq/rabbitmq.go @@ -67,6 +67,8 @@ type rabbitMQ struct { } // interface used to allow unit testing. +// +//nolint:interfacebloat type rabbitMQChannelBroker interface { PublishWithContext(ctx context.Context, exchange string, key string, mandatory bool, immediate bool, msg amqp.Publishing) error PublishWithDeferredConfirmWithContext(ctx context.Context, exchange string, key string, mandatory bool, immediate bool, msg amqp.Publishing) (*amqp.DeferredConfirmation, error) diff --git a/secretstores/azure/keyvault/keyvault.go b/secretstores/azure/keyvault/keyvault.go index 0af130a17..9a3440007 100644 --- a/secretstores/azure/keyvault/keyvault.go +++ b/secretstores/azure/keyvault/keyvault.go @@ -185,11 +185,11 @@ func (k *keyvaultSecretStore) getVaultURI() string { func (k *keyvaultSecretStore) getMaxResultsFromMetadata(metadata map[string]string) (*int32, error) { if s, ok := metadata["maxresults"]; ok && s != "" { - val, err := strconv.Atoi(s) //nolint:gosec + val, err := strconv.Atoi(s) if err != nil { return nil, err } - converted := int32(val) + converted := int32(val) //nolint:gosec return &converted, nil } diff --git a/secretstores/hashicorp/vault/vault.go b/secretstores/hashicorp/vault/vault.go index 3411a38ca..da029b9fa 100644 --- a/secretstores/hashicorp/vault/vault.go +++ b/secretstores/hashicorp/vault/vault.go @@ -226,11 +226,11 @@ func (v *vaultSecretStore) getSecret(ctx context.Context, secret, version string defer httpresp.Body.Close() - if httpresp.StatusCode != 200 { + if httpresp.StatusCode != http.StatusOK { var b bytes.Buffer io.Copy(&b, httpresp.Body) v.logger.Debugf("getSecret %s couldn't get successful response: %#v, %s", secret, httpresp, b.String()) - if httpresp.StatusCode == 404 { + if httpresp.StatusCode == http.StatusNotFound { // handle not found error return nil, fmt.Errorf("getSecret %s failed %w", secret, ErrNotFound) } @@ -344,7 +344,7 @@ func (v *vaultSecretStore) listKeysUnderPath(ctx context.Context, path string) ( defer httpresp.Body.Close() - if httpresp.StatusCode != 200 { + if httpresp.StatusCode != http.StatusOK { var b bytes.Buffer io.Copy(&b, httpresp.Body) v.logger.Debugf("list keys couldn't get successful response: %#v, %s", httpresp, b.String()) diff --git a/state/oci/objectstorage/objectstorage.go b/state/oci/objectstorage/objectstorage.go index 440a19523..cb722f7ed 100644 --- a/state/oci/objectstorage/objectstorage.go +++ b/state/oci/objectstorage/objectstorage.go @@ -18,6 +18,7 @@ import ( "context" "fmt" "io" + "net/http" "os" "path" "reflect" @@ -405,7 +406,7 @@ func (c *ociObjectStorageClient) ensureBucketExists(ctx context.Context, client // verify if bucket exists. response, err := client.GetBucket(ctx, req) if err != nil { - if response.RawResponse.StatusCode == 404 { + if response.RawResponse.StatusCode == http.StatusNotFound { err = createBucket(ctx, client, namespace, name, compartmentOCID) if err == nil { c.logger.Debugf("Created OCI Object Storage Bucket %s as State Store", name) @@ -445,7 +446,7 @@ func (c *ociObjectStorageClient) getObject(ctx context.Context, objectname strin response, err := c.objectStorageMetadata.OCIObjectStorageClient.GetObject(ctx, request) if err != nil { c.logger.Debugf("Issue in OCI ObjectStorage with retrieving object %s, error: %s", objectname, err) - if response.RawResponse.StatusCode == 404 { + if response.RawResponse.StatusCode == http.StatusNotFound { return nil, nil, nil, nil } return nil, nil, nil, fmt.Errorf("failed to retrieve object : %w", err) diff --git a/state/sqlserver/migration.go b/state/sqlserver/migration.go index 06ab76bc4..a56019906 100644 --- a/state/sqlserver/migration.go +++ b/state/sqlserver/migration.go @@ -277,6 +277,7 @@ func (m *migration) createStoredProcedureIfNotExists(db *sql.DB, name string, es } /* #nosec. */ +//nolint:dupword func (m *migration) ensureUpsertStoredProcedureExists(db *sql.DB, mr migrationResult) error { tsql := fmt.Sprintf(` CREATE PROCEDURE %s ( diff --git a/tests/conformance/utils/utils.go b/tests/conformance/utils/utils.go index 01d5c3244..2628ce2b0 100644 --- a/tests/conformance/utils/utils.go +++ b/tests/conformance/utils/utils.go @@ -104,9 +104,9 @@ func appRouter() *mux.Router { func handleCall(w http.ResponseWriter, r *http.Request) { switch r.Method { - case "POST": + case http.MethodPost: s.handlePost(r) - case "GET": + case http.MethodGet: w.Write(s.handleGet()) default: w.WriteHeader(http.StatusInternalServerError)