Fix code style issues and refactor to use ale#Var

This commit is contained in:
haginaga 2018-05-27 22:19:31 +09:00
parent 230656e678
commit feab494286

View File

@ -9,7 +9,8 @@ let g:ale_php_phan_use_client = get(g:, 'ale_php_phan_use_client', 0)
function! ale_linters#php#phan#GetExecutable(buffer) abort function! ale_linters#php#phan#GetExecutable(buffer) abort
let l:executable = ale#Var(a:buffer, 'php_phan_executable') let l:executable = ale#Var(a:buffer, 'php_phan_executable')
if g:ale_php_phan_use_client == 1 && l:executable is# 'phan'
if ale#Var(a:buffer, 'php_phan_use_client') == 1 && l:executable is# 'phan'
let l:executable = 'phan_client' let l:executable = 'phan_client'
endif endif
@ -17,7 +18,7 @@ function! ale_linters#php#phan#GetExecutable(buffer) abort
endfunction endfunction
function! ale_linters#php#phan#GetCommand(buffer) abort function! ale_linters#php#phan#GetCommand(buffer) abort
if g:ale_php_phan_use_client == 1 if ale#Var(a:buffer, 'php_phan_use_client') == 1
let l:args = '-l ' let l:args = '-l '
\ . ' %s' \ . ' %s'
else else
@ -33,7 +34,7 @@ endfunction
function! ale_linters#php#phan#Handle(buffer, lines) abort function! ale_linters#php#phan#Handle(buffer, lines) abort
" Matches against lines like the following: " Matches against lines like the following:
if g:ale_php_phan_use_client == 1 if ale#Var(a:buffer, 'php_phan_use_client') == 1
" Phan error: ERRORTYPE: message in /path/to/some-filename.php on line nnn " Phan error: ERRORTYPE: message in /path/to/some-filename.php on line nnn
let l:pattern = '^Phan error: \(\w\+\): \(.\+\) in \(.\+\) on line \(\d\+\)$' let l:pattern = '^Phan error: \(\w\+\): \(.\+\) in \(.\+\) on line \(\d\+\)$'
else else
@ -42,8 +43,9 @@ function! ale_linters#php#phan#Handle(buffer, lines) abort
endif endif
let l:output = [] let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern) for l:match in ale#util#GetMatches(a:lines, l:pattern)
if g:ale_php_phan_use_client == 1 if ale#Var('php_phan_use_client') == 1
let l:dict = { let l:dict = {
\ 'lnum': l:match[4] + 0, \ 'lnum': l:match[4] + 0,
\ 'text': l:match[2], \ 'text': l:match[2],