1
0
Fork 0
mirror of synced 2024-11-30 04:35:35 -05:00
ultimate-vim/sources_non_forked/ale/ale_linters/php/phpmd.vim

39 lines
1.2 KiB
VimL
Raw Normal View History

" 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#GetCommand(buffer) abort
2024-01-07 10:14:20 -05:00
return '%e %t text'
2018-08-25 12:13:42 -04:00
\ . ale#Pad(ale#Var(a:buffer, 'php_phpmd_ruleset'))
2024-01-07 10:14:20 -05:00
\ . ' --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',
2019-03-08 06:04:56 -05:00
\ 'executable': {b -> ale#Var(b, 'php_phpmd_executable')},
\ 'command': function('ale_linters#php#phpmd#GetCommand'),
\ 'callback': 'ale_linters#php#phpmd#Handle',
\})