Remove gometalinter support (#4534)

gometalinter has been deprecated, and was archived in 2019
This commit is contained in:
Craig Rodrigues 2023-07-24 05:33:15 -07:00 committed by GitHub
parent f34016a552
commit 3d10770387
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 5 additions and 215 deletions

View File

@ -1,58 +0,0 @@
" Author: Ben Reedy <https://github.com/breed808>, Jeff Willette <jrwillette88@gmail.com>
" Description: Adds support for the gometalinter suite for Go files
call ale#Set('go_gometalinter_options', '')
call ale#Set('go_gometalinter_executable', 'gometalinter')
call ale#Set('go_gometalinter_lint_package', 0)
function! ale_linters#go#gometalinter#GetCommand(buffer) abort
let l:filename = expand('#' . a:buffer . ':t')
let l:options = ale#Var(a:buffer, 'go_gometalinter_options')
let l:lint_package = ale#Var(a:buffer, 'go_gometalinter_lint_package')
" BufferCdString is used so that we can be sure the paths output from gometalinter can
" be calculated to absolute paths in the Handler
if l:lint_package
return ale#go#EnvString(a:buffer)
\ . '%e'
\ . (!empty(l:options) ? ' ' . l:options : '') . ' .'
endif
return ale#go#EnvString(a:buffer)
\ . '%e'
\ . ' --include=' . ale#Escape(ale#util#EscapePCRE(l:filename))
\ . (!empty(l:options) ? ' ' . l:options : '') . ' .'
endfunction
function! ale_linters#go#gometalinter#GetMatches(lines) abort
let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):?(\d+)?:?:?(warning|error):?\s\*?(.+)$'
return ale#util#GetMatches(a:lines, l:pattern)
endfunction
function! ale_linters#go#gometalinter#Handler(buffer, lines) abort
let l:dir = expand('#' . a:buffer . ':p:h')
let l:output = []
for l:match in ale_linters#go#gometalinter#GetMatches(a:lines)
" l:match[1] will already be an absolute path, output from gometalinter
call add(l:output, {
\ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]),
\ 'lnum': l:match[2] + 0,
\ 'col': l:match[3] + 0,
\ 'type': tolower(l:match[4]) is# 'warning' ? 'W' : 'E',
\ 'text': l:match[5],
\})
endfor
return l:output
endfunction
call ale#linter#Define('go', {
\ 'name': 'gometalinter',
\ 'executable': {b -> ale#Var(b, 'go_gometalinter_executable')},
\ 'cwd': '%s:h',
\ 'command': function('ale_linters#go#gometalinter#GetCommand'),
\ 'callback': 'ale_linters#go#gometalinter#Handler',
\ 'lint_file': 1,
\})

View File

