#1754 Require snake_case names for linters in the codebase

This commit is contained in:
w0rp 2018-07-24 10:05:44 +01:00
parent 95be2bf1ff
commit d368f090ae
No known key found for this signature in database
GPG Key ID: 0FC1ECAA8C81CD83
23 changed files with 52 additions and 84 deletions

View File

@ -1,9 +1,4 @@
" Author: Sumner Evans <sumner.evans98@gmail.com>
" Description: write-good for AsciiDoc files
call ale#linter#Define('asciidoc', {
\ 'name': 'write-good',
\ 'executable_callback': 'ale#handlers#writegood#GetExecutable',
\ 'command_callback': 'ale#handlers#writegood#GetCommand',
\ 'callback': 'ale#handlers#writegood#Handle',
\})
call ale#handlers#writegood#DefineLinter('asciidoc')

View File

@ -70,7 +70,8 @@ function! ale_linters#go#gobuild#Handler(buffer, lines) abort
endfunction
call ale#linter#Define('go', {
\ 'name': 'go build',
\ 'name': 'gobuild',
\ 'aliases': ['go build'],
\ 'executable': 'go',
\ 'command_chain': [
\ {'callback': 'ale_linters#go#gobuild#GoEnv', 'output_stream': 'stdout'},

View File

@ -9,7 +9,8 @@ function! ale_linters#go#govet#GetCommand(buffer) abort
endfunction
call ale#linter#Define('go', {
\ 'name': 'go vet',
\ 'name': 'govet',
\ 'aliases': ['go vet'],
\ 'output_stream': 'stderr',
\ 'executable': 'go',
\ 'command_callback': 'ale_linters#go#govet#GetCommand',

View File

@ -10,7 +10,8 @@ function! ale_linters#haskell#cabal_ghc#GetCommand(buffer) abort
endfunction
call ale#linter#Define('haskell', {
\ 'name': 'cabal-ghc',
\ 'name': 'cabal_ghc',
\ 'aliases': ['cabal-ghc'],
\ 'output_stream': 'stderr',
\ 'executable': 'cabal',
\ 'command_callback': 'ale_linters#haskell#cabal_ghc#GetCommand',

View File

@ -2,14 +2,16 @@
" Description: ghc-mod for Haskell files
call ale#linter#Define('haskell', {
\ 'name': 'ghc-mod',
\ 'name': 'ghc_mod',
\ 'aliases': ['ghc-mod'],
\ 'executable': 'ghc-mod',
\ 'command': 'ghc-mod --map-file %s=%t check %s',
\ 'callback': 'ale#handlers#haskell#HandleGHCFormat',
\})
call ale#linter#Define('haskell', {
\ 'name': 'stack-ghc-mod',
\ 'name': 'stack_ghc_mod',
\ 'aliases': ['stack-ghc-mod'],
\ 'executable': 'stack',
\ 'command': 'stack exec ghc-mod -- --map-file %s=%t check %s',
\ 'callback': 'ale#handlers#haskell#HandleGHCFormat',

View File

@ -13,7 +13,8 @@ function! ale_linters#haskell#stack_build#GetCommand(buffer) abort
endfunction
call ale#linter#Define('haskell', {
\ 'name': 'stack-build',
\ 'name': 'stack_build',
\ 'aliases': ['stack-build'],
\ 'output_stream': 'stderr',
\ 'executable': 'stack',
\ 'command_callback': 'ale_linters#haskell#stack_build#GetCommand',

View File

@ -2,7 +2,8 @@
" Description: ghc for Haskell files, using Stack
call ale#linter#Define('haskell', {
\ 'name': 'stack-ghc',
\ 'name': 'stack_ghc',
\ 'aliases': ['stack-ghc'],
\ 'output_stream': 'stderr',
\ 'executable': 'stack',
\ 'command': 'stack ghc -- -fno-code -v0 %t',

View File

@ -1,9 +1,4 @@
" Author: Sumner Evans <sumner.evans98@gmail.com>
" Description: write-good for vim Help files
call ale#linter#Define('help', {
\ 'name': 'write-good',
\ 'executable_callback': 'ale#handlers#writegood#GetExecutable',
\ 'command_callback': 'ale#handlers#writegood#GetCommand',
\ 'callback': 'ale#handlers#writegood#Handle',
\})
call ale#handlers#writegood#DefineLinter('help')

View File

