summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaco <liaoishere@gmail.com>2020-05-22 19:09:14 +0800
committerGitHub <noreply@github.com>2020-05-22 06:09:14 -0500
commit7265ceb6d050d1a4642741d248f11e4f2abd37e1 (patch)
treec4d8dd7e708a201a080efb2ddc63f9b49132c7f1
parent7ff87a942b8a6c2cf50b7cf34f9b98421508f542 (diff)
downloadale-7265ceb6d050d1a4642741d248f11e4f2abd37e1.zip
Support revive for go files (#2933)
Signed-off-by: Penghui Liao <liaoishere@gmail.com>
-rw-r--r--ale_linters/go/revive.vim21
-rw-r--r--doc/ale-go.txt19
-rw-r--r--doc/ale-supported-languages-and-tools.txt1
-rw-r--r--doc/ale.txt1
-rw-r--r--supported-tools.md1
-rw-r--r--test/command_callback/test_revive_command_callbacks.vader30
6 files changed, 73 insertions, 0 deletions
diff --git a/ale_linters/go/revive.vim b/ale_linters/go/revive.vim
new file mode 100644
index 00000000..b14b5ab9
--- /dev/null
+++ b/ale_linters/go/revive.vim
@@ -0,0 +1,21 @@
+" Author: Penghui Liao <liaoishere@gmail.com>
+" Description: Adds support for revive
+
+call ale#Set('go_revive_executable', 'revive')
+call ale#Set('go_revive_options', '')
+
+function! ale_linters#go#revive#GetCommand(buffer) abort
+ let l:options = ale#Var(a:buffer, 'go_revive_options')
+
+ return ale#go#EnvString(a:buffer) . '%e'
+ \ . (!empty(l:options) ? ' ' . l:options : '')
+ \ . ' %t'
+endfunction
+
+call ale#linter#Define('go', {
+\ 'name': 'revive',
+\ 'output_stream': 'both',
+\ 'executable': {b -> ale#Var(b, 'go_revive_executable')},
+\ 'command': function('ale_linters#go#revive#GetCommand'),
+\ 'callback': 'ale#handlers#unix#HandleAsWarning',
+\})
diff --git a/doc/ale-go.txt b/doc/ale-go.txt
index be53783e..5c0791bc 100644
--- a/doc/ale-go.txt
+++ b/doc/ale-go.txt
@@ -220,6 +220,25 @@ g:ale_go_govet_options *g:ale_go_govet_options*
===============================================================================
+revive *ale-go-revive*
+
+g:ale_go_revive_executable *g:ale_go_revive_executable*
+ *b:ale_go_revive_executable*
+ Type: |String|
+ Default: `'revive'`
+
+ This variable can be set to change the revive executable path.
+
+
+g:ale_go_revive_options *g:ale_go_revive_options*
+ *b:ale_go_revive_options*
+ Type: |String|
+ Default: `''`
+
+ This variable can be set to pass additional options to the revive
+
+
+===============================================================================
staticcheck *ale-go-staticcheck*
g:ale_go_staticcheck_options *g:ale_go_staticcheck_options*
diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt
index bd2d5b4a..45252294 100644
--- a/doc/ale-supported-languages-and-tools.txt
+++ b/doc/ale-supported-languages-and-tools.txt
@@ -164,6 +164,7 @@ Notes:
* `gosimple`!!
* `gotype`!!
* `go vet`!!
+ * `revive`!!
* `staticcheck`!!
* GraphQL
* `eslint`
diff --git a/doc/ale.txt b/doc/ale.txt
index 8d5b8820..724da57e 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -2379,6 +2379,7 @@ documented in additional help files.
gometalinter..........................|ale-go-gometalinter|
gopls.................................|ale-go-gopls|
govet.................................|ale-go-govet|
+ revive................................|ale-go-revive|
staticcheck...........................|ale-go-staticcheck|
graphql.................................|ale-graphql-options|
eslint................................|ale-graphql-eslint|
diff --git a/supported-tools.md b/supported-tools.md
index f6b26458..7d2f5287 100644
--- a/supported-tools.md
+++ b/supported-tools.md
@@ -173,6 +173,7 @@ formatting.
* [gosimple](https://github.com/dominikh/go-tools/tree/master/cmd/gosimple) :warning: :floppy_disk:
* [gotype](https://godoc.org/golang.org/x/tools/cmd/gotype) :warning: :floppy_disk:
* [go vet](https://golang.org/cmd/vet/) :floppy_disk:
+ * [revive](https://github.com/mgechev/revive) :warning: :floppy_disk:
* [staticcheck](https://github.com/dominikh/go-tools/tree/master/cmd/staticcheck) :warning: :floppy_disk:
* GraphQL
* [eslint](http://eslint.org/)
diff --git a/test/command_callback/test_revive_command_callbacks.vader b/test/command_callback/test_revive_command_callbacks.vader
new file mode 100644
index 00000000..172294f3
--- /dev/null
+++ b/test/command_callback/test_revive_command_callbacks.vader
@@ -0,0 +1,30 @@
+Before:
+ Save g:ale_go_go111module
+
+ call ale#assert#SetUpLinterTest('go', 'revive')
+
+After:
+ Restore
+
+ unlet! b:ale_go_go111module
+
+ call ale#assert#TearDownLinterTest()
+
+Execute(The default revive command should be correct):
+ AssertLinter 'revive', ale#Escape('revive') . ' %t'
+
+Execute(The revive executable should be configurable):
+ let b:ale_go_revive_executable = 'foobar'
+
+ AssertLinter 'foobar', ale#Escape('foobar') . ' %t'
+
+Execute(The revive options should be configurable):
+ let b:ale_go_revive_options = '--foo'
+
+ AssertLinter 'revive', ale#Escape('revive') . ' --foo %t'
+
+Execute(The revive command should support Go environment variables):
+ let b:ale_go_go111module = 'on'
+
+ AssertLinter 'revive',
+ \ ale#Env('GO111MODULE', 'on') . ale#Escape('revive') . ' %t'