mirror of
https://github.com/dense-analysis/ale
synced 2024-12-24 15:13:02 +00:00
Fix #1186 - Use -w by default for Perl, which does not execute code
This commit is contained in:
parent
83760a0952
commit
f5fc746d00
@ -1,18 +1,15 @@
|
||||
" Author: Vincent Lequertier <https://github.com/SkySymbol>
|
||||
" Description: This file adds support for checking perl syntax
|
||||
|
||||
let g:ale_perl_perl_executable =
|
||||
\ get(g:, 'ale_perl_perl_executable', 'perl')
|
||||
|
||||
let g:ale_perl_perl_options =
|
||||
\ get(g:, 'ale_perl_perl_options', '-c -Mwarnings -Ilib')
|
||||
call ale#Set('perl_perl_executable', 'perl')
|
||||
call ale#Set('perl_perl_options', '-w -Mwarnings -Ilib')
|
||||
|
||||
function! ale_linters#perl#perl#GetExecutable(buffer) abort
|
||||
return ale#Var(a:buffer, 'perl_perl_executable')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#perl#perl#GetCommand(buffer) abort
|
||||
return ale_linters#perl#perl#GetExecutable(a:buffer)
|
||||
return ale#Escape(ale_linters#perl#perl#GetExecutable(a:buffer))
|
||||
\ . ' ' . ale#Var(a:buffer, 'perl_perl_options')
|
||||
\ . ' %t'
|
||||
endfunction
|
||||
|
@ -16,11 +16,15 @@ g:ale_perl_perl_executable *g:ale_perl_perl_executable*
|
||||
g:ale_perl_perl_options *g:ale_perl_perl_options*
|
||||
*b:ale_perl_perl_options*
|
||||
Type: |String|
|
||||
Default: `'-c -Mwarnings -Ilib'`
|
||||
Default: `'-w -Mwarnings -Ilib'`
|
||||
|
||||
This variable can be changed to alter the command-line arguments to the perl
|
||||
invocation.
|
||||
|
||||
Perl code is checked with `-w` by default, because `-c` can execute
|
||||
malicious code. You can use the `-c` option at your own risk. See
|
||||
|g:ale_pattern_options| for changing the option only for specific files.
|
||||
|
||||
|
||||
===============================================================================
|
||||
perlcritic *ale-perl-perlcritic*
|
||||
|
37
test/command_callback/test_perl_command_callback.vader
Normal file
37
test/command_callback/test_perl_command_callback.vader
Normal file
@ -0,0 +1,37 @@
|
||||
Before:
|
||||
Save g:ale_perl_perl_executable
|
||||
Save g:ale_perl_perl_options
|
||||
|
||||
unlet! g:ale_perl_perl_executable
|
||||
unlet! g:ale_perl_perl_options
|
||||
|
||||
runtime ale_linters/perl/perl.vim
|
||||
|
||||
After:
|
||||
Restore
|
||||
|
||||
unlet! b:ale_perl_perl_executable
|
||||
unlet! b:ale_perl_perl_options
|
||||
|
||||
call ale#linter#Reset()
|
||||
|
||||
Execute(The default Perl command callback should be correct):
|
||||
AssertEqual
|
||||
\ 'perl',
|
||||
\ ale_linters#perl#perl#GetExecutable(bufnr(''))
|
||||
|
||||
AssertEqual
|
||||
\ ale#Escape('perl') . ' -w -Mwarnings -Ilib %t',
|
||||
\ ale_linters#perl#perl#GetCommand(bufnr(''))
|
||||
|
||||
Execute(Overriding the executable and command should work):
|
||||
let b:ale_perl_perl_executable = 'foobar'
|
||||
let b:ale_perl_perl_options = '-c'
|
||||
|
||||
AssertEqual
|
||||
\ 'foobar',
|
||||
\ ale_linters#perl#perl#GetExecutable(bufnr(''))
|
||||
|
||||
AssertEqual
|
||||
\ ale#Escape('foobar') . ' -c %t',
|
||||
\ ale_linters#perl#perl#GetCommand(bufnr(''))
|
Loading…
Reference in New Issue
Block a user