Respect warn_about_trailing_whitespace for gitlint

This commit is contained in:
w0rp 2018-06-03 10:45:40 +01:00
parent 786fc0a62f
commit 0db12702f3
No known key found for this signature in database
GPG Key ID: 0FC1ECAA8C81CD83
2 changed files with 35 additions and 2 deletions

View File

@ -28,6 +28,10 @@ function! ale_linters#gitcommit#gitlint#Handle(buffer, lines) abort
for l:match in ale#util#GetMatches(a:lines, l:pattern) for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:code = l:match[2] let l:code = l:match[2]
if l:code is# 'T2' && !ale#Var(a:buffer, 'warn_about_trailing_whitespace')
continue
endif
let l:item = { let l:item = {
\ 'lnum': l:match[1] + 0, \ 'lnum': l:match[1] + 0,
\ 'text': l:match[3], \ 'text': l:match[3],

View File

@ -1,8 +1,16 @@
Before: Before:
runtime ale_linters/gitcommit/gitlint.vim Save g:ale_warn_about_trailing_whitespace
let g:ale_warn_about_trailing_whitespace = 1
runtime ale_linters/gitcommit/gitlint.vim
After: After:
call ale#linter#Reset() Restore
unlet! b:ale_warn_about_trailing_whitespace
call ale#linter#Reset()
Execute(The gitlint handler should handle basic warnings and syntax errors): Execute(The gitlint handler should handle basic warnings and syntax errors):
AssertEqual AssertEqual
@ -39,3 +47,24 @@ Execute(The gitlint handler should handle basic warnings and syntax errors):
\ '8: T1 Title exceeds max length (92>72): "some very long commit subject line where the author can''t wait to explain what he just fixed"' \ '8: T1 Title exceeds max length (92>72): "some very long commit subject line where the author can''t wait to explain what he just fixed"'
\ ]) \ ])
Execute(Disabling trailing whitespace warnings should work):
AssertEqual
\ [
\ {
\ 'lnum': 8,
\ 'type': 'E',
\ 'text': 'Trailing whitespace',
\ 'code': 'T2',
\ },
\ ],
\ ale_linters#gitcommit#gitlint#Handle(bufnr(''), [
\ '8: T2 Trailing whitespace',
\])
let b:ale_warn_about_trailing_whitespace = 0
AssertEqual
\ [],
\ ale_linters#gitcommit#gitlint#Handle(bufnr(''), [
\ '8: T2 Trailing whitespace',
\ ])