#852 Capture error codes for pylint, throw away the msgid values

This commit is contained in:
w0rp 2017-11-15 17:35:34 +00:00
parent 08f4f8f0fc
commit cf538c3a58
2 changed files with 45 additions and 8 deletions

View File

@ -45,7 +45,8 @@ function! ale_linters#python#pylint#Handle(buffer, lines) abort
call add(l:output, { call add(l:output, {
\ 'lnum': l:match[1] + 0, \ 'lnum': l:match[1] + 0,
\ 'col': l:match[2] + 1, \ 'col': l:match[2] + 1,
\ 'text': l:code . ': ' . l:match[5] . ' (' . l:match[4] . ')', \ 'text': l:match[5],
\ 'code': l:match[4],
\ 'type': l:code[:0] is# 'E' ? 'E' : 'W', \ 'type': l:code[:0] is# 'E' ? 'E' : 'W',
\}) \})
endfor endfor

View File

@ -1,47 +1,60 @@
Before: Before:
Save g:ale_warn_about_trailing_whitespace
let g:ale_warn_about_trailing_whitespace = 1
runtime ale_linters/python/pylint.vim runtime ale_linters/python/pylint.vim
After: After:
Restore
call ale#linter#Reset() call ale#linter#Reset()
silent file something_else.py silent file something_else.py
Execute(pylint handler parsing, translating columns to 1-based index): Execute(Basic pylint errors should be handle):
AssertEqual AssertEqual
\ [ \ [
\ { \ {
\ 'lnum': 4, \ 'lnum': 4,
\ 'col': 1, \ 'col': 1,
\ 'text': 'C0303: Trailing whitespace (trailing-whitespace)', \ 'text': 'Trailing whitespace',
\ 'code': 'trailing-whitespace',
\ 'type': 'W', \ 'type': 'W',
\ }, \ },
\ { \ {
\ 'lnum': 1, \ 'lnum': 1,
\ 'col': 1, \ 'col': 1,
\ 'text': 'C0111: Missing module docstring (missing-docstring)', \ 'text': 'Missing module docstring',
\ 'code': 'missing-docstring',
\ 'type': 'W', \ 'type': 'W',
\ }, \ },
\ { \ {
\ 'lnum': 2, \ 'lnum': 2,
\ 'col': 1, \ 'col': 1,
\ 'text': 'C0111: Missing function docstring (missing-docstring)', \ 'text': 'Missing function docstring',
\ 'code': 'missing-docstring',
\ 'type': 'W', \ 'type': 'W',
\ }, \ },
\ { \ {
\ 'lnum': 3, \ 'lnum': 3,
\ 'col': 5, \ 'col': 5,
\ 'text': 'E0103: ''break'' not properly in loop (not-in-loop)', \ 'text': '''break'' not properly in loop',
\ 'code': 'not-in-loop',
\ 'type': 'E', \ 'type': 'E',
\ }, \ },
\ { \ {
\ 'lnum': 4, \ 'lnum': 4,
\ 'col': 5, \ 'col': 5,
\ 'text': 'W0101: Unreachable code (unreachable)', \ 'text': 'Unreachable code',
\ 'code': 'unreachable',
\ 'type': 'W', \ 'type': 'W',
\ }, \ },
\ { \ {
\ 'lnum': 7, \ 'lnum': 7,
\ 'col': 33, \ 'col': 33,
\ 'text': 'W0702: No exception type(s) specified (bare-except)', \ 'text': 'No exception type(s) specified',
\ 'code': 'bare-except',
\ 'type': 'W', \ 'type': 'W',
\ }, \ },
\ ], \ ],
@ -58,3 +71,26 @@ Execute(pylint handler parsing, translating columns to 1-based index):
\ '------------------------------------------------------------------', \ '------------------------------------------------------------------',
\ 'Your code has been rated at 0.00/10 (previous run: 2.50/10, -2.50)', \ 'Your code has been rated at 0.00/10 (previous run: 2.50/10, -2.50)',
\ ]) \ ])
Execute(Ignoring trailing whitespace messages should work):
let g:ale_warn_about_trailing_whitespace = 0
AssertEqual
\ [
\ {
\ 'lnum': 1,
\ 'col': 1,
\ 'text': 'Missing module docstring',
\ 'code': 'missing-docstring',
\ 'type': 'W',
\ },
\ ],
\ ale_linters#python#pylint#Handle(bufnr(''), [
\ 'No config file found, using default configuration',
\ '************* Module test',
\ 'test.py:4:0: C0303 (trailing-whitespace) Trailing whitespace',
\ 'test.py:1:0: C0111 (missing-docstring) Missing module docstring',
\ '',
\ '------------------------------------------------------------------',
\ 'Your code has been rated at 0.00/10 (previous run: 2.50/10, -2.50)',
\ ])