Make code more consistent

This commit is contained in:
w0rp 2017-04-15 12:52:08 +01:00
parent c9a5d9845b
commit cab68cba25
13 changed files with 184 additions and 183 deletions

View File

@ -1,38 +1,37 @@
" Author: Lucas Kolstad <lkolstad@uw.edu>
" Description: gcc linter for asm files
let g:ale_asm_gcc_options =
\ get(g:, 'ale_asm_gcc_options', '-Wall')
let g:ale_asm_gcc_options = get(g:, 'ale_asm_gcc_options', '-Wall')
function! ale_linters#asm#gcc#GetCommand(buffer) abort
return 'gcc -x assembler -fsyntax-only '
\ . '-iquote ' . fnameescape(fnamemodify(bufname(a:buffer), ':p:h'))
\ . ' ' . g:ale_asm_gcc_options . ' -'
return 'gcc -x assembler -fsyntax-only '
\ . '-iquote ' . fnameescape(fnamemodify(bufname(a:buffer), ':p:h'))
\ . ' ' . g:ale_asm_gcc_options . ' -'
endfunction
function! ale_linters#asm#gcc#Handle(buffer, lines) abort
let l:pattern = '^.\+:\(\d\+\): \([^:]\+\): \(.\+\)$'
let l:output = []
let l:pattern = '^.\+:\(\d\+\): \([^:]\+\): \(.\+\)$'
let l:output = []
for l:line in a:lines
let l:match = matchlist(l:line, l:pattern)
for l:line in a:lines
let l:match = matchlist(l:line, l:pattern)
if len(l:match) == 0
continue
endif
if len(l:match) == 0
continue
endif
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'vcol': 0,
\ 'col': 0,
\ 'text': l:match[3],
\ 'type': l:match[2] =~? 'error' ? 'E' : 'W',
\ 'nr': -1,
\})
endfor
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'vcol': 0,
\ 'col': 0,
\ 'text': l:match[3],
\ 'type': l:match[2] =~? 'error' ? 'E' : 'W',
\ 'nr': -1,
\})
endfor
return l:output
return l:output
endfunction
call ale#linter#Define('asm', {

View File

@ -35,10 +35,10 @@ function! ale_linters#chef#foodcritic#Handle(buffer, lines) abort
endfunction
function! ale_linters#chef#foodcritic#GetCommand(buffer) abort
return printf('%s %s %%t',
\ g:ale_chef_foodcritic_executable,
\ escape(g:ale_chef_foodcritic_options, '~')
\)
return printf('%s %s %%t',
\ g:ale_chef_foodcritic_executable,
\ escape(g:ale_chef_foodcritic_options, '~')
\)
endfunction
@ -48,4 +48,3 @@ call ale#linter#Define('chef', {
\ 'command_callback': 'ale_linters#chef#foodcritic#GetCommand',
\ 'callback': 'ale_linters#chef#foodcritic#Handle',
\})

View File

@ -3,15 +3,15 @@
" Set this option to change the GCC options for warnings for C.
if !exists('g:ale_cpp_gcc_options')
" added c++14 standard support
" POSIX thread and standard c++ thread and atomic library Linker
" let g:ale_cpp_gcc_options = '-std=c++1z' for c++17
" for previous version and default, you can just use
" let g:ale_cpp_gcc_options = '-Wall'
" for more see man pages of gcc
" $ man g++
" make sure g++ in your $PATH
" Add flags according to your requirements
" added c++14 standard support
" POSIX thread and standard c++ thread and atomic library Linker
" let g:ale_cpp_gcc_options = '-std=c++1z' for c++17
" for previous version and default, you can just use
" let g:ale_cpp_gcc_options = '-Wall'
" for more see man pages of gcc
" $ man g++
" make sure g++ in your $PATH
" Add flags according to your requirements
let g:ale_cpp_gcc_options = '-std=c++14 -Wall'
endif

View File