@ -1,9 +1,4 @@
" Author: Sumner Evans <sumner.evans98@gmail.com>
" Description: write-good for nroff files
" Description: write-good for html files
call ale#linter#Define('html', {
\ 'name': 'write-good',
\ 'executable_callback': 'ale#handlers#writegood#GetExecutable',
\ 'command_callback': 'ale#handlers#writegood#GetCommand',
\ 'callback': 'ale#handlers#writegood#Handle',
\})
call ale#handlers#writegood#DefineLinter('html')

View File

@ -1,3 +1,4 @@
scriptencoding utf-8
" Author rhysd https://rhysd.github.io/, Dirk Roorda (dirkroorda), Adrián González Rus (@adrigzr)
" Description: remark-lint for Markdown files
call ale#Set('markdown_remark_lint_executable', 'remark')
@ -43,7 +44,8 @@ function! ale_linters#markdown#remark_lint#Handle(buffer, lines) abort
endfunction
call ale#linter#Define('markdown', {
\ 'name': 'remark-lint',
\ 'name': 'remark_lint',
\ 'aliases': ['remark-lint'],
\ 'executable_callback': 'ale_linters#markdown#remark_lint#GetExecutable',
\ 'command_callback': 'ale_linters#markdown#remark_lint#GetCommand',
\ 'callback': 'ale_linters#markdown#remark_lint#Handle',

View File

@ -1,9 +1,4 @@
" Author: Sumner Evans <sumner.evans98@gmail.com>
" Description: write-good for Markdown files
call ale#linter#Define('markdown', {
\ 'name': 'write-good',
\ 'executable_callback': 'ale#handlers#writegood#GetExecutable',
\ 'command_callback': 'ale#handlers#writegood#GetCommand',
\ 'callback': 'ale#handlers#writegood#Handle',
\})
call ale#handlers#writegood#DefineLinter('markdown')

View File

@ -1,9 +1,4 @@
" Author: Sumner Evans <sumner.evans98@gmail.com>
" Description: write-good for nroff files
call ale#linter#Define('nroff', {
\ 'name': 'write-good',
\ 'executable_callback': 'ale#handlers#writegood#GetExecutable',
\ 'command_callback': 'ale#handlers#writegood#GetCommand',
\ 'callback': 'ale#handlers#writegood#Handle',
\})
call ale#handlers#writegood#DefineLinter('nroff')

View File

@ -1,9 +1,4 @@
" Author: Cian Butler https://github.com/butlerx
" Description: write-good for PO files
call ale#linter#Define('po', {
\ 'name': 'write-good',
\ 'executable_callback': 'ale#handlers#writegood#GetExecutable',
\ 'command_callback': 'ale#handlers#writegood#GetCommand',
\ 'callback': 'ale#handlers#writegood#Handle',
\})
call ale#handlers#writegood#DefineLinter('po')

View File

@ -1,9 +1,4 @@
" Author: Sumner Evans <sumner.evans98@gmail.com>
" Description: write-good for Pod files
call ale#linter#Define('pod', {
\ 'name': 'write-good',
\ 'executable_callback': 'ale#handlers#writegood#GetExecutable',
\ 'command_callback': 'ale#handlers#writegood#GetCommand',
\ 'callback': 'ale#handlers#writegood#Handle',
\})
call ale#handlers#writegood#DefineLinter('pod')

View File

@ -1,9 +1,4 @@
" Author: Sumner Evans <sumner.evans98@gmail.com>
" Description: write-good for reStructuredText files
call ale#linter#Define('rst', {
\ 'name': 'write-good',
\ 'executable_callback': 'ale#handlers#writegood#GetExecutable',
\ 'command_callback': 'ale#handlers#writegood#GetCommand',
\ 'callback': 'ale#handlers#writegood#Handle',
\})
call ale#handlers#writegood#DefineLinter('rst')

View File

@ -9,7 +9,8 @@ endfunction
" Using CM requires that we set "lint_file: 1", since it reads the files
" from the disk itself.
call ale#linter#Define('sml', {
\ 'name': 'smlnj-cm',
\ 'name': 'smlnj_cm',
\ 'aliases': ['smlnj-cm'],
\ 'executable_callback': 'ale#handlers#sml#GetExecutableSmlnjCm',
\ 'lint_file': 1,
\ 'command_callback': 'ale_linters#sml#smlnj_cm#GetCommand',

View File

