summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ale_linters/gitcommit/gitlint.vim4
-rw-r--r--test/handler/test_gitlint_handler.vader33
2 files changed, 35 insertions, 2 deletions
diff --git a/ale_linters/gitcommit/gitlint.vim b/ale_linters/gitcommit/gitlint.vim
index 0b4ca0fc..64731055 100644
--- a/ale_linters/gitcommit/gitlint.vim
+++ b/ale_linters/gitcommit/gitlint.vim
@@ -28,6 +28,10 @@ function! ale_linters#gitcommit#gitlint#Handle(buffer, lines) abort
for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:code = l:match[2]
+ if l:code is# 'T2' && !ale#Var(a:buffer, 'warn_about_trailing_whitespace')
+ continue
+ endif
+
let l:item = {
\ 'lnum': l:match[1] + 0,
\ 'text': l:match[3],
diff --git a/test/handler/test_gitlint_handler.vader b/test/handler/test_gitlint_handler.vader
index 73ee988f..60d632a0 100644
--- a/test/handler/test_gitlint_handler.vader
+++ b/test/handler/test_gitlint_handler.vader
@@ -1,8 +1,16 @@
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:
- 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):
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"'
\ ])
+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',
+ \ ])