@ -24,11 +24,11 @@ function! ale_linters#crystal#crystal#Handle(buffer, lines) abort
endfunction
function! ale_linters#crystal#crystal#GetCommand(buffer) abort
let l:crystal_cmd = 'crystal build -f json --no-codegen -o '
let l:crystal_cmd .= shellescape(g:ale#util#nul_file)
let l:crystal_cmd .= ' %t'
let l:crystal_cmd = 'crystal build -f json --no-codegen -o '
let l:crystal_cmd .= shellescape(g:ale#util#nul_file)
let l:crystal_cmd .= ' %t'
return l:crystal_cmd
return l:crystal_cmd
endfunction
call ale#linter#Define('crystal', {

View File

@ -1,43 +1,44 @@
" Author: hauleth - https://github.com/hauleth
function! ale_linters#dockerfile#hadolint#Handle(buffer, lines) abort
" Matches patterns line the following:
"
" stdin:19: F: Pipe chain should start with a raw value.
let l:pattern = '\v^/dev/stdin:?(\d+)? (\S+) (.+)$'
let l:output = []
" Matches patterns line the following:
"
" stdin:19: F: Pipe chain should start with a raw value.
let l:pattern = '\v^/dev/stdin:?(\d+)? (\S+) (.+)$'
let l:output = []
for l:line in a:lines
let l:match = matchlist(l:line, l:pattern)
for l:line in a:lines
let l:match = matchlist(l:line, l:pattern)
if len(l:match) == 0
continue
endif
if len(l:match) == 0
continue
endif
let l:lnum = 0
let l:lnum = 0
if l:match[1] !=# ''
let l:lnum = l:match[1] + 0
endif
if l:match[1] !=# ''
let l:lnum = l:match[1] + 0
endif
let l:type = 'W'
let l:text = l:match[3]
let l:type = 'W'
let l:text = l:match[3]
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:lnum,
\ 'col': 0,
\ 'type': l:type,
\ 'text': l:text,
\ 'nr': l:match[2],
\})
endfor
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:lnum,
\ 'col': 0,
\ 'type': l:type,
\ 'text': l:text,
\ 'nr': l:match[2],
\})
endfor
return l:output
return l:output
endfunction
call ale#linter#Define('dockerfile', {
\ 'name': 'hadolint',
\ 'executable': 'hadolint',
\ 'command': 'hadolint -',
\ 'callback': 'ale_linters#dockerfile#hadolint#Handle' })
\ 'name': 'hadolint',
\ 'executable': 'hadolint',
\ 'command': 'hadolint -',
\ 'callback': 'ale_linters#dockerfile#hadolint#Handle',
\})

View File

@ -1,42 +1,43 @@
" Author: hauleth - https://github.com/hauleth
function! ale_linters#elixir#credo#Handle(buffer, lines) abort
" Matches patterns line the following:
"
" lib/filename.ex:19:7: F: Pipe chain should start with a raw value.
let l:pattern = '\v:(\d+):?(\d+)?: (.): (.+)$'
let l:output = []
" Matches patterns line the following:
"
" lib/filename.ex:19:7: F: Pipe chain should start with a raw value.
let l:pattern = '\v:(\d+):?(\d+)?: (.): (.+)$'
let l:output = []
for l:line in a:lines
let l:match = matchlist(l:line, l:pattern)
for l:line in a:lines
let l:match = matchlist(l:line, l:pattern)
if len(l:match) == 0
continue
endif
if len(l:match) == 0
continue
endif
let l:type = l:match[3]
let l:text = l:match[4]
let l:type = l:match[3]
let l:text = l:match[4]
if l:type ==# 'C'
let l:type = 'E'
elseif l:type ==# 'R'
let l:type = 'W'
endif
if l:type ==# 'C'
let l:type = 'E'
elseif l:type ==# 'R'
let l:type = 'W'
endif
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'col': l:match[2] + 0,
\ 'type': l:type,
\ 'text': l:text,
\})
endfor
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'col': l:match[2] + 0,
\ 'type': l:type,
\ 'text': l:text,
\})
endfor
return l:output
return l:output
endfunction
call ale#linter#Define('elixir', {
\ 'name': 'credo',
\ 'executable': 'mix',
\ 'command': 'mix credo suggest --format=flycheck --read-from-stdin %s',
\ 'callback': 'ale_linters#elixir#credo#Handle' })
\ 'name': 'credo',
\ 'executable': 'mix',
\ 'command': 'mix credo suggest --format=flycheck --read-from-stdin %s',
\ 'callback': 'ale_linters#elixir#credo#Handle',
\})

