#430 Use the style sub_type for flake8 problems

This commit is contained in:
w0rp 2017-06-14 16:40:03 +01:00
parent f6b0a28cba
commit 07af1799b1
2 changed files with 26 additions and 8 deletions

View File

@ -117,7 +117,6 @@ function! ale_linters#python#flake8#Handle(buffer, lines) abort
" Matches patterns line the following: " Matches patterns line the following:
" "
" stdin:6:6: E111 indentation is not a multiple of four " stdin:6:6: E111 indentation is not a multiple of four
" test.yml:35: [EANSIBLE0002] Trailing whitespace
let l:pattern = '\v^[a-zA-Z]?:?[^:]+:(\d+):?(\d+)?: ([[:alnum:]]+) (.*)$' let l:pattern = '\v^[a-zA-Z]?:?[^:]+:(\d+):?(\d+)?: ([[:alnum:]]+) (.*)$'
let l:output = [] let l:output = []
@ -134,9 +133,18 @@ function! ale_linters#python#flake8#Handle(buffer, lines) abort
\ 'lnum': l:match[1] + 0, \ 'lnum': l:match[1] + 0,
\ 'col': l:match[2] + 0, \ 'col': l:match[2] + 0,
\ 'text': l:code . ': ' . l:match[4], \ 'text': l:code . ': ' . l:match[4],
\ 'type': l:code[:0] ==# 'E' ? 'E' : 'W', \ 'type': 'W',
\} \}
if l:code[:0] ==# 'F'
let l:item.type = 'E'
elseif l:code[:0] ==# 'E'
let l:item.type = 'E'
let l:item.sub_type = 'style'
elseif l:code[:0] ==# 'W'
let l:item.sub_type = 'style'
endif
let l:end_col_pattern = get(s:end_col_pattern_map, l:code, '') let l:end_col_pattern = get(s:end_col_pattern_map, l:code, '')
if !empty(l:end_col_pattern) if !empty(l:end_col_pattern)

View File

@ -4,7 +4,7 @@ Before:
After: After:
call ale#linter#Reset() call ale#linter#Reset()
Execute(The flake8 handler should handle basic errors): Execute(The flake8 handler should handle basic warnings):
AssertEqual AssertEqual
\ [ \ [
\ { \ {
@ -12,10 +12,19 @@ Execute(The flake8 handler should handle basic errors):
\ 'col': 6, \ 'col': 6,
\ 'type': 'E', \ 'type': 'E',
\ 'text': 'E111: indentation is not a multiple of four', \ 'text': 'E111: indentation is not a multiple of four',
\ 'sub_type': 'style',
\ },
\ {
\ 'lnum': 7,
\ 'col': 6,
\ 'type': 'W',
\ 'text': 'W123: some warning',
\ 'sub_type': 'style',
\ }, \ },
\ ], \ ],
\ ale_linters#python#flake8#Handle(1, [ \ ale_linters#python#flake8#Handle(1, [
\ 'stdin:6:6: E111 indentation is not a multiple of four', \ 'stdin:6:6: E111 indentation is not a multiple of four',
\ 'stdin:7:6: W123 some warning',
\ ]) \ ])
Execute(The flake8 handler should set end column indexes should be set for certain errors): Execute(The flake8 handler should set end column indexes should be set for certain errors):
@ -24,35 +33,35 @@ Execute(The flake8 handler should set end column indexes should be set for certa
\ { \ {
\ 'lnum': 25, \ 'lnum': 25,
\ 'col': 1, \ 'col': 1,
\ 'type': 'W', \ 'type': 'E',
\ 'end_col': 3, \ 'end_col': 3,
\ 'text': 'F821: undefined name ''foo''', \ 'text': 'F821: undefined name ''foo''',
\ }, \ },
\ { \ {
\ 'lnum': 28, \ 'lnum': 28,
\ 'col': 5, \ 'col': 5,
\ 'type': 'W', \ 'type': 'E',
\ 'end_col': 9, \ 'end_col': 9,
\ 'text': 'F405: hello may be undefined, or defined from star imports: x', \ 'text': 'F405: hello may be undefined, or defined from star imports: x',
\ }, \ },
\ { \ {
\ 'lnum': 104, \ 'lnum': 104,
\ 'col': 5, \ 'col': 5,
\ 'type': 'W', \ 'type': 'E',
\ 'end_col': 12, \ 'end_col': 12,
\ 'text': 'F999: ''continue'' not properly in loop', \ 'text': 'F999: ''continue'' not properly in loop',
\ }, \ },
\ { \ {
\ 'lnum': 106, \ 'lnum': 106,
\ 'col': 5, \ 'col': 5,
\ 'type': 'W', \ 'type': 'E',
\ 'end_col': 9, \ 'end_col': 9,
\ 'text': 'F999: ''break'' outside loop', \ 'text': 'F999: ''break'' outside loop',
\ }, \ },
\ { \ {
\ 'lnum': 109, \ 'lnum': 109,
\ 'col': 5, \ 'col': 5,
\ 'type': 'W', \ 'type': 'E',
\ 'end_col': 8, \ 'end_col': 8,
\ 'text': 'F841: local variable ''test'' is assigned to but never used', \ 'text': 'F841: local variable ''test'' is assigned to but never used',
\ }, \ },
@ -110,6 +119,7 @@ Execute (The flake8 handler should handle names with spaces):
\ 'col': 6, \ 'col': 6,
\ 'type': 'E', \ 'type': 'E',
\ 'text': 'E111: indentation is not a multiple of four', \ 'text': 'E111: indentation is not a multiple of four',
\ 'sub_type': 'style',
\ }, \ },
\ ], \ ],
\ ale_linters#python#flake8#Handle(42, [ \ ale_linters#python#flake8#Handle(42, [