From 8f80708da6192ccc2914668ff776916c98cb4e82 Mon Sep 17 00:00:00 2001 From: w0rp Date: Wed, 15 Nov 2017 11:28:16 +0000 Subject: [PATCH] #852 - Capture error codes for cpplint --- autoload/ale/handlers/cpplint.vim | 5 +++-- test/handler/test_cpplint_handler.vader | 14 ++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/autoload/ale/handlers/cpplint.vim b/autoload/ale/handlers/cpplint.vim index 4607863..5c475a5 100644 --- a/autoload/ale/handlers/cpplint.vim +++ b/autoload/ale/handlers/cpplint.vim @@ -4,14 +4,15 @@ function! ale#handlers#cpplint#HandleCppLintFormat(buffer, lines) abort " Look for lines like the following. " test.cpp:5: Estra space after ( in function call [whitespace/parents] [4] - let l:pattern = '^.\{-}:\(\d\+\): \(.\+\)' + let l:pattern = '^.\{-}:\(\d\+\): *\(.\+\) *\[\(.*/.*\)\] ' let l:output = [] for l:match in ale#util#GetMatches(a:lines, l:pattern) call add(l:output, { \ 'lnum': l:match[1] + 0, \ 'col': 0, - \ 'text': l:match[2], + \ 'text': join(split(l:match[2])), + \ 'code': l:match[3], \ 'type': 'W', \}) endfor diff --git a/test/handler/test_cpplint_handler.vader b/test/handler/test_cpplint_handler.vader index 6df84cc..d8d7b8b 100644 --- a/test/handler/test_cpplint_handler.vader +++ b/test/handler/test_cpplint_handler.vader @@ -1,6 +1,9 @@ Before: runtime ale_linters/cpp/cpplint.vim +After: + call ale#linter#Reset() + Execute(cpplint warnings from included files should be parsed correctly): AssertEqual @@ -8,20 +11,19 @@ Execute(cpplint warnings from included files should be parsed correctly): \ { \ 'lnum': 5, \ 'col': 0, - \ 'text': ' Estra space after ( in function call [whitespace/parents] [4]', + \ 'text': 'Extra space after ( in function call', + \ 'code': 'whitespace/parents', \ 'type': 'W', \ }, \ { \ 'lnum': 120, \ 'col': 0, - \ 'text': ' At least two spaces is best between code and comments [whitespace/comments] [2]', + \ 'text': 'At least two spaces is best between code and comments', + \ 'code': 'whitespace/comments', \ 'type': 'W', \ }, \ ], \ ale#handlers#cpplint#HandleCppLintFormat(347, [ - \ 'test.cpp:5: Estra space after ( in function call [whitespace/parents] [4]', + \ 'test.cpp:5: Extra space after ( in function call [whitespace/parents] [4]', \ 'keymap_keys.hpp:120: At least two spaces is best between code and comments [whitespace/comments] [2]', \ ]) - -After: - call ale#linter#Reset()