summaryrefslogtreecommitdiff
path: root/ale_linters/php
diff options
context:
space:
mode:
authorDavid Sierra DiazGranados <davidsierradz@gmail.com>2017-11-05 13:53:12 -0500
committerw0rp <w0rp@users.noreply.github.com>2017-11-05 18:53:12 +0000
commit7086586b1776d2b5f3bf87a7f0c25595a5d7e1b0 (patch)
tree6291c26a2c6529864ae80444b1d360bb9e7b4cf5 /ale_linters/php
parent7b5108d934d8682490ab3d9af25361e06a3df3f8 (diff)
downloadale-7086586b1776d2b5f3bf87a7f0c25595a5d7e1b0.zip
Add executable option for phpmd linter (resolves #1076) (#1078)
* Add executable option for phpmd linter (resolves #1076) * Add test for phpmd executable option
Diffstat (limited to 'ale_linters/php')
-rw-r--r--ale_linters/php/phpmd.vim15
1 files changed, 12 insertions, 3 deletions
diff --git a/ale_linters/php/phpmd.vim b/ale_linters/php/phpmd.vim
index e4192c70..e9450752 100644
--- a/ale_linters/php/phpmd.vim
+++ b/ale_linters/php/phpmd.vim
@@ -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
+let g:ale_php_phpmd_executable = get(g:, 'ale_php_phpmd_executable', 'phpmd')
+
" Set to change the ruleset
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
- 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')
\ . ' --ignore-violations-on-exit %t'
endfunction
@@ -30,7 +39,7 @@ endfunction
call ale#linter#Define('php', {
\ 'name': 'phpmd',
-\ 'executable': 'phpmd',
+\ 'executable_callback': 'ale_linters#php#phpmd#GetExecutable',
\ 'command_callback': 'ale_linters#php#phpmd#GetCommand',
\ 'callback': 'ale_linters#php#phpmd#Handle',
\})