Browse Source

introduce revive to check lint (#1723)

Signed-off-by: yisaer <disxiaofei@163.com>
Song Gao 2 years ago
parent
commit
33fe7836a9
3 changed files with 60 additions and 0 deletions
  1. 1 0
      .gitignore
  2. 8 0
      Makefile
  3. 51 0
      tools/check/revive.toml

+ 1 - 0
.gitignore

@@ -39,3 +39,4 @@ corss_build_for_rpm.tar
 */**/*.db
 
 .vscode/
+tools/check/bin/

+ 8 - 0
Makefile

@@ -5,6 +5,7 @@ VERSION := $(shell git describe --tags --always)
 ARCH := $(shell go env GOARCH)
 OS := $(shell go env GOOS)
 PACKAGE_NAME := kuiper-$(VERSION)-$(OS)-$(ARCH)
+GO              := GO111MODULE=on go
 
 TARGET ?= lfedge/ekuiper
 
@@ -123,3 +124,10 @@ clean:
 tidy:
 	@echo "go mod tidy"
 	go mod tidy && git diff go.mod go.sum
+
+lint:tools/check/bin/revive
+	@echo "linting"
+	@tools/check/bin/revive -formatter friendly -config tools/check/revive.toml ./...
+
+tools/check/bin/revive:
+	GOBIN=$(shell pwd)/tools/check/bin $(GO) install github.com/mgechev/revive@v1.2.1

+ 51 - 0
tools/check/revive.toml

@@ -0,0 +1,51 @@
+ignoreGeneratedHeader = false
+severity = "error"
+confidence = 0.8
+errorCode = -1
+warningCode = -1
+
+#[rule.blank-imports]
+[rule.context-as-argument]
+[rule.dot-imports]
+#[rule.error-return]
+#[rule.error-strings]
+[rule.error-naming]
+#[rule.exported]
+#[rule.if-return]
+#[rule.var-naming]
+[rule.package-comments]
+#[rule.range]
+#[rule.receiver-naming]
+#[rule.indent-error-flow]
+#[rule.superfluous-else]
+[rule.modifies-parameter]
+
+# This can be checked by other tools like megacheck
+[rule.unreachable-code]
+
+
+# Currently this makes too much noise, but should add it in
+# and perhaps ignore it in a few files
+#[rule.confusing-naming]
+#  severity = "warning"
+#[rule.confusing-results]
+#  severity = "warning"
+#[rule.unused-parameter]
+#  severity = "warning"
+#[rule.deep-exit]
+#  severity = "warning"
+#[rule.flag-parameter]
+#  severity = "warning"
+
+
+
+# Adding these will slow down the linter
+# They are already provided by megacheck
+# [rule.unexported-return]
+# [rule.time-naming]
+# [rule.errorf]
+
+# Adding these will slow down the linter
+# Not sure if they are already provided by megacheck
+# [rule.var-declaration]
+# [rule.context-keys-type]