Browse Source

fix lint

pull/443/head
yedf2 3 years ago
parent
commit
3d639e0989
  1. 27
      .golangci.yml
  2. 2
      dtmsvr/cron.go
  3. 26
      helper/Makefile
  4. 3
      helper/golint.sh
  5. 4
      test/common_test.go
  6. 4
      test/dtmsvr_test.go
  7. 2
      test/workflow_http_test.go

27
.golangci.yml

@ -1,27 +0,0 @@
run:
deadline: 5m
skip-dirs:
# - test
# - bench
linter-settings:
goconst:
min-len: 2
min-occurrences: 2
linters:
enable:
- revive
- goconst
- gofmt
- goimports
- misspell
- unparam
issues:
exclude-use-default: false
exclude-rules:
- path: _test.go
linters:
- errcheck
- revive

2
dtmsvr/cron.go

@ -57,7 +57,7 @@ func CronUpdateTopicsMap() {
}
}
// CronUpdateTopicsMap cron updates topics map once
// CronUpdateTopicsMapOnce cron updates topics map once
func CronUpdateTopicsMapOnce() {
defer handlePanic(nil)
updateTopicsMap()

26
helper/Makefile

@ -1,26 +0,0 @@
# dev env https://www.dtm.pub/other/develop.html
all: fmt lint test_redis
.PHONY: all
fmt:
@gofmt -s -w ./
lint:
@golangci-lint run
.PHONY: test
test:
@go test ./...
test_redis:
TEST_STORE=redis go test ./...
test_all:
TEST_STORE=redis go test ./...
TEST_STORE=boltdb go test ./...
TEST_STORE=mysql go test ./...
TEST_STORE=postgres go test ./...
cover_test:
./helper/test-cover.sh

3
helper/golint.sh

@ -1,4 +1,3 @@
set -x
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.53.3
$(go env GOPATH)/bin/golangci-lint run
go install github.com/mgechev/revive@latest && revive -config revive.toml ./...

4
test/common_test.go

@ -14,12 +14,12 @@ import (
func TestGeneralDB(t *testing.T) {
if conf.Store.IsDB() {
testSql(t)
testSQL(t)
testDbAlone(t)
}
}
func testSql(t *testing.T) {
func testSQL(t *testing.T) {
conf := conf.Store.GetDBConf()
conf.Host = "127.0.0.1" // use a new host to trigger SetDBConn called
db := dtmutil.DbGet(conf, sql.SetDBConn)

4
test/dtmsvr_test.go

@ -43,11 +43,11 @@ func getBranchesStatus(gid string) []string {
return status
}
func isSqlStore() bool {
func isSQLStore() bool {
return conf.Store.Driver == config.Mysql || conf.Store.Driver == config.Postgres
}
func TestUpdateBranchAsync(t *testing.T) {
if !isSqlStore() {
if !isSQLStore() {
return
}
conf.UpdateBranchSync = 0

2
test/workflow_http_test.go

@ -215,7 +215,7 @@ func TestWorkflowResumeSkip(t *testing.T) {
workflow.Register(gid, func(wf *workflow.Workflow, data []byte) error {
wf.NewBranch().Do(func(bb *dtmcli.BranchBarrier) ([]byte, error) {
logger.Infof("increase resume counter")
resumeCounter += 1
resumeCounter++
return nil, nil
})
var req busi.ReqHTTP

Loading…
Cancel
Save