From 15b9d85f162d0da226ff7a7d436af7239ad5d6c3 Mon Sep 17 00:00:00 2001 From: Dan George Date: Sat, 13 Nov 2021 15:21:07 -0800 Subject: [PATCH 1/2] Add cppcheck handler match on misra msg --- autoload/ale/handlers/cppcheck.vim | 7 ++++++- test/handler/test_cppcheck_handler.vader | 17 +++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/autoload/ale/handlers/cppcheck.vim b/autoload/ale/handlers/cppcheck.vim index a07d0aed9a..bb8c86027b 100644 --- a/autoload/ale/handlers/cppcheck.vim +++ b/autoload/ale/handlers/cppcheck.vim @@ -50,7 +50,12 @@ function! ale#handlers#cppcheck#HandleCppCheckFormat(buffer, lines) abort "test.cpp:974:{column}: error:{inconclusive:inconclusive} Array 'n[3]' accessed at index 3, which is out of bounds. [arrayIndexOutOfBounds]\ " n[3]=3; " ^ - let l:pattern = '\v(\f+):(\d+):(\d+|\{column\}): (\w+):(\{inconclusive:inconclusive\})? ?(.*) \[(\w+)\]\' + " + "" OR if using the misra addon: + "test.c:1:16: style: misra violation (use --rule-texts= to get proper output) [misra-c2012-2.7]\' + "void test( int parm ) {} + " ^ + let l:pattern = '\v(\f+):(\d+):(\d+|\{column\}): (\w+):(\{inconclusive:inconclusive\})? ?(.*) \[(%(\w[-.]?)+)\]\' let l:output = [] for l:match in ale#util#GetMatches(a:lines, l:pattern) diff --git a/test/handler/test_cppcheck_handler.vader b/test/handler/test_cppcheck_handler.vader index 2a740722f9..ef161f4485 100644 --- a/test/handler/test_cppcheck_handler.vader +++ b/test/handler/test_cppcheck_handler.vader @@ -63,6 +63,23 @@ Execute(Basic errors should be handled by cppcheck): \ ' ^', \ ]) + AssertEqual + \ [ + \ { + \ 'lnum': 1, + \ 'col' : 16, + \ 'type': 'W', + \ 'sub_type': 'style', + \ 'text': 'misra violation (use --rule-texts= to get proper output)', + \ 'code': 'misra-c2012-2.7' + \ }, + \ ], + \ ale#handlers#cppcheck#HandleCppCheckFormat(bufnr(''), [ + \ 'test.cpp:1:16: style: misra violation (use --rule-texts= to get proper output) [misra-c2012-2.7]\', + \ 'void test( int parm ) {}', + \ ' ^', + \ ]) + Execute(Problems from other files should be ignored by cppcheck): call ale#test#SetFilename('test.cpp') From dee2dad763baebfb6c3a77d799a6ad122fe4ae63 Mon Sep 17 00:00:00 2001 From: Dan George Date: Tue, 16 Nov 2021 14:38:19 -0800 Subject: [PATCH 2/2] Add linebreak to checkmake formatter --- ale_linters/make/checkmake.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ale_linters/make/checkmake.vim b/ale_linters/make/checkmake.vim index 5ebdf91ee7..d5f95d6f25 100644 --- a/ale_linters/make/checkmake.vim +++ b/ale_linters/make/checkmake.vim @@ -20,6 +20,6 @@ endfunction call ale#linter#Define('make', { \ 'name': 'checkmake', \ 'executable': 'checkmake', -\ 'command': 'checkmake %s --format="{{.LineNumber}}:{{.Rule}}:{{.Violation}}"', +\ 'command': 'checkmake %s --format="{{.LineNumber}}:{{.Rule}}:{{.Violation}}{{\"\r\n\"}}"', \ 'callback': 'ale_linters#make#checkmake#Handle', \})