From 0ea007f68fada5cd27d307b9f058366e66b95611 Mon Sep 17 00:00:00 2001 From: David Landry Date: Fri, 5 Oct 2018 16:00:04 -0400 Subject: [PATCH 1/7] Add revive config file for linting --- revive.toml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 revive.toml diff --git a/revive.toml b/revive.toml new file mode 100644 index 00000000..c9a52e70 --- /dev/null +++ b/revive.toml @@ -0,0 +1,32 @@ +ignoreGeneratedHeader = true +severity = "error" +confidence = 0.8 +errorCode = 1 +warningCode = 0 + +[rule.package-comments] + severity = "warning" +[rule.exported] + severity = "warning" +[rule.blank-imports] +[rule.context-as-argument] +[rule.context-keys-type] +[rule.dot-imports] +[rule.error-return] +[rule.error-strings] +[rule.error-naming] +[rule.if-return] +[rule.increment-decrement] +[rule.var-naming] +[rule.var-declaration] +[rule.range] +[rule.receiver-naming] +[rule.time-naming] +[rule.unexported-return] +[rule.indent-error-flow] +[rule.errorf] +[rule.empty-block] +[rule.superfluous-else] +[rule.unused-parameter] +[rule.unreachable-code] +[rule.redefines-builtin-id] From 87faec998ef738e79abeae155e86e2090956601b Mon Sep 17 00:00:00 2001 From: David Landry Date: Fri, 5 Oct 2018 16:11:28 -0400 Subject: [PATCH 2/7] Run linting during CI Install and run revive for linting --- .travis.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d6fe95eb..344d7a7b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,10 +18,14 @@ addons: before_install: - curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh +- go get -u github.com/mgechev/revive - sudo curl -o /usr/local/lib/antlr-4.7.1-complete.jar https://www.antlr.org/download/antlr-4.7.1-complete.jar - export CLASSPATH=".:/usr/local/lib/antlr-4.7.1-complete.jar:$CLASSPATH" - mkdir $HOME/travis-bin - echo -e '#!/bin/bash\njava -jar /usr/local/lib/antlr-4.7.1-complete.jar "$@"' > $HOME/travis-bin/antlr4 - echo -e '#!/bin/bash\njava org.antlr.v4.gui.TestRig "$@"' > $HOME/travis-bin/grun - chmod +x $HOME/travis-bin/* -- export PATH=$PATH:$HOME/travis-bin \ No newline at end of file +- export PATH=$PATH:$HOME/travis-bin + +script: +- revive -config revive.toml -formatter friendly ./... From e0ca4065d7f441fdf05961bb95be80d7982848b6 Mon Sep 17 00:00:00 2001 From: David Landry Date: Fri, 5 Oct 2018 16:41:14 -0400 Subject: [PATCH 3/7] Ignore parser files that are generated by antlr --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 344d7a7b..e712401d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,4 +28,4 @@ before_install: - export PATH=$PATH:$HOME/travis-bin script: -- revive -config revive.toml -formatter friendly ./... +- revive -config revive.toml -formatter friendly -exclude ./pkg/parser/fql/... ./... From 423939af57bbdc74ecd48a460d93d6fc2b6af176 Mon Sep 17 00:00:00 2001 From: David Landry Date: Fri, 5 Oct 2018 16:52:41 -0400 Subject: [PATCH 4/7] Change this to 'warning' because we're using a redefined 'Type' all over the place --- revive.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/revive.toml b/revive.toml index c9a52e70..e0556f98 100644 --- a/revive.toml +++ b/revive.toml @@ -30,3 +30,4 @@ warningCode = 0 [rule.unused-parameter] [rule.unreachable-code] [rule.redefines-builtin-id] + severity = "warning" From 8e2006b73c7f3665ce1acb74ad74339bb66cc621 Mon Sep 17 00:00:00 2001 From: David Landry Date: Fri, 5 Oct 2018 17:00:37 -0400 Subject: [PATCH 5/7] Actually, let's just disable the check for Type --- pkg/runtime/core/value.go | 1 + revive.toml | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/runtime/core/value.go b/pkg/runtime/core/value.go index ca315263..3f496376 100644 --- a/pkg/runtime/core/value.go +++ b/pkg/runtime/core/value.go @@ -4,6 +4,7 @@ import ( "encoding/json" ) +//revive:disable-next-line redefines-builtin-id type Type int64 const ( diff --git a/revive.toml b/revive.toml index e0556f98..c9a52e70 100644 --- a/revive.toml +++ b/revive.toml @@ -30,4 +30,3 @@ warningCode = 0 [rule.unused-parameter] [rule.unreachable-code] [rule.redefines-builtin-id] - severity = "warning" From 0d43a37880719dbcf75365de3fa7c0ddcd0a31e6 Mon Sep 17 00:00:00 2001 From: David Landry Date: Fri, 5 Oct 2018 18:59:42 -0400 Subject: [PATCH 6/7] Swap golint for revive --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 923a6d52..c1af62b8 100644 --- a/Makefile +++ b/Makefile @@ -32,12 +32,12 @@ doc: fmt: go fmt ${DIR_CLI}/... ${DIR_PKG}/... -# https://github.com/golang/lint -# go get github.com/golang/lint/golint +# https://github.com/mgechev/revive +# go get github.com/mgechev/revive lint: - golint ${DIR_CLI}/... ${DIR_PKG}/... + revive -config ../revive.toml -formatter friendly -exclude ./pkg/parser/fql/... ./... # http://godoc.org/code.google.com/p/go.tools/cmd/vet # go get code.google.com/p/go.tools/cmd/vet vet: - go vet ${DIR_CLI}/... ${DIR_PKG}/... \ No newline at end of file + go vet ${DIR_CLI}/... ${DIR_PKG}/... From ff0d9c667bbda4d418b378b0495653a24e0f9a41 Mon Sep 17 00:00:00 2001 From: David Landry Date: Fri, 5 Oct 2018 19:00:22 -0400 Subject: [PATCH 7/7] Update lockfile --- Gopkg.lock | 70 +++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 61 insertions(+), 9 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index 78ab0f6a..a60f1066 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -1,6 +1,41 @@ # This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. +[[projects]] + branch = "master" + digest = "1:b464fe4a2262c37c82c16ff76dd77ae8efb85036d2f6b13b428a3e63bce3d562" + name = "github.com/MontFerret/ferret" + packages = [ + "cli", + "cli/browser", + "pkg/compiler", + "pkg/parser", + "pkg/parser/fql", + "pkg/runtime", + "pkg/runtime/collections", + "pkg/runtime/core", + "pkg/runtime/expressions", + "pkg/runtime/expressions/clauses", + "pkg/runtime/expressions/literals", + "pkg/runtime/expressions/operators", + "pkg/runtime/logging", + "pkg/runtime/values", + "pkg/stdlib", + "pkg/stdlib/collections", + "pkg/stdlib/html", + "pkg/stdlib/html/driver", + "pkg/stdlib/html/driver/common", + "pkg/stdlib/html/driver/dynamic", + "pkg/stdlib/html/driver/dynamic/eval", + "pkg/stdlib/html/driver/dynamic/events", + "pkg/stdlib/html/driver/static", + "pkg/stdlib/strings", + "pkg/stdlib/types", + "pkg/stdlib/utils", + ] + pruneopts = "UT" + revision = "51d794d6c1b3cbc5e4d3a654000a601f974b0288" + [[projects]] digest = "1:a62f6ed230a8cd138a9efbe718e7d0b0294f139266f5f55cd942769a9aac8de2" name = "github.com/PuerkitoBio/goquery" @@ -137,14 +172,6 @@ revision = "a96e63847dc3c67d17befa69c303767e2f84e54f" version = "v2.1" -[[projects]] - branch = "master" - digest = "1:f7aa53146bf79462509d4ce136826ebbd64907e4679e1b04e62758da6b68e589" - name = "github.com/orcaman/concurrent-map" - packages = ["."] - pruneopts = "UT" - revision = "b28018939af9022337862b94a463abb18abb3e0e" - [[projects]] digest = "1:40e195917a951a8bf867cd05de2a46aaf1806c50cf92eebf4c16f78cd196f747" name = "github.com/pkg/errors" @@ -221,6 +248,32 @@ analyzer-name = "dep" analyzer-version = 1 input-imports = [ + "github.com/MontFerret/ferret/cli", + "github.com/MontFerret/ferret/cli/browser", + "github.com/MontFerret/ferret/pkg/compiler", + "github.com/MontFerret/ferret/pkg/parser", + "github.com/MontFerret/ferret/pkg/parser/fql", + "github.com/MontFerret/ferret/pkg/runtime", + "github.com/MontFerret/ferret/pkg/runtime/collections", + "github.com/MontFerret/ferret/pkg/runtime/core", + "github.com/MontFerret/ferret/pkg/runtime/expressions", + "github.com/MontFerret/ferret/pkg/runtime/expressions/clauses", + "github.com/MontFerret/ferret/pkg/runtime/expressions/literals", + "github.com/MontFerret/ferret/pkg/runtime/expressions/operators", + "github.com/MontFerret/ferret/pkg/runtime/logging", + "github.com/MontFerret/ferret/pkg/runtime/values", + "github.com/MontFerret/ferret/pkg/stdlib", + "github.com/MontFerret/ferret/pkg/stdlib/collections", + "github.com/MontFerret/ferret/pkg/stdlib/html", + "github.com/MontFerret/ferret/pkg/stdlib/html/driver", + "github.com/MontFerret/ferret/pkg/stdlib/html/driver/common", + "github.com/MontFerret/ferret/pkg/stdlib/html/driver/dynamic", + "github.com/MontFerret/ferret/pkg/stdlib/html/driver/dynamic/eval", + "github.com/MontFerret/ferret/pkg/stdlib/html/driver/dynamic/events", + "github.com/MontFerret/ferret/pkg/stdlib/html/driver/static", + "github.com/MontFerret/ferret/pkg/stdlib/strings", + "github.com/MontFerret/ferret/pkg/stdlib/types", + "github.com/MontFerret/ferret/pkg/stdlib/utils", "github.com/PuerkitoBio/goquery", "github.com/antlr/antlr4/runtime/Go/antlr", "github.com/chzyer/readline", @@ -236,7 +289,6 @@ "github.com/mafredri/cdp/rpcc", "github.com/mafredri/cdp/session", "github.com/natefinch/lumberjack", - "github.com/orcaman/concurrent-map", "github.com/pkg/errors", "github.com/rs/zerolog", "github.com/sethgrid/pester",