View File

@ -4,22 +4,25 @@
" inspired by work from dzhou121 <dzhou121@gmail.com>
function! ale_linters#go#gobuild#GoEnv(buffer) abort
if exists('s:go_env')
return ''
endif
if exists('s:go_env')
return ''
endif
return 'go env GOPATH GOROOT'
return 'go env GOPATH GOROOT'
endfunction
function! ale_linters#go#gobuild#GetCommand(buffer, goenv_output) abort
if !exists('s:go_env')
let s:go_env = {
\ 'GOPATH': a:goenv_output[0],
\ 'GOROOT': a:goenv_output[1],
\}
endif
" Run go test in local directory with relative path
return 'GOPATH=' . s:go_env.GOPATH . ' cd ' . fnamemodify(bufname(a:buffer), ':.:h') . ' && go test -c -o /dev/null ./'
if !exists('s:go_env')
let s:go_env = {
\ 'GOPATH': a:goenv_output[0],
\ 'GOROOT': a:goenv_output[1],
\}
endif
" Run go test in local directory with relative path
return 'GOPATH=' . s:go_env.GOPATH
\ . ' cd ' . fnamemodify(bufname(a:buffer), ':.:h')
\ . ' && go test -c -o /dev/null ./'
endfunction
function! ale_linters#go#gobuild#Handler(buffer, lines) abort
@ -42,7 +45,7 @@ function! ale_linters#go#gobuild#HandleGoBuildErrors(buffer, full_filename, line
for l:line in a:lines
let l:match = matchlist(l:line, l:pattern)
" Omit errors from imported go packages
" Omit errors from imported go packages
if len(l:match) == 0 || l:line !~ l:filename
continue
endif

View File

@ -27,7 +27,7 @@ endfunction
function! ale_linters#handlebars#embertemplatelint#Handle(buffer, lines) abort
if len(a:lines) == 0
return []
end
endif
let l:output = []

View File

@ -51,7 +51,7 @@ function! ale_linters#nim#nimcheck#Handle(buffer, lines) abort
endfunction
function! ale_linters#nim#nimcheck#GetCommand(buffer)
function! ale_linters#nim#nimcheck#GetCommand(buffer) abort
return 'nim check --path:' . fnameescape(fnamemodify(bufname(a:buffer), ':p:h')) . ' --threads:on --verbosity:0 --colors:off --listFullPaths %t'
endfunction

View File

@ -2,12 +2,11 @@
" Description: Report errors in OCaml code with Merlin
if !exists('g:merlin')
finish
finish
endif
function! ale_linters#ocaml#merlin#Handle(buffer, lines) abort
let l:errors = merlin#ErrorLocList()
return l:errors
return merlin#ErrorLocList()
endfunction
call ale#linter#Define('ocaml', {
@ -16,4 +15,3 @@ call ale#linter#Define('ocaml', {
\ 'command': 'true',
\ 'callback': 'ale_linters#ocaml#merlin#Handle',
\})

View File

@ -32,9 +32,9 @@ function! ale_linters#ruby#rubocop#Handle(buffer, lines) abort
endfunction
function! ale_linters#ruby#rubocop#GetCommand(buffer) abort
return 'rubocop --format emacs --force-exclusion ' .
\ g:ale_ruby_rubocop_options .
\ ' --stdin ' . bufname(a:buffer)
return 'rubocop --format emacs --force-exclusion '
\ . g:ale_ruby_rubocop_options
\ . ' --stdin ' . bufname(a:buffer)
endfunction
" Set this option to change Rubocop options.

View File

