X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/0ee596c5c5e11fc79598407eaf22f83d279f7e9e..5a4872f466ebd76ddd532bdf2798554421c53df4:/.vim/bundle/ale/ale_linters/php/phpmd.vim diff --git a/.vim/bundle/ale/ale_linters/php/phpmd.vim b/.vim/bundle/ale/ale_linters/php/phpmd.vim new file mode 100644 index 00000000..368a66c3 --- /dev/null +++ b/.vim/bundle/ale/ale_linters/php/phpmd.vim @@ -0,0 +1,38 @@ +" Author: medains , David Sierra +" 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#GetCommand(buffer) abort + return '%e %t text' + \ . ale#Pad(ale#Var(a:buffer, 'php_phpmd_ruleset')) + \ . ' --ignore-violations-on-exit' +endfunction + +function! ale_linters#php#phpmd#Handle(buffer, lines) abort + " Matches against lines like the following: + " + " /path/to/some-filename.php:18 message + let l:pattern = '^.*:\(\d\+\)\s\+\(.\+\)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'text': l:match[2], + \ 'type': 'W', + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('php', { +\ 'name': 'phpmd', +\ 'executable': {b -> ale#Var(b, 'php_phpmd_executable')}, +\ 'command': function('ale_linters#php#phpmd#GetCommand'), +\ 'callback': 'ale_linters#php#phpmd#Handle', +\})