Fix #1611 - Fix perlcritic escaping on Windows

This commit is contained in:
w0rp 2018-05-28 12:51:06 +01:00
parent eaf35bc611
commit cd0dc0a227
No known key found for this signature in database
GPG Key ID: 0FC1ECAA8C81CD83
2 changed files with 19 additions and 16 deletions

View File

@ -18,9 +18,9 @@ function! ale_linters#perl#perlcritic#GetExecutable(buffer) abort
endfunction endfunction
function! ale_linters#perl#perlcritic#GetProfile(buffer) abort function! ale_linters#perl#perlcritic#GetProfile(buffer) abort
" first see if we've been overridden " first see if we've been overridden
let l:profile = ale#Var(a:buffer, 'perl_perlcritic_profile') let l:profile = ale#Var(a:buffer, 'perl_perlcritic_profile')
if l:profile is? '' if l:profile is? ''
return '' return ''
endif endif
@ -31,6 +31,7 @@ endfunction
function! ale_linters#perl#perlcritic#GetCommand(buffer) abort function! ale_linters#perl#perlcritic#GetCommand(buffer) abort
let l:critic_verbosity = '%l:%c %m\n' let l:critic_verbosity = '%l:%c %m\n'
if ale#Var(a:buffer, 'perl_perlcritic_showrules') if ale#Var(a:buffer, 'perl_perlcritic_showrules')
let l:critic_verbosity = '%l:%c %m [%p]\n' let l:critic_verbosity = '%l:%c %m [%p]\n'
endif endif
@ -38,17 +39,11 @@ function! ale_linters#perl#perlcritic#GetCommand(buffer) abort
let l:profile = ale_linters#perl#perlcritic#GetProfile(a:buffer) let l:profile = ale_linters#perl#perlcritic#GetProfile(a:buffer)
let l:options = ale#Var(a:buffer, 'perl_perlcritic_options') let l:options = ale#Var(a:buffer, 'perl_perlcritic_options')
let l:command = ale#Escape(ale_linters#perl#perlcritic#GetExecutable(a:buffer)) return ale#Escape(ale_linters#perl#perlcritic#GetExecutable(a:buffer))
\ . " --verbose '". l:critic_verbosity . "' --nocolor" \ . ' --verbose ' . ale#Escape(l:critic_verbosity)
\ . ' --nocolor'
if l:profile isnot? '' \ . (!empty(l:profile) ? ' --profile ' . ale#Escape(l:profile) : '')
let l:command .= ' --profile ' . ale#Escape(l:profile) \ . (!empty(l:options) ? ' ' . l:options : '')
endif
if l:options isnot? ''
let l:command .= ' ' . l:options
endif
return l:command
endfunction endfunction

View File

@ -30,14 +30,18 @@ Execute(The command should be correct with g:ale_perl_perlcritic_showrules off):
let b:ale_perl_perlcritic_showrules = 0 let b:ale_perl_perlcritic_showrules = 0
AssertEqual AssertEqual
\ ale#Escape('perlcritic') . ' --verbose ''%l:%c %m\n'' --nocolor', \ ale#Escape('perlcritic')
\ . ' --verbose ' . ale#Escape('%l:%c %m\n')
\ . ' --nocolor',
\ ale_linters#perl#perlcritic#GetCommand(bufnr('')) \ ale_linters#perl#perlcritic#GetCommand(bufnr(''))
Execute(The command should be correct with g:ale_perl_perlcritic_showrules on): Execute(The command should be correct with g:ale_perl_perlcritic_showrules on):
let b:ale_perl_perlcritic_showrules = 1 let b:ale_perl_perlcritic_showrules = 1
AssertEqual AssertEqual
\ ale#Escape('perlcritic') . ' --verbose ''%l:%c %m [%p]\n'' --nocolor', \ ale#Escape('perlcritic')
\ . ' --verbose ' . ale#Escape('%l:%c %m [%p]\n')
\ . ' --nocolor',
\ ale_linters#perl#perlcritic#GetCommand(bufnr('')) \ ale_linters#perl#perlcritic#GetCommand(bufnr(''))
Execute(The command search for the profile file when set): Execute(The command search for the profile file when set):
@ -46,7 +50,9 @@ Execute(The command search for the profile file when set):
let b:readme_path = ale#path#Simplify(expand('%:p:h:h:h') . '/README.md') let b:readme_path = ale#path#Simplify(expand('%:p:h:h:h') . '/README.md')
AssertEqual AssertEqual
\ ale#Escape('perlcritic') . ' --verbose ''%l:%c %m\n'' --nocolor' \ ale#Escape('perlcritic')
\ . ' --verbose ' . ale#Escape('%l:%c %m\n')
\ . ' --nocolor'
\ . ' --profile ' . ale#Escape(b:readme_path), \ . ' --profile ' . ale#Escape(b:readme_path),
\ ale_linters#perl#perlcritic#GetCommand(bufnr('')) \ ale_linters#perl#perlcritic#GetCommand(bufnr(''))
@ -54,6 +60,8 @@ Execute(Extra options should be set appropriately):
let b:ale_perl_perlcritic_options = 'beep boop' let b:ale_perl_perlcritic_options = 'beep boop'
AssertEqual AssertEqual
\ ale#Escape('perlcritic') . ' --verbose ''%l:%c %m\n'' --nocolor' \ ale#Escape('perlcritic')
\ . ' --verbose ' . ale#Escape('%l:%c %m\n')
\ . ' --nocolor'
\ . ' beep boop', \ . ' beep boop',
\ ale_linters#perl#perlcritic#GetCommand(bufnr('')) \ ale_linters#perl#perlcritic#GetCommand(bufnr(''))