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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -59,3 +59,14 @@ function! ale#handlers#writegood#Handle(buffer, lines) abort
return l:output return l:output
endfunction 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() { check_errors() {
regex="$1" regex="$1"
message="$2" message="$2"
include_arg=''
if [ $# -gt 2 ]; then
include_arg="--include $3"
fi
for directory in "${directories[@]}"; do for directory in "${directories[@]}"; do
while IFS= read -r match; do while IFS= read -r match; do
RETURN_CODE=1 RETURN_CODE=1
echo "$match $message" echo "$match $message"
done < <(grep -n "$regex" "$directory"/**/*.vim \ done < <(grep -n "$regex" $include_arg "$directory"/**/*.vim \
| grep -v 'no-custom-checks' \ | grep -v 'no-custom-checks' \
| grep -o '^[^:]\+:[0-9]\+' \ | grep -o '^[^:]\+:[0-9]\+' \
| sed 's:^\./::') | sed 's:^\./::')
@ -75,6 +80,7 @@ if (( FIX_ERRORS )); then
done done
fi fi
# The arguments are: regex, explanation, [filename_filter]
check_errors \ check_errors \
'^function.*) *$' \ '^function.*) *$' \
'Function without abort keyword (See :help except-compat)' '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 '!=?' "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 '^ *:\?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 exit $RETURN_CODE

View File

@ -22,7 +22,7 @@ Execute(The defaults for the csh filetype should be correct):
AssertEqual [], GetLinterNames('csh') AssertEqual [], GetLinterNames('csh')
Execute(The defaults for the go filetype should be correct): 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 let g:ale_linters_explicit = 1