Cppcheck buffered file only (#3983)

* Add cppcheck handler match on misra msg

* Use --file-filter cppcheck option

Cppcheck recently added --file-filter so that cppcheck only checks the
filtered files, even when using --project option, which checks all files
in the project, by default. The --ccpcheck-build-dir option didn't help
enough (at all?).

* Added C test cases

Also fixed and assumed typo: foo.c, instead of foo.cpp

* Replace hard-coded full path filenames

Attempt to fix the windows platform test execution.

* Fix typo - foo.c, instead of foo.cpp

* Reset buffer var between tests

* Handle header files in cppcheck

Cppcheck isn't designed to check header files, stand-alone. Daniel
Marjamäki suggested using --suppress options to avoid FPs.

* Fix Vint complaint in cppcheck handler.

* Fix file path in cppcheck handler

Co-authored-by: Dan George <dgeorge@anduril.com>
This commit is contained in:
Dan George
2021-11-17 20:27:23 -08:00
committed by GitHub
parent 3ca66e44bd
commit aee0cc45be
3 changed files with 47 additions and 3 deletions

View File

@@ -28,6 +28,7 @@ Execute(cppcheck for C++ should detect compile_commands.json files):
\ . ' -q --language=c++'
\ . ' --template=' . ale#Escape('{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}')
\ . ' --project=' . ale#Escape('compile_commands.json')
\ . ' --file-filter=' . ale#Escape('foo.cpp')
\ . ' --enable=style %t'
Execute(cppcheck for C++ should detect compile_commands.json files in build directories):
@@ -38,6 +39,7 @@ Execute(cppcheck for C++ should detect compile_commands.json files in build dire
\ . ' -q --language=c++'
\ . ' --template=' . ale#Escape('{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}')
\ . ' --project=' . ale#Escape(ale#path#Simplify('build/compile_commands.json'))
\ . ' --file-filter=' . ale#Escape('foo.cpp')
\ . ' --enable=style %t'
Execute(cppcheck for C++ should include file dir if compile_commands.json file is not found):
@@ -51,6 +53,18 @@ Execute(cppcheck for C++ should include file dir if compile_commands.json file i
\ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/cppcheck'))
\ . ' %t'
Execute(cppcheck for C++ header should include file dir and not use compile_commands.json):
call ale#test#SetFilename('../test-files/cppcheck/one/foo.hpp')
AssertLinter 'cppcheck',
\ ale#Escape('cppcheck')
\ . ' -q --language=c++'
\ . ' --template=' . ale#Escape('{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}')
\ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/cppcheck/one'))
\ . ' --suppress=unusedStructMember'
\ . ' --enable=style'
\ . ' %t'
Execute(cppcheck for C++ should ignore compile_commands.json file if buffer is modified):
call ale#test#SetFilename('../test-files/cppcheck/one/foo.cpp')