summaryrefslogtreecommitdiff
path: root/ale_linters/php
diff options
context:
space:
mode:
authormedains <medains@github.com.fake>2017-02-01 16:09:33 +0000
committermedains <medains@github.com.fake>2017-02-01 16:28:51 +0000
commitff096124c6d128bef222aa6954da636c075b05d8 (patch)
tree2534a4502691dbf0bd3f723d32df6134f9ef7d73 /ale_linters/php
parent512b6e00d9379700d65dbf7701dc9631f62866d8 (diff)
downloadale-ff096124c6d128bef222aa6954da636c075b05d8.zip
Linter addition of PHP Mess Detector
Diffstat (limited to 'ale_linters/php')
-rw-r--r--ale_linters/php/phpmd.vim41
1 files changed, 41 insertions, 0 deletions
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 <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#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',
+\})