From 3d639e098968fe23d547d57da4bafccf73a8e1ba Mon Sep 17 00:00:00 2001 From: yedf2 <120050102@qq.com> Date: Sat, 1 Jul 2023 10:49:29 +0800 Subject: [PATCH] fix lint --- .golangci.yml | 27 --------------------------- dtmsvr/cron.go | 2 +- helper/Makefile | 26 -------------------------- helper/golint.sh | 3 +-- test/common_test.go | 4 ++-- test/dtmsvr_test.go | 4 ++-- test/workflow_http_test.go | 2 +- 7 files changed, 7 insertions(+), 61 deletions(-) delete mode 100644 .golangci.yml delete mode 100644 helper/Makefile diff --git a/.golangci.yml b/.golangci.yml deleted file mode 100644 index 31cf246..0000000 --- a/.golangci.yml +++ /dev/null @@ -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 diff --git a/dtmsvr/cron.go b/dtmsvr/cron.go index 21e22df..82ef344 100644 --- a/dtmsvr/cron.go +++ b/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() diff --git a/helper/Makefile b/helper/Makefile deleted file mode 100644 index f9d7353..0000000 --- a/helper/Makefile +++ /dev/null @@ -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 - diff --git a/helper/golint.sh b/helper/golint.sh index 78fd29f..d4a8642 100644 --- a/helper/golint.sh +++ b/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 ./... diff --git a/test/common_test.go b/test/common_test.go index 4974268..de01e63 100644 --- a/test/common_test.go +++ b/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) diff --git a/test/dtmsvr_test.go b/test/dtmsvr_test.go index 497a449..93e592d 100644 --- a/test/dtmsvr_test.go +++ b/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 diff --git a/test/workflow_http_test.go b/test/workflow_http_test.go index 991a315..8e740da 100644 --- a/test/workflow_http_test.go +++ b/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