This is an automated email from the ASF dual-hosted git repository. joaoreis pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/cassandra-gocql-driver.git
The following commit(s) were added to refs/heads/trunk by this push: new 05517735 Use golangci instead of govet 05517735 is described below commit 0551773596db460ae1925e8702fcb84fb7745111 Author: Dmitry Kropachev <dmitry.kropac...@gmail.com> AuthorDate: Fri May 30 11:21:36 2025 -0400 Use golangci instead of govet 1. Switch to use golangci instead of govet 2. Enable all linters in govet, except fieldalingment 3. Run `make fix` to fix all the linting problems 4. Fix awaitSchemaAgreement bug found by linters when error is not returned Patch by dkropachev; reviewed by joao-r-reis for CASSGO-77 --- .golangci.yml | 33 +++++++++++++++++++++++++++++++++ Makefile | 19 ++++++++++++++++--- conn.go | 8 +++++--- lz4/lz4.go | 1 + marshal.go | 2 +- 5 files changed, 56 insertions(+), 7 deletions(-) diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 00000000..f0ff7d32 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,33 @@ +version: "2" + +issues: + max-same-issues: 50 + +formatters: + enable: + - goimports + + settings: + goimports: + local-prefixes: + - github.com/gocql/gocql + - github.com/apache/cassandra-gocql-driver + golines: + max-len: 120 + +linters: + default: none + enable: + - nolintlint + - govet + settings: + govet: + enable-all: true + disable: + - shadow + - fieldalignment + + nolintlint: + allow-no-explanation: [ golines ] + require-explanation: true + require-specific: true diff --git a/Makefile b/Makefile index 4ef54d28..56ed015d 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,7 @@ TEST_COMPRESSOR ?= no-compression TEST_INTEGRATION_TAGS ?= integration CCM_VERSION ?= 39b8222b31a6c7afe8fe845d16981088a5a735ad +GOLANGCI_VERSION = v2.1.6 JVM_EXTRA_OPTS ?= -Dcassandra.test.fail_writes_ks=test -Dcassandra.custom_query_handler_class=org.apache.cassandra.cql3.CustomPayloadMirroringQueryHandler ifeq (${CCM_CONFIG_DIR},) CCM_CONFIG_DIR = ~/.ccm @@ -101,9 +102,15 @@ test-unit: @go clean -testcache go test -tags unit -timeout=5m -race ./... -check: - @echo "Run go vet linter" - go vet --tags "unit all cassandra integration" ./... +check: .prepare-golangci + @echo "Build" + @go build -tags all . + @echo "Check linting" + @golangci-lint run + +fix: .prepare-golangci + @echo "Fix linting" + golangci-lint run --fix .prepare-java: ifeq ($(shell if [ -f ~/.sdkman/bin/sdkman-init.sh ]; then echo "installed"; else echo "not-installed"; fi), not-installed) @@ -149,3 +156,9 @@ install-ccm: @mkdir ${CCM_CONFIG_DIR} 2>/dev/null 1>&2 || true @echo ${CCM_VERSION} > ${CCM_CONFIG_DIR}/ccm-version +.prepare-golangci: + @if ! golangci-lint --version 2>/dev/null | grep ${GOLANGCI_VERSION} >/dev/null; then \ + echo "Installing golangci-ling ${GOLANGCI_VERSION}"; \ + go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@${GOLANGCI_VERSION}; \ + fi + diff --git a/conn.go b/conn.go index 114f159d..93f6cab1 100644 --- a/conn.go +++ b/conn.go @@ -1900,6 +1900,7 @@ func (c *Conn) awaitSchemaAgreement(ctx context.Context) (err error) { var versions map[string]struct{} var schemaVersion string + var rows []map[string]interface{} endDeadline := time.Now().Add(c.session.cfg.MaxWaitSchemaAgreement) @@ -1908,17 +1909,18 @@ func (c *Conn) awaitSchemaAgreement(ctx context.Context) (err error) { versions = make(map[string]struct{}) - rows, err := iter.SliceMap() + rows, err = iter.SliceMap() if err != nil { goto cont } for _, row := range rows { - h, err := NewHostInfo(c.host.ConnectAddress(), c.session.cfg.Port) + var host *HostInfo + host, err = NewHostInfo(c.host.ConnectAddress(), c.session.cfg.Port) if err != nil { goto cont } - host, err := c.session.hostInfoFromMap(row, h) + host, err = c.session.hostInfoFromMap(row, host) if err != nil { goto cont } diff --git a/lz4/lz4.go b/lz4/lz4.go index c836a093..f97cbd37 100644 --- a/lz4/lz4.go +++ b/lz4/lz4.go @@ -27,6 +27,7 @@ package lz4 import ( "encoding/binary" "fmt" + "github.com/pierrec/lz4/v4" ) diff --git a/marshal.go b/marshal.go index 368c7f12..d0cf6730 100644 --- a/marshal.go +++ b/marshal.go @@ -2603,7 +2603,7 @@ func unmarshalUDT(info TypeInfo, data []byte, value interface{}) error { f, ok := fields[e.Name] if !ok { f = k.FieldByName(e.Name) - if f == emptyValue { + if f == emptyValue { //nolint:govet // there is no other way to compare with empty value // skip fields which exist in the UDT but not in // the struct passed in continue --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org