summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2018-03-18 17:16:13 +0000
committerw0rp <devw0rp@gmail.com>2018-03-18 17:16:13 +0000
commitc112ee9dff2a44d733556dc9440f6d1c15f41f15 (patch)
tree736996783bdba392895f05484e2cd6efec71d810
parentbdd8d2399f59f32c5531d168a1f9402d42d9b299 (diff)
downloadale-c112ee9dff2a44d733556dc9440f6d1c15f41f15.zip
Fix #1392 - Only check files on disk for gotype
-rw-r--r--README.md2
-rw-r--r--ale_linters/go/gotype.vim22
-rw-r--r--doc/ale.txt2
-rw-r--r--test/command_callback/test_gotype_command_callback.vader12
4 files changed, 14 insertions, 24 deletions
diff --git a/README.md b/README.md
index 1e5a725f..69e4f43d 100644
--- a/README.md
+++ b/README.md
@@ -104,7 +104,7 @@ formatting.
| FusionScript | [fusion-lint](https://github.com/RyanSquared/fusionscript) |
| Git Commit Messages | [gitlint](https://github.com/jorisroovers/gitlint) |
| GLSL | [glslang](https://github.com/KhronosGroup/glslang), [glslls](https://github.com/svenstaro/glsl-language-server) |
-| Go | [gofmt](https://golang.org/cmd/gofmt/), [goimports](https://godoc.org/golang.org/x/tools/cmd/goimports), [go vet](https://golang.org/cmd/vet/) !!, [golint](https://godoc.org/github.com/golang/lint), [gotype](https://godoc.org/golang.org/x/tools/cmd/gotype), [gometalinter](https://github.com/alecthomas/gometalinter) !!, [go build](https://golang.org/cmd/go/) !!, [gosimple](https://github.com/dominikh/go-tools/tree/master/cmd/gosimple) !!, [staticcheck](https://github.com/dominikh/go-tools/tree/master/cmd/staticcheck) !! |
+| Go | [gofmt](https://golang.org/cmd/gofmt/), [goimports](https://godoc.org/golang.org/x/tools/cmd/goimports), [go vet](https://golang.org/cmd/vet/) !!, [golint](https://godoc.org/github.com/golang/lint), [gotype](https://godoc.org/golang.org/x/tools/cmd/gotype) !!, [gometalinter](https://github.com/alecthomas/gometalinter) !!, [go build](https://golang.org/cmd/go/) !!, [gosimple](https://github.com/dominikh/go-tools/tree/master/cmd/gosimple) !!, [staticcheck](https://github.com/dominikh/go-tools/tree/master/cmd/staticcheck) !! |
| GraphQL | [eslint](http://eslint.org/), [gqlint](https://github.com/happylinks/gqlint), [prettier](https://github.com/prettier/prettier) |
| Haml | [haml-lint](https://github.com/brigade/haml-lint) |
| Handlebars | [ember-template-lint](https://github.com/rwjblue/ember-template-lint) |
diff --git a/ale_linters/go/gotype.vim b/ale_linters/go/gotype.vim
index 731f4c92..13055a89 100644
--- a/ale_linters/go/gotype.vim
+++ b/ale_linters/go/gotype.vim
@@ -1,23 +1,19 @@
" Author: Jelte Fennema <github-public@jeltef.nl>
" Description: gotype for Go files
+function! ale_linters#go#gotype#GetCommand(buffer) abort
+ if expand('#' . a:buffer . ':p') =~# '_test\.go$'
+ return
+ endif
+
+ return 'gotype %s'
+endfunction
+
call ale#linter#Define('go', {
\ 'name': 'gotype',
\ 'output_stream': 'stderr',
\ 'executable': 'gotype',
\ 'command_callback': 'ale_linters#go#gotype#GetCommand',
\ 'callback': 'ale#handlers#unix#HandleAsError',
+\ 'lint_file': 1,
\})
-
-"\ 'command':
-function! ale_linters#go#gotype#GetCommand(buffer) abort
- let l:cur_file = expand('#' . a:buffer . ':p')
- if l:cur_file =~# '_test\.go$'
- return
- endif
-
- let l:module_files = globpath(expand('#' . a:buffer . ':p:h'), '*.go', 0, 1)
- let l:other_module_files = filter(l:module_files, 'v:val isnot# ' . ale#util#EscapeVim(l:cur_file) . ' && v:val !~# "_test\.go$"')
- return 'gotype %t ' . join(map(l:other_module_files, 'ale#Escape(v:val)'))
-
-endfunction
diff --git a/doc/ale.txt b/doc/ale.txt
index b16528f6..b9ac0875 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -327,7 +327,7 @@ Notes:
* FusionScript: `fusion-lint`
* Git Commit Messages: `gitlint`
* GLSL: glslang, `glslls`
-* Go: `gofmt`, `goimports`, `go vet`!!, `golint`, `gotype`, `gometalinter`!!, `go build`!!, `gosimple`!!, `staticcheck`!!
+* Go: `gofmt`, `goimports`, `go vet`!!, `golint`, `gotype`!!, `gometalinter`!!, `go build`!!, `gosimple`!!, `staticcheck`!!
* GraphQL: `eslint`, `gqlint`, `prettier`
* Haml: `haml-lint`
* Handlebars: `ember-template-lint`
diff --git a/test/command_callback/test_gotype_command_callback.vader b/test/command_callback/test_gotype_command_callback.vader
index f95e8423..ec98627c 100644
--- a/test/command_callback/test_gotype_command_callback.vader
+++ b/test/command_callback/test_gotype_command_callback.vader
@@ -5,15 +5,9 @@ Before:
After:
call ale#linter#Reset()
-
-Execute(The gotype callback should include other files from the directory but exclude the file itself):
- let dir = expand('#' . bufnr('') . ':p:h')
- AssertEqual
- \ "gotype %t ". ale#Escape(ale#path#Simplify(dir . "/testfile.go")),
- \ ale_linters#go#gotype#GetCommand(bufnr(''))
+Execute(The default gotype command should be correct):
+ AssertEqual 'gotype %s', ale_linters#go#gotype#GetCommand(bufnr(''))
Execute(The gotype callback should ignore test files):
call ale#test#SetFilename('bla_test.go')
- AssertEqual
- \ 0,
- \ ale_linters#go#gotype#GetCommand(bufnr(''))
+ AssertEqual 0, ale_linters#go#gotype#GetCommand(bufnr(''))