diff options
author | w0rp <devw0rp@gmail.com> | 2018-07-15 18:24:53 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2018-07-15 18:28:28 +0100 |
commit | a42999a639b2916b769a85f37d037be314d9d61b (patch) | |
tree | 5ebfb4d357dc673efa93fd32a66b489c4510de40 /ale_linters | |
parent | 5155a35a80fe3b20659eb0f28cc6cc720532dd3f (diff) | |
download | ale-a42999a639b2916b769a85f37d037be314d9d61b.zip |
Massively reduce the amount of code needed for linter tests
Diffstat (limited to 'ale_linters')
-rw-r--r-- | ale_linters/asciidoc/writegood.vim (renamed from ale_linters/asciidoc/write-good.vim) | 0 | ||||
-rw-r--r-- | ale_linters/awk/gawk.vim | 4 | ||||
-rw-r--r-- | ale_linters/cs/mcs.vim | 6 | ||||
-rw-r--r-- | ale_linters/cs/mcsc.vim | 10 | ||||
-rw-r--r-- | ale_linters/fuse/fusionlint.vim | 9 | ||||
-rw-r--r-- | ale_linters/glsl/glslang.vim | 6 | ||||
-rw-r--r-- | ale_linters/go/gotype.vim | 3 | ||||
-rw-r--r-- | ale_linters/help/writegood.vim (renamed from ale_linters/help/write-good.vim) | 0 | ||||
-rw-r--r-- | ale_linters/html/writegood.vim (renamed from ale_linters/html/write-good.vim) | 0 | ||||
-rw-r--r-- | ale_linters/java/javac.vim | 6 | ||||
-rw-r--r-- | ale_linters/llvm/llc.vim | 3 | ||||
-rw-r--r-- | ale_linters/markdown/writegood.vim (renamed from ale_linters/markdown/write-good.vim) | 0 | ||||
-rw-r--r-- | ale_linters/nasm/nasm.vim | 2 | ||||
-rw-r--r-- | ale_linters/nroff/writegood.vim (renamed from ale_linters/nroff/write-good.vim) | 0 | ||||
-rw-r--r-- | ale_linters/po/writegood.vim (renamed from ale_linters/po/write-good.vim) | 0 | ||||
-rw-r--r-- | ale_linters/pod/writegood.vim (renamed from ale_linters/pod/write-good.vim) | 0 | ||||
-rw-r--r-- | ale_linters/rst/writegood.vim (renamed from ale_linters/rst/write-good.vim) | 0 | ||||
-rw-r--r-- | ale_linters/ruby/rails_best_practices.vim | 12 | ||||
-rw-r--r-- | ale_linters/scala/scalastyle.vim | 28 | ||||
-rw-r--r-- | ale_linters/tex/writegood.vim (renamed from ale_linters/tex/write-good.vim) | 0 | ||||
-rw-r--r-- | ale_linters/texinfo/writegood.vim (renamed from ale_linters/texinfo/write-good.vim) | 0 | ||||
-rw-r--r-- | ale_linters/text/writegood.vim (renamed from ale_linters/text/write-good.vim) | 0 | ||||
-rw-r--r-- | ale_linters/thrift/thrift.vim | 10 | ||||
-rw-r--r-- | ale_linters/typescript/tslint.vim | 16 | ||||
-rw-r--r-- | ale_linters/xhtml/writegood.vim (renamed from ale_linters/xhtml/write-good.vim) | 0 | ||||
-rw-r--r-- | ale_linters/xml/xmllint.vim | 2 |
26 files changed, 49 insertions, 68 deletions
diff --git a/ale_linters/asciidoc/write-good.vim b/ale_linters/asciidoc/writegood.vim index c986cc6c..c986cc6c 100644 --- a/ale_linters/asciidoc/write-good.vim +++ b/ale_linters/asciidoc/writegood.vim diff --git a/ale_linters/awk/gawk.vim b/ale_linters/awk/gawk.vim index 3e9987b3..8b60815f 100644 --- a/ale_linters/awk/gawk.vim +++ b/ale_linters/awk/gawk.vim @@ -15,9 +15,9 @@ function! ale_linters#awk#gawk#GetCommand(buffer) abort " note the --source 'BEGIN ...' is to prevent " gawk from attempting to execute the body of the script " it is linting. - return ale_linters#awk#gawk#GetExecutable(a:buffer) + return ale#Escape(ale_linters#awk#gawk#GetExecutable(a:buffer)) \ . " --source 'BEGIN { exit } END { exit 1 }'" - \ . ' ' . ale#Var(a:buffer, 'awk_gawk_options') + \ . ale#Pad(ale#Var(a:buffer, 'awk_gawk_options')) \ . ' ' . '-f %t --lint /dev/null' endfunction diff --git a/ale_linters/cs/mcs.vim b/ale_linters/cs/mcs.vim index b5c4054a..8738026d 100644 --- a/ale_linters/cs/mcs.vim +++ b/ale_linters/cs/mcs.vim @@ -1,7 +1,11 @@ let g:ale_cs_mcs_options = get(g:, 'ale_cs_mcs_options', '') function! ale_linters#cs#mcs#GetCommand(buffer) abort - return 'mcs -unsafe --parse ' . ale#Var(a:buffer, 'cs_mcs_options') . ' %t' + let l:options = ale#Var(a:buffer, 'cs_mcs_options') + + return 'mcs -unsafe --parse' + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' %t' endfunction function! ale_linters#cs#mcs#Handle(buffer, lines) abort diff --git a/ale_linters/cs/mcsc.vim b/ale_linters/cs/mcsc.vim index 8e84620c..1561661e 100644 --- a/ale_linters/cs/mcsc.vim +++ b/ale_linters/cs/mcsc.vim @@ -29,16 +29,16 @@ function! ale_linters#cs#mcsc#GetCommand(buffer) abort \ : '' " register temporary module target file with ale - let l:out = ale#util#Tempname() - call ale#engine#ManageFile(a:buffer, l:out) + " register temporary module target file with ALE. + let l:out = ale#engine#CreateFile(a:buffer) " The code is compiled as a module and the output is redirected to a " temporary file. return ale#path#CdString(s:GetWorkingDirectory(a:buffer)) \ . 'mcs -unsafe' - \ . ' ' . ale#Var(a:buffer, 'cs_mcsc_options') - \ . ' ' . l:lib_option - \ . ' ' . l:r_option + \ . ale#Pad(ale#Var(a:buffer, 'cs_mcsc_options')) + \ . ale#Pad(l:lib_option) + \ . ale#Pad(l:r_option) \ . ' -out:' . l:out \ . ' -t:module' \ . ' -recurse:' . ale#Escape('*.cs') diff --git a/ale_linters/fuse/fusionlint.vim b/ale_linters/fuse/fusionlint.vim index 968e801b..cf20e1b4 100644 --- a/ale_linters/fuse/fusionlint.vim +++ b/ale_linters/fuse/fusionlint.vim @@ -1,11 +1,8 @@ " Author: RyanSquared <vandor2012@gmail.com> " Description: `fusion-lint` linter for FusionScript files -let g:ale_fuse_fusionlint_executable = -\ get(g:, 'ale_fuse_fusionlint_executable', 'fusion-lint') - -let g:ale_fuse_fusionlint_options = -\ get(g:, 'ale_fuse_fusionlint_options', '') +call ale#Set('fuse_fusionlint_executable', 'fusion-lint') +call ale#Set('fuse_fusionlint_options', '') function! ale_linters#fuse#fusionlint#GetExecutable(buffer) abort return ale#Var(a:buffer, 'fuse_fusionlint_executable') @@ -13,7 +10,7 @@ endfunction function! ale_linters#fuse#fusionlint#GetCommand(buffer) abort return ale#Escape(ale_linters#fuse#fusionlint#GetExecutable(a:buffer)) - \ . ' ' . ale#Var(a:buffer, 'fuse_fusionlint_options') + \ . ale#Pad(ale#Var(a:buffer, 'fuse_fusionlint_options')) \ . ' --filename %s -i' endfunction diff --git a/ale_linters/glsl/glslang.vim b/ale_linters/glsl/glslang.vim index 21a03ee2..d494df0e 100644 --- a/ale_linters/glsl/glslang.vim +++ b/ale_linters/glsl/glslang.vim @@ -14,9 +14,9 @@ function! ale_linters#glsl#glslang#GetExecutable(buffer) abort endfunction function! ale_linters#glsl#glslang#GetCommand(buffer) abort - return ale_linters#glsl#glslang#GetExecutable(a:buffer) - \ . ' ' . ale#Var(a:buffer, 'glsl_glslang_options') - \ . ' ' . '-C %t' + return ale#Escape(ale_linters#glsl#glslang#GetExecutable(a:buffer)) + \ . ale#Pad(ale#Var(a:buffer, 'glsl_glslang_options')) + \ . ' -C %t' endfunction function! ale_linters#glsl#glslang#Handle(buffer, lines) abort diff --git a/ale_linters/go/gotype.vim b/ale_linters/go/gotype.vim index f4bb274e..a678e0f3 100644 --- a/ale_linters/go/gotype.vim +++ b/ale_linters/go/gotype.vim @@ -3,10 +3,9 @@ function! ale_linters#go#gotype#GetCommand(buffer) abort if expand('#' . a:buffer . ':p') =~# '_test\.go$' - return + return '' endif - return ale#path#BufferCdString(a:buffer) . ' gotype .' endfunction diff --git a/ale_linters/help/write-good.vim b/ale_linters/help/writegood.vim index 11254cd2..11254cd2 100644 --- a/ale_linters/help/write-good.vim +++ b/ale_linters/help/writegood.vim diff --git a/ale_linters/html/write-good.vim b/ale_linters/html/writegood.vim index 9fae8821..9fae8821 100644 --- a/ale_linters/html/write-good.vim +++ b/ale_linters/html/writegood.vim diff --git a/ale_linters/java/javac.vim b/ale_linters/java/javac.vim index b1f74a6d..d7a39aa7 100644 --- a/ale_linters/java/javac.vim +++ b/ale_linters/java/javac.vim @@ -84,10 +84,10 @@ function! ale_linters#java#javac#GetCommand(buffer, import_paths) abort return ale#path#BufferCdString(a:buffer) \ . ale#Escape(l:executable) \ . ' -Xlint' - \ . ' ' . l:cp_option - \ . ' ' . l:sp_option + \ . ale#Pad(l:cp_option) + \ . ale#Pad(l:sp_option) \ . ' -d ' . ale#Escape(l:class_file_directory) - \ . ' ' . ale#Var(a:buffer, 'java_javac_options') + \ . ale#Pad(ale#Var(a:buffer, 'java_javac_options')) \ . ' %t' endfunction diff --git a/ale_linters/llvm/llc.vim b/ale_linters/llvm/llc.vim index 0a4903eb..15201cbe 100644 --- a/ale_linters/llvm/llc.vim +++ b/ale_linters/llvm/llc.vim @@ -9,8 +9,7 @@ endfunction function! ale_linters#llvm#llc#GetCommand(buffer) abort return ale#Escape(ale_linters#llvm#llc#GetExecutable(a:buffer)) - \ . ' -filetype=null -o=' - \ . ale#Escape(g:ale#util#nul_file) + \ . ' -filetype=null -o=' . g:ale#util#nul_file endfunction function! ale_linters#llvm#llc#HandleErrors(buffer, lines) abort diff --git a/ale_linters/markdown/write-good.vim b/ale_linters/markdown/writegood.vim index 21dbff1a..21dbff1a 100644 --- a/ale_linters/markdown/write-good.vim +++ b/ale_linters/markdown/writegood.vim diff --git a/ale_linters/nasm/nasm.vim b/ale_linters/nasm/nasm.vim index f4b2ca4b..77d57e18 100644 --- a/ale_linters/nasm/nasm.vim +++ b/ale_linters/nasm/nasm.vim @@ -42,9 +42,9 @@ endfunction call ale#linter#Define('nasm', { \ 'name': 'nasm', -\ 'executable': 'nasm', \ 'output_stream': 'stderr', \ 'lint_file': 1, +\ 'executable_callback': 'ale_linters#nasm#nasm#GetExecutable', \ 'command_callback': 'ale_linters#nasm#nasm#GetCommand', \ 'callback': 'ale_linters#nasm#nasm#Handle', \}) diff --git a/ale_linters/nroff/write-good.vim b/ale_linters/nroff/writegood.vim index d318fb28..d318fb28 100644 --- a/ale_linters/nroff/write-good.vim +++ b/ale_linters/nroff/writegood.vim diff --git a/ale_linters/po/write-good.vim b/ale_linters/po/writegood.vim index 5a01cb66..5a01cb66 100644 --- a/ale_linters/po/write-good.vim +++ b/ale_linters/po/writegood.vim diff --git a/ale_linters/pod/write-good.vim b/ale_linters/pod/writegood.vim index 14ed5c0c..14ed5c0c 100644 --- a/ale_linters/pod/write-good.vim +++ b/ale_linters/pod/writegood.vim diff --git a/ale_linters/rst/write-good.vim b/ale_linters/rst/writegood.vim index 12137dbf..12137dbf 100644 --- a/ale_linters/rst/write-good.vim +++ b/ale_linters/rst/writegood.vim diff --git a/ale_linters/ruby/rails_best_practices.vim b/ale_linters/ruby/rails_best_practices.vim index 107753c3..4ba1f3fe 100644 --- a/ale_linters/ruby/rails_best_practices.vim +++ b/ale_linters/ruby/rails_best_practices.vim @@ -1,8 +1,8 @@ " Author: Eddie Lebow https://github.com/elebow " Description: rails_best_practices, a code metric tool for rails projects -let g:ale_ruby_rails_best_practices_options = -\ get(g:, 'ale_ruby_rails_best_practices_options', '') +call ale#Set('ruby_rails_best_practices_options', '') +call ale#Set('ruby_rails_best_practices_executable', 'rails_best_practices') function! ale_linters#ruby#rails_best_practices#Handle(buffer, lines) abort let l:output = [] @@ -22,8 +22,12 @@ function! ale_linters#ruby#rails_best_practices#Handle(buffer, lines) abort return l:output endfunction +function! ale_linters#ruby#rails_best_practices#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'ruby_rails_best_practices_executable') +endfunction + function! ale_linters#ruby#rails_best_practices#GetCommand(buffer) abort - let l:executable = ale#handlers#rails_best_practices#GetExecutable(a:buffer) + let l:executable = ale_linters#ruby#rails_best_practices#GetExecutable(a:buffer) let l:exec_args = l:executable =~? 'bundle$' \ ? ' exec rails_best_practices' \ : '' @@ -46,7 +50,7 @@ endfunction call ale#linter#Define('ruby', { \ 'name': 'rails_best_practices', -\ 'executable_callback': 'ale#handlers#rails_best_practices#GetExecutable', +\ 'executable_callback': 'ale_linters#ruby#rails_best_practices#GetExecutable', \ 'command_callback': 'ale_linters#ruby#rails_best_practices#GetCommand', \ 'callback': 'ale_linters#ruby#rails_best_practices#Handle', \ 'lint_file': 1, diff --git a/ale_linters/scala/scalastyle.vim b/ale_linters/scala/scalastyle.vim index f78fd749..3232d70b 100644 --- a/ale_linters/scala/scalastyle.vim +++ b/ale_linters/scala/scalastyle.vim @@ -1,11 +1,11 @@ " Author: Kevin Kays - https://github.com/okkays " Description: Support for the scalastyle checker. -let g:ale_scala_scalastyle_options = -\ get(g:, 'ale_scala_scalastyle_options', '') - -let g:ale_scalastyle_config_loc = +call ale#Set('scala_scalastyle_options', '') +" TODO: Remove support for the old option name in ALE 3.0. +call ale#Set('scala_scalastyle_config', \ get(g:, 'ale_scalastyle_config_loc', '') +\) function! ale_linters#scala#scalastyle#Handle(buffer, lines) abort " Look for help output from scalastyle first, which indicates that no @@ -66,23 +66,13 @@ function! ale_linters#scala#scalastyle#GetCommand(buffer) abort " If all else fails, try the global config. if empty(l:scalastyle_config) - let l:scalastyle_config = get(g:, 'ale_scalastyle_config_loc', '') - endif - - " Build the command using the config file and additional options. - let l:command = 'scalastyle' - - if !empty(l:scalastyle_config) - let l:command .= ' --config ' . ale#Escape(l:scalastyle_config) + let l:scalastyle_config = ale#Var(a:buffer, 'scala_scalastyle_config') endif - if !empty(g:ale_scala_scalastyle_options) - let l:command .= ' ' . g:ale_scala_scalastyle_options - endif - - let l:command .= ' %t' - - return l:command + return 'scalastyle' + \ . (!empty(l:scalastyle_config) ? ' --config ' . ale#Escape(l:scalastyle_config) : '') + \ . ale#Pad(ale#Var(a:buffer, 'scala_scalastyle_options')) + \ . ' %t' endfunction call ale#linter#Define('scala', { diff --git a/ale_linters/tex/write-good.vim b/ale_linters/tex/writegood.vim index dc59de2e..dc59de2e 100644 --- a/ale_linters/tex/write-good.vim +++ b/ale_linters/tex/writegood.vim diff --git a/ale_linters/texinfo/write-good.vim b/ale_linters/texinfo/writegood.vim index 8104c634..8104c634 100644 --- a/ale_linters/texinfo/write-good.vim +++ b/ale_linters/texinfo/writegood.vim diff --git a/ale_linters/text/write-good.vim b/ale_linters/text/writegood.vim index ff76ce42..ff76ce42 100644 --- a/ale_linters/text/write-good.vim +++ b/ale_linters/text/writegood.vim diff --git a/ale_linters/thrift/thrift.vim b/ale_linters/thrift/thrift.vim index 741e80ab..a8fe10b6 100644 --- a/ale_linters/thrift/thrift.vim +++ b/ale_linters/thrift/thrift.vim @@ -20,14 +20,12 @@ function! ale_linters#thrift#thrift#GetCommand(buffer) abort let l:generators = ['cpp'] endif - let l:output_dir = ale#util#Tempname() - call mkdir(l:output_dir) - call ale#engine#ManageDirectory(a:buffer, l:output_dir) + let l:output_dir = ale#engine#CreateDirectory(a:buffer) return ale#Escape(ale_linters#thrift#thrift#GetExecutable(a:buffer)) - \ . ' ' . join(map(copy(l:generators), "'--gen ' . v:val")) - \ . ' ' . join(map(copy(l:includes), "'-I ' . v:val")) - \ . ' ' . ale#Var(a:buffer, 'thrift_thrift_options') + \ . ale#Pad(join(map(copy(l:generators), "'--gen ' . v:val"))) + \ . ale#Pad(join(map(copy(l:includes), "'-I ' . v:val"))) + \ . ale#Pad(ale#Var(a:buffer, 'thrift_thrift_options')) \ . ' -out ' . ale#Escape(l:output_dir) \ . ' %t' endfunction diff --git a/ale_linters/typescript/tslint.vim b/ale_linters/typescript/tslint.vim index b28f7cee..ccdca936 100644 --- a/ale_linters/typescript/tslint.vim +++ b/ale_linters/typescript/tslint.vim @@ -1,17 +1,7 @@ " Author: Prashanth Chandra <https://github.com/prashcr>, Jonathan Clem <https://jclem.net> " Description: tslint for TypeScript files -call ale#Set('typescript_tslint_executable', 'tslint') -call ale#Set('typescript_tslint_config_path', '') -call ale#Set('typescript_tslint_rules_dir', '') -call ale#Set('typescript_tslint_use_global', get(g:, 'ale_use_global_executables', 0)) -call ale#Set('typescript_tslint_ignore_empty_files', 0) - -function! ale_linters#typescript#tslint#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'typescript_tslint', [ - \ 'node_modules/.bin/tslint', - \]) -endfunction +call ale#handlers#tslint#InitVariables() function! ale_linters#typescript#tslint#Handle(buffer, lines) abort " Do not output any errors for empty files if the option is on. @@ -70,7 +60,7 @@ function! ale_linters#typescript#tslint#GetCommand(buffer) abort \ : '' return ale#path#BufferCdString(a:buffer) - \ . ale#Escape(ale_linters#typescript#tslint#GetExecutable(a:buffer)) + \ . ale#Escape(ale#handlers#tslint#GetExecutable(a:buffer)) \ . ' --format json' \ . l:tslint_config_option \ . l:tslint_rules_option @@ -79,7 +69,7 @@ endfunction call ale#linter#Define('typescript', { \ 'name': 'tslint', -\ 'executable_callback': 'ale_linters#typescript#tslint#GetExecutable', +\ 'executable_callback': 'ale#handlers#tslint#GetExecutable', \ 'command_callback': 'ale_linters#typescript#tslint#GetCommand', \ 'callback': 'ale_linters#typescript#tslint#Handle', \}) diff --git a/ale_linters/xhtml/write-good.vim b/ale_linters/xhtml/writegood.vim index 83d1863b..83d1863b 100644 --- a/ale_linters/xhtml/write-good.vim +++ b/ale_linters/xhtml/writegood.vim diff --git a/ale_linters/xml/xmllint.vim b/ale_linters/xml/xmllint.vim index 63d7f768..9d79438e 100644 --- a/ale_linters/xml/xmllint.vim +++ b/ale_linters/xml/xmllint.vim @@ -11,7 +11,7 @@ endfunction function! ale_linters#xml#xmllint#GetCommand(buffer) abort return ale#Escape(ale_linters#xml#xmllint#GetExecutable(a:buffer)) - \ . ' ' . ale#Var(a:buffer, 'xml_xmllint_options') + \ . ale#Pad(ale#Var(a:buffer, 'xml_xmllint_options')) \ . ' --noout -' endfunction |