@ -5,20 +5,15 @@ ALE Go Integration *ale-go-options*
===============================================================================
Integration Information
The `gometalinter` linter is disabled by default. ALE enables `gofmt`,
`gopls`, and `go vet` by default. It also supports `staticcheck, `go
build`, `gosimple`, `golangserver`, and `golangci-lint`.
ALE enables `gofmt`, `gopls` and `go vet` by default. It also supports `staticcheck`,
`go build, ``gosimple`, `golangserver`, and `golangci-lint.
To enable `gometalinter`, update |g:ale_linters| as appropriate:
To enable `golangci-lint`, update |g:ale_linters| as appropriate.
A possible configuration is to enable golangci-lint and `gofmt:
>
" Enable all of the linters you want for Go.
let g:ale_linters = {'go': ['gometalinter', 'gofmt']}
let g:ale_linters = {'go': ['golangci-lint', 'gofmt']}
<
A possible configuration is to enable `gometalinter` and `gofmt` but paired
with the `--fast` option, set by |g:ale_go_gometalinter_options|. This gets you
the benefit of running a number of linters, more than ALE would by default,
while ensuring it doesn't run any linters known to be slow or resource
intensive.
g:ale_go_go_executable *g:ale_go_go_executable*
*b:ale_go_go_executable*
@ -175,44 +170,6 @@ g:ale_go_golines_options *g:ale_go_golines_options*
--max-length=100 (lines above 100 characters will be wrapped)
===============================================================================
gometalinter *ale-go-gometalinter*
`gometalinter` is a `lint_file` linter, which only lints files that are
written to disk. This differs from the default behavior of linting the buffer.
See: |ale-lint-file|
g:ale_go_gometalinter_executable *g:ale_go_gometalinter_executable*
*b:ale_go_gometalinter_executable*
Type: |String|
Default: `'gometalinter'`
The executable that will be run for gometalinter.
g:ale_go_gometalinter_options *g:ale_go_gometalinter_options*
*b:ale_go_gometalinter_options*
Type: |String|
Default: `''`
This variable can be changed to alter the command-line arguments to the
gometalinter invocation.
Since `gometalinter` runs a number of linters that can consume a lot of
resources it's recommended to set this option to a value of `--fast` if you
use `gometalinter` as one of the linters in |g:ale_linters|. This disables a
number of linters known to be slow or consume a lot of resources.
g:ale_go_gometalinter_lint_package *g:ale_go_gometalinter_lint_package*
*b:ale_go_gometalinter_lint_package*
Type: |Number|
Default: `0`
When set to `1`, the whole Go package will be checked instead of only the
current file.
===============================================================================
gopls *ale-go-gopls*

View File

@ -213,7 +213,6 @@ Notes:
* `golangci-lint`!!
* `golangserver`
* `golines`
* `gometalinter`!!
* `gopls`
* `gosimple`!!
* `gotype`!!

View File

@ -2987,7 +2987,6 @@ documented in additional help files.
golangci-lint.........................|ale-go-golangci-lint|
golangserver..........................|ale-go-golangserver|
golines...............................|ale-go-golines|
gometalinter..........................|ale-go-gometalinter|
gopls.................................|ale-go-gopls|
govet.................................|ale-go-govet|
revive................................|ale-go-revive|

View File

@ -222,7 +222,6 @@ formatting.
* [golangci-lint](https://github.com/golangci/golangci-lint) :warning: :floppy_disk:
* [golangserver](https://github.com/sourcegraph/go-langserver) :warning:
* [golines](https://github.com/segmentio/golines)
* [gometalinter](https://github.com/alecthomas/gometalinter) :warning: :floppy_disk:
* [gopls](https://github.com/golang/go/wiki/gopls)
* [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:

View File

@ -1,57 +0,0 @@
Before:
runtime ale_linters/go/gometalinter.vim
After:
call ale#linter#Reset()
Execute (The gometalinter handler should handle names with spaces):
" We can't test Windows paths with the path resovling on Linux, but we can
" test the regex.
AssertEqual
\ [
\ [
\ 'C:\something\file with spaces.go',
\ '12',
\ '3',
\ 'warning',
\ 'expected ''package'', found ''IDENT'' gibberish (staticcheck)',
\ ],
\ [
\ 'C:\something\file with spaces.go',
\ '37',
\ '5',
\ 'error',
\ 'expected ''package'', found ''IDENT'' gibberish (golint)',
\ ],
\ ],
\ map(ale_linters#go#gometalinter#GetMatches([
\ 'C:\something\file with spaces.go:12:3:warning: expected ''package'', found ''IDENT'' gibberish (staticcheck)',
\ 'C:\something\file with spaces.go:37:5:error: expected ''package'', found ''IDENT'' gibberish (golint)',
\ ]), 'v:val[1:5]')
Execute (The gometalinter handler should handle paths correctly):
call ale#test#SetFilename('app/test.go')
let file = ale#path#GetAbsPath(expand('%:p:h'), 'test.go')
AssertEqual
\ [
\ {
\ 'lnum': 12,
\ 'col': 3,
\ 'text': 'expected ''package'', found ''IDENT'' gibberish (staticcheck)',
\ 'type': 'W',
\ 'filename': ale#path#Simplify(expand('%:p:h') . '/test.go'),
\ },
\ {
\ 'lnum': 37,
\ 'col': 5,
\ 'text': 'expected ''package'', found ''IDENT'' gibberish (golint)',
\ 'type': 'E',
\ 'filename': ale#path#Simplify(expand('%:p:h') . '/test.go'),
\ },
\ ],
\ ale_linters#go#gometalinter#Handler(bufnr(''), [
\ file . ':12:3:warning: expected ''package'', found ''IDENT'' gibberish (staticcheck)',
\ file . ':37:5:error: expected ''package'', found ''IDENT'' gibberish (golint)',
\ ])

View File

@ -1,49 +0,0 @@
Before:
Save g:ale_go_go111module
call ale#assert#SetUpLinterTest('go', 'gometalinter')
call ale#test#SetFilename('test.go')
After:
Restore
unlet! b:ale_go_go111module
call ale#assert#TearDownLinterTest()
Execute(The gometalinter defaults should be correct):
AssertLinterCwd '%s:h',
AssertLinter 'gometalinter',
\ ale#Escape('gometalinter')
\ . ' --include=' . ale#Escape(ale#util#EscapePCRE(expand('%' . ':t')))
\ . ' .'
Execute(The gometalinter callback should use a configured executable):
let b:ale_go_gometalinter_executable = 'something else'
AssertLinter 'something else',
\ ale#Escape('something else')
\ . ' --include=' . ale#Escape(ale#util#EscapePCRE(expand('%' . ':t')))
\ . ' .'
Execute(The gometalinter callback should use configured options):
let b:ale_go_gometalinter_options = '--foobar'
AssertLinter 'gometalinter',
\ ale#Escape('gometalinter')
\ . ' --include=' . ale#Escape(ale#util#EscapePCRE(expand('%' . ':t')))
\ . ' --foobar' . ' .'
Execute(The gometalinter should use configured environment variables):
let b:ale_go_go111module = 'off'
AssertLinter 'gometalinter',
\ ale#Env('GO111MODULE', 'off')
\ . ale#Escape('gometalinter')
\ . ' --include=' . ale#Escape(ale#util#EscapePCRE(expand('%' . ':t')))
\ . ' .'
Execute(The gometalinter `lint_package` option should use the correct command):
let b:ale_go_gometalinter_lint_package = 1
AssertLinter 'gometalinter', ale#Escape('gometalinter') . ' .'