From ff096124c6d128bef222aa6954da636c075b05d8 Mon Sep 17 00:00:00 2001 From: medains Date: Wed, 1 Feb 2017 16:09:33 +0000 Subject: Linter addition of PHP Mess Detector --- ale_linters/php/phpmd.vim | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 ale_linters/php/phpmd.vim (limited to 'ale_linters') diff --git a/ale_linters/php/phpmd.vim b/ale_linters/php/phpmd.vim new file mode 100644 index 00000000..73432538 --- /dev/null +++ b/ale_linters/php/phpmd.vim @@ -0,0 +1,41 @@ +" Author: medains +" Description: phpmd for PHP files + +" 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#Handle(buffer, lines) abort + " Matches against lines like the following: + " + " /path/to/some-filename.php:18 message + let l:pattern = '^.*:\(\d\+\)\t\(.\+\)$' + let l:output = [] + + for l:line in a:lines + let l:match = matchlist(l:line, l:pattern) + + if len(l:match) == 0 + continue + endif + + " vcol is Needed to indicate that the column is a character. + call add(l:output, { + \ 'bufnr': a:buffer, + \ 'lnum': l:match[1] + 0, + \ 'vcol': 0, + \ 'col': 0, + \ 'text': l:match[2], + \ 'type': 'W', + \ 'nr': -1, + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('php', { +\ 'name': 'phpmd', +\ 'executable': 'phpmd', +\ 'command': g:ale#util#stdin_wrapper . ' .php phpmd %s text ' . g:ale_php_phpmd_ruleset . ' --ignore-violations-on-exit', +\ 'callback': 'ale_linters#php#phpmd#Handle', +\}) -- cgit v1.2.3