Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -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
19 changes: 16 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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

8 changes: 5 additions & 3 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions lz4/lz4.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ package lz4
import (
"encoding/binary"
"fmt"

"github.com/pierrec/lz4/v4"
)

Expand Down
2 changes: 1 addition & 1 deletion marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down