ale/ale_linters/php/phpmd.vim

37 lines
1.1 KiB
VimL
Raw Normal View History

2017-02-01 16:09:33 +00:00
" Author: medains <https://github.com/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#GetCommand(buffer) abort
return 'phpmd %s text '
\ . ale#Var(a:buffer, 'php_phpmd_ruleset')
\ . ' --ignore-violations-on-exit %t'
endfunction
2017-02-01 16:09:33 +00:00
function! ale_linters#php#phpmd#Handle(buffer, lines) abort
" Matches against lines like the following:
"
" /path/to/some-filename.php:18 message
2017-10-22 16:56:09 +00:00
let l:pattern = '^.*:\(\d\+\)\s\+\(.\+\)$'
2017-02-01 16:09:33 +00:00
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
2017-02-01 16:09:33 +00:00
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': 'phpmd',
\ 'command_callback': 'ale_linters#php#phpmd#GetCommand',
2017-02-01 16:09:33 +00:00
\ 'callback': 'ale_linters#php#phpmd#Handle',
\})