@ -1,9 +1,4 @@
" Author: Sumner Evans <sumner.evans98@gmail.com>
" Description: write-good for TeX files
call ale#linter#Define('tex', {
\ 'name': 'write-good',
\ 'executable_callback': 'ale#handlers#writegood#GetExecutable',
\ 'command_callback': 'ale#handlers#writegood#GetCommand',
\ 'callback': 'ale#handlers#writegood#Handle',
\})
call ale#handlers#writegood#DefineLinter('tex')

View File

@ -1,9 +1,4 @@
" Author: Sumner Evans <sumner.evans98@gmail.com>
" Description: write-good for Texinfo files
call ale#linter#Define('texinfo', {
\ 'name': 'write-good',
\ 'executable_callback': 'ale#handlers#writegood#GetExecutable',
\ 'command_callback': 'ale#handlers#writegood#GetCommand',
\ 'callback': 'ale#handlers#writegood#Handle',
\})
call ale#handlers#writegood#DefineLinter('texinfo')

View File

@ -1,9 +1,4 @@
" Author: Sumner Evans <sumner.evans98@gmail.com>
" Description: write-good for text files
call ale#linter#Define('text', {
\ 'name': 'write-good',
\ 'executable_callback': 'ale#handlers#writegood#GetExecutable',
\ 'command_callback': 'ale#handlers#writegood#GetCommand',
\ 'callback': 'ale#handlers#writegood#Handle',
\})
call ale#handlers#writegood#DefineLinter('text')

View File

@ -1,9 +1,4 @@
" Author: Sumner Evans <sumner.evans98@gmail.com>
" Description: write-good for XHTML files
call ale#linter#Define('xhtml', {
\ 'name': 'write-good',
\ 'executable_callback': 'ale#handlers#writegood#GetExecutable',
\ 'command_callback': 'ale#handlers#writegood#GetCommand',
\ 'callback': 'ale#handlers#writegood#Handle',
\})
call ale#handlers#writegood#DefineLinter('xhtml')

View File

@ -59,3 +59,14 @@ function! ale#handlers#writegood#Handle(buffer, lines) abort
return l:output
endfunction
" Define the writegood linter for a given filetype.
function! ale#handlers#writegood#DefineLinter(filetype) abort
call ale#linter#Define(a:filetype, {
\ 'name': 'writegood',
\ 'aliases': ['write-good'],
\ 'executable_callback': 'ale#handlers#writegood#GetExecutable',
\ 'command_callback': 'ale#handlers#writegood#GetCommand',
\ 'callback': 'ale#handlers#writegood#Handle',
\})
endfunction

View File

@ -52,12 +52,17 @@ directories=("$@")
check_errors() {
regex="$1"
message="$2"
include_arg=''
if [ $# -gt 2 ]; then
include_arg="--include $3"
fi
for directory in "${directories[@]}"; do
while IFS= read -r match; do
RETURN_CODE=1
echo "$match $message"
done < <(grep -n "$regex" "$directory"/**/*.vim \
done < <(grep -n "$regex" $include_arg "$directory"/**/*.vim \
| grep -v 'no-custom-checks' \
| grep -o '^[^:]\+:[0-9]\+' \
| sed 's:^\./::')
@ -75,6 +80,7 @@ if (( FIX_ERRORS )); then
done
fi
# The arguments are: regex, explanation, [filename_filter]
check_errors \
'^function.*) *$' \
'Function without abort keyword (See :help except-compat)'
@ -95,5 +101,6 @@ check_errors '==?' "Use 'is?' instead of '==?'. 0 ==? 'foobar' is true"
check_errors '!=#' "Use 'isnot#' instead of '!=#'. 0 !=# 'foobar' is false"
check_errors '!=?' "Use 'isnot?' instead of '!=?'. 0 !=? 'foobar' is false"
check_errors '^ *:\?echo' "Stray echo line. Use \`execute echo\` if you want to echo something"
check_errors $'name.:.*\'[a-z_]*[^a-z_0-9][a-z_0-9]*\',$' 'Use snake_case names for linters' '*/ale_linters/*'
exit $RETURN_CODE

View File

@ -22,7 +22,7 @@ Execute(The defaults for the csh filetype should be correct):
AssertEqual [], GetLinterNames('csh')
Execute(The defaults for the go filetype should be correct):
AssertEqual ['gofmt', 'golint', 'go vet'], GetLinterNames('go')
AssertEqual ['gofmt', 'golint', 'govet'], GetLinterNames('go')
let g:ale_linters_explicit = 1