* Add executable option for phpmd linter (resolves #1076) * Add test for phpmd executable option
This commit is contained in:
parent
7b5108d934
commit
7086586b17
@ -1,11 +1,20 @@
|
|||||||
" Author: medains <https://github.com/medains>
|
" Author: medains <https://github.com/medains>, David Sierra <https://github.com/davidsierradz>
|
||||||
" Description: phpmd for PHP files
|
" Description: phpmd for PHP files
|
||||||
|
|
||||||
|
let g:ale_php_phpmd_executable = get(g:, 'ale_php_phpmd_executable', 'phpmd')
|
||||||
|
|
||||||
" Set to change the ruleset
|
" Set to change the ruleset
|
||||||
let g:ale_php_phpmd_ruleset = get(g:, 'ale_php_phpmd_ruleset', 'cleancode,codesize,controversial,design,naming,unusedcode')
|
let g:ale_php_phpmd_ruleset = get(g:, 'ale_php_phpmd_ruleset', 'cleancode,codesize,controversial,design,naming,unusedcode')
|
||||||
|
|
||||||
|
function! ale_linters#php#phpmd#GetExecutable(buffer) abort
|
||||||
|
return ale#Var(a:buffer, 'php_phpmd_executable')
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#php#phpmd#GetCommand(buffer) abort
|
function! ale_linters#php#phpmd#GetCommand(buffer) abort
|
||||||
return 'phpmd %s text '
|
let l:executable = ale_linters#php#phpmd#GetExecutable(a:buffer)
|
||||||
|
|
||||||
|
return ale#Escape(l:executable)
|
||||||
|
\ . ' %s text '
|
||||||
\ . ale#Var(a:buffer, 'php_phpmd_ruleset')
|
\ . ale#Var(a:buffer, 'php_phpmd_ruleset')
|
||||||
\ . ' --ignore-violations-on-exit %t'
|
\ . ' --ignore-violations-on-exit %t'
|
||||||
endfunction
|
endfunction
|
||||||
@ -30,7 +39,7 @@ endfunction
|
|||||||
|
|
||||||
call ale#linter#Define('php', {
|
call ale#linter#Define('php', {
|
||||||
\ 'name': 'phpmd',
|
\ 'name': 'phpmd',
|
||||||
\ 'executable': 'phpmd',
|
\ 'executable_callback': 'ale_linters#php#phpmd#GetExecutable',
|
||||||
\ 'command_callback': 'ale_linters#php#phpmd#GetCommand',
|
\ 'command_callback': 'ale_linters#php#phpmd#GetCommand',
|
||||||
\ 'callback': 'ale_linters#php#phpmd#Handle',
|
\ 'callback': 'ale_linters#php#phpmd#Handle',
|
||||||
\})
|
\})
|
||||||
|
@ -121,6 +121,14 @@ g:ale_php_phpcs_use_global *g:ale_php_phpcs_use_global*
|
|||||||
===============================================================================
|
===============================================================================
|
||||||
phpmd *ale-php-phpmd*
|
phpmd *ale-php-phpmd*
|
||||||
|
|
||||||
|
g:ale_php_phpmd_executable *g:ale_php_phpmd_executable*
|
||||||
|
*b:ale_php_phpmd_executable*
|
||||||
|
Type: |String|
|
||||||
|
Default: `'phpmd'`
|
||||||
|
|
||||||
|
This variable sets executable used for phpmd.
|
||||||
|
|
||||||
|
|
||||||
g:ale_php_phpmd_ruleset *g:ale_php_phpmd_ruleset*
|
g:ale_php_phpmd_ruleset *g:ale_php_phpmd_ruleset*
|
||||||
*b:ale_php_phpmd_ruleset*
|
*b:ale_php_phpmd_ruleset*
|
||||||
Type: |String|
|
Type: |String|
|
||||||
|
20
test/command_callback/test_phpmd_command_callbacks.vader
Normal file
20
test/command_callback/test_phpmd_command_callbacks.vader
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
Before:
|
||||||
|
Save g:ale_php_phpmd_executable
|
||||||
|
|
||||||
|
unlet! g:ale_php_phpmd_executable
|
||||||
|
|
||||||
|
runtime ale_linters/php/phpmd.vim
|
||||||
|
|
||||||
|
After:
|
||||||
|
Restore
|
||||||
|
|
||||||
|
call ale#linter#Reset()
|
||||||
|
|
||||||
|
Execute(Custom executables should be used for the executable and command):
|
||||||
|
let g:ale_php_phpmd_executable = 'phpmd_test'
|
||||||
|
|
||||||
|
AssertEqual 'phpmd_test', ale_linters#php#phpmd#GetExecutable(bufnr(''))
|
||||||
|
AssertEqual
|
||||||
|
\ ale#Escape('phpmd_test')
|
||||||
|
\ . ' %s text cleancode,codesize,controversial,design,naming,unusedcode --ignore-violations-on-exit %t',
|
||||||
|
\ ale_linters#php#phpmd#GetCommand(bufnr(''))
|
Loading…
x
Reference in New Issue
Block a user