@ -8,49 +8,49 @@ let g:ale_tex_chktex_options =
\ get(g:, 'ale_tex_chktex_options', '-I')
function! ale_linters#tex#chktex#GetCommand(buffer) abort
" Check for optional .chktexrc
let l:chktex_config = ale#util#FindNearestFile(
\ a:buffer,
\ '.chktexrc')
" Check for optional .chktexrc
let l:chktex_config = ale#util#FindNearestFile(
\ a:buffer,
\ '.chktexrc')
let l:command = g:ale_tex_chktex_executable
" Avoid bug when used without -p (last warning has gibberish for a filename)
let l:command .= ' -v0 -p stdin -q'
let l:command = g:ale_tex_chktex_executable
" Avoid bug when used without -p (last warning has gibberish for a filename)
let l:command .= ' -v0 -p stdin -q'
if !empty(l:chktex_config)
let l:command .= ' -l ' . fnameescape(l:chktex_config)
endif
if !empty(l:chktex_config)
let l:command .= ' -l ' . fnameescape(l:chktex_config)
endif
let l:command .= ' ' . g:ale_tex_chktex_options
let l:command .= ' ' . g:ale_tex_chktex_options
return l:command
return l:command
endfunction
function! ale_linters#tex#chktex#Handle(buffer, lines) abort
" Mattes lines like:
"
" stdin:499:2:24:Delete this space to maintain correct pagereferences.
" stdin:507:81:3:You should enclose the previous parenthesis with `{}'.
let l:pattern = '^stdin:\(\d\+\):\(\d\+\):\(\d\+\):\(.\+\)$'
let l:output = []
" Mattes lines like:
"
" stdin:499:2:24:Delete this space to maintain correct pagereferences.
" stdin:507:81:3:You should enclose the previous parenthesis with `{}'.
let l:pattern = '^stdin:\(\d\+\):\(\d\+\):\(\d\+\):\(.\+\)$'
let l:output = []
for l:line in a:lines
let l:match = matchlist(l:line, l:pattern)
for l:line in a:lines
let l:match = matchlist(l:line, l:pattern)
if len(l:match) == 0
continue
endif
if len(l:match) == 0
continue
endif
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'col': l:match[2] + 0,
\ 'text': l:match[4] . ' (' . (l:match[3]+0) . ')',
\ 'type': 'W',
\})
endfor
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'col': l:match[2] + 0,
\ 'text': l:match[4] . ' (' . (l:match[3]+0) . ')',
\ 'type': 'W',
\})
endfor
return l:output
return l:output
endfunction
call ale#linter#Define('tex', {

View File

@ -13,38 +13,38 @@ function! ale_linters#tex#lacheck#GetCommand(buffer) abort
endfunction
function! ale_linters#tex#lacheck#Handle(buffer, lines) abort
" Mattes lines like:
"
" "book.tex", line 37: possible unwanted space at "{"
" "book.tex", line 38: missing `\ ' after "etc."
" Mattes lines like:
"
" "book.tex", line 37: possible unwanted space at "{"
" "book.tex", line 38: missing `\ ' after "etc."
let l:pattern = '^".\+", line \(\d\+\): \(.\+\)$'
let l:output = []
let l:pattern = '^".\+", line \(\d\+\): \(.\+\)$'
let l:output = []
for l:line in a:lines
let l:match = matchlist(l:line, l:pattern)
for l:line in a:lines
let l:match = matchlist(l:line, l:pattern)
if len(l:match) == 0
continue
endif
if len(l:match) == 0
continue
endif
" lacheck follows `\input{}` commands. If the cwd is not the same as the
" file in the buffer then it will fail to find the inputed items. We do not
" want warnings from those items anyway
if !empty(matchstr(l:match[2], '^Could not open ".\+"$'))
continue
endif
" lacheck follows `\input{}` commands. If the cwd is not the same as the
" file in the buffer then it will fail to find the inputed items. We do not
" want warnings from those items anyway
if !empty(matchstr(l:match[2], '^Could not open ".\+"$'))
continue
endif
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'col': 0,
\ 'text': l:match[2],
\ 'type': 'W',
\})
endfor
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'col': 0,
\ 'text': l:match[2],
\ 'type': 'W',
\})
endfor
return l:output
return l:output
endfunction
call ale#linter#Define('tex', {