added golangci (#59)
This commit is contained in:
22
.golangci.yml
Normal file
22
.golangci.yml
Normal file
@@ -0,0 +1,22 @@
|
||||
run:
|
||||
deadline: 5m
|
||||
tests: false
|
||||
silent: true
|
||||
|
||||
linters-settings:
|
||||
lll:
|
||||
line-length: 180
|
||||
|
||||
linters:
|
||||
enable-all: true
|
||||
disable:
|
||||
- gas
|
||||
- interfacer
|
||||
- maligned
|
||||
- nakedret
|
||||
|
||||
issues:
|
||||
exclude-use-default: false
|
||||
exclude:
|
||||
- composite literal uses unkeyed fields
|
||||
- Error return value of `.+\.Close` is not checked
|
||||
@@ -1,3 +1,4 @@
|
||||
sudo: true
|
||||
language: go
|
||||
go:
|
||||
- 1.10.x
|
||||
@@ -9,8 +10,6 @@ env:
|
||||
- DB="scylla"
|
||||
- DB="cassandra"
|
||||
|
||||
sudo: true
|
||||
|
||||
dist: trusty
|
||||
addons:
|
||||
apt:
|
||||
@@ -21,8 +20,7 @@ before_install:
|
||||
- ./.travis_start_db.sh
|
||||
|
||||
install:
|
||||
- make get-deps
|
||||
- make get-tools
|
||||
- make get-deps get-tools
|
||||
|
||||
script:
|
||||
- make
|
||||
|
||||
@@ -20,3 +20,5 @@ cassandra)
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
until nc -vz 127.0.0.1 9042; do sleep 1; done
|
||||
|
||||
47
Makefile
47
Makefile
@@ -1,44 +1,28 @@
|
||||
all: check test bench
|
||||
all: check test
|
||||
|
||||
ifndef GOBIN
|
||||
export GOBIN := $(GOPATH)/bin
|
||||
endif
|
||||
|
||||
define dl
|
||||
@curl -sSq -L $(2) -o $(GOBIN)/$(1) && chmod u+x $(GOBIN)/$(1)
|
||||
endef
|
||||
|
||||
define dl_tgz
|
||||
@curl -sSq -L $(2) | tar zxf - --strip 1 -C $(GOBIN) --wildcards '*/$(1)'
|
||||
endef
|
||||
|
||||
.PHONY: fmt
|
||||
fmt: ## Format source code
|
||||
fmt:
|
||||
@go fmt ./...
|
||||
|
||||
.PHONY: check
|
||||
check: ## Perform static code analysis
|
||||
check: .check-misspell .check-lint
|
||||
|
||||
.PHONY: .check-fmt
|
||||
.check-fmt:
|
||||
@go fmt ./... | tee /dev/stderr | ifne false
|
||||
|
||||
.PHONY: .check-misspell
|
||||
.check-misspell:
|
||||
@$(GOBIN)/misspell ./...
|
||||
|
||||
.PHONY: .check-lint
|
||||
.check-lint:
|
||||
@$(GOBIN)/golangci-lint run -s --disable-all -E govet -E errcheck -E staticcheck \
|
||||
-E gas -E typecheck -E unused -E structcheck -E varcheck -E ineffassign -E deadcode \
|
||||
-E gofmt -E golint -E gosimple -E unconvert -E dupl -E depguard -E gocyclo \
|
||||
--tests=false \
|
||||
--exclude-use-default=false \
|
||||
--exclude='composite literal uses unkeyed fields' \
|
||||
--exclude='Error return value of `.+\.Close` is not checked' \
|
||||
--exclude='G104' \
|
||||
--exclude='G304' \
|
||||
--exclude='G401' \
|
||||
--exclude='G501' \
|
||||
./...
|
||||
check:
|
||||
@$(GOBIN)/golangci-lint run ./...
|
||||
|
||||
GOTEST := go test -cover -race -tags all
|
||||
|
||||
.PHONY: test
|
||||
test: ## Run unit and integration tests
|
||||
test:
|
||||
@$(GOTEST) .
|
||||
@$(GOTEST) ./migrate
|
||||
@@ -54,12 +38,7 @@ get-deps:
|
||||
go get -t ./...
|
||||
|
||||
.PHONY: get-tools
|
||||
get-tools: GOPATH := $(shell mktemp -d)
|
||||
get-tools:
|
||||
@echo "==> Installing tools at $(GOBIN)..."
|
||||
@mkdir -p $(GOBIN)
|
||||
@$(call dl_tgz,golangci-lint,https://github.com/golangci/golangci-lint/releases/download/v1.9.3/golangci-lint-1.9.3-linux-amd64.tar.gz)
|
||||
|
||||
@go get -u github.com/client9/misspell/cmd/misspell
|
||||
@go get -u github.com/golangci/golangci-lint/cmd/golangci-lint
|
||||
|
||||
@rm -Rf $(GOPATH)
|
||||
|
||||
@@ -86,13 +86,13 @@ func createKeyspace(tb testing.TB, cluster *gocql.ClusterConfig, keyspace string
|
||||
c.Timeout = 30 * time.Second
|
||||
session, err := c.CreateSession()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
tb.Fatal(err)
|
||||
}
|
||||
defer session.Close()
|
||||
|
||||
err = ExecStmt(session, `DROP KEYSPACE IF EXISTS `+keyspace)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("unable to drop keyspace: %v", err))
|
||||
tb.Fatalf("unable to drop keyspace: %v", err)
|
||||
}
|
||||
|
||||
err = ExecStmt(session, fmt.Sprintf(`CREATE KEYSPACE %s
|
||||
@@ -102,7 +102,7 @@ func createKeyspace(tb testing.TB, cluster *gocql.ClusterConfig, keyspace string
|
||||
}`, keyspace, *flagRF))
|
||||
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("unable to create keyspace: %v", err))
|
||||
tb.Fatalf("unable to create keyspace: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -244,7 +244,7 @@ type kinder interface {
|
||||
|
||||
// mustBe checks a value against a kind, panicing with a reflect.ValueError
|
||||
// if the kind isn't that which is required.
|
||||
func mustBe(v kinder, expected reflect.Kind) {
|
||||
func mustBe(v kinder, expected reflect.Kind) { // nolint: unparam
|
||||
if k := v.Kind(); k != expected {
|
||||
panic(&reflect.ValueError{Method: methodName(), Kind: k})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user