2017-06-22 13:08:58 +00:00
|
|
|
Before:
|
2017-07-09 21:43:25 +00:00
|
|
|
call ale#test#SetDirectory('/testplugin/test/handler')
|
2017-06-22 13:08:58 +00:00
|
|
|
|
|
|
|
After:
|
2017-07-09 21:43:25 +00:00
|
|
|
call ale#test#RestoreDirectory()
|
2017-06-22 13:08:58 +00:00
|
|
|
|
|
|
|
Execute(Basic errors should be handled by cppcheck):
|
|
|
|
call ale#test#SetFilename('test.cpp')
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ {
|
2020-08-06 19:50:44 +00:00
|
|
|
\ 'lnum': 974,
|
|
|
|
\ 'col' : 6,
|
2017-06-22 13:08:58 +00:00
|
|
|
\ 'type': 'E',
|
2020-08-06 19:50:44 +00:00
|
|
|
\ 'sub_type': '',
|
|
|
|
\ 'text': 'Array ''n[3]'' accessed at index 3, which is out of bounds.',
|
|
|
|
\ 'code': 'arrayIndexOutOfBounds'
|
2017-06-22 13:08:58 +00:00
|
|
|
\ },
|
|
|
|
\ {
|
2020-08-06 19:50:44 +00:00
|
|
|
\ 'lnum': 1185,
|
|
|
|
\ 'col' : 10,
|
2017-06-22 13:08:58 +00:00
|
|
|
\ 'type': 'W',
|
2020-08-06 19:50:44 +00:00
|
|
|
\ 'sub_type': 'style',
|
|
|
|
\ 'text': 'The scope of the variable ''indxStr'' can be reduced.',
|
|
|
|
\ 'code': 'variableScope'
|
2017-06-22 13:08:58 +00:00
|
|
|
\ },
|
|
|
|
\ ],
|
|
|
|
\ ale#handlers#cppcheck#HandleCppCheckFormat(bufnr(''), [
|
2020-08-06 19:50:44 +00:00
|
|
|
\ 'test.cpp:974:6: error: Array ''n[3]'' accessed at index 3, which is out of bounds. [arrayIndexOutOfBounds]\',
|
|
|
|
\ ' n[3]=3;',
|
|
|
|
\ ' ^',
|
|
|
|
\ 'test.cpp:1185:10: style: The scope of the variable ''indxStr'' can be reduced. [variableScope]\',
|
|
|
|
\ ' char indxStr[16];',
|
|
|
|
\ ' ^',
|
2017-06-22 13:08:58 +00:00
|
|
|
\ ])
|
|
|
|
|
2021-09-03 13:31:17 +00:00
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ {
|
|
|
|
\ 'lnum': 974,
|
|
|
|
\ 'col' : 1,
|
|
|
|
\ 'type': 'E',
|
|
|
|
\ 'sub_type': '',
|
|
|
|
\ 'text': 'inconclusive Array ''n[3]'' accessed at index 3, which is out of bounds.',
|
|
|
|
\ 'code': 'arrayIndexOutOfBounds'
|
|
|
|
\ },
|
|
|
|
\ {
|
|
|
|
\ 'lnum': 1185,
|
|
|
|
\ 'col' : 1,
|
|
|
|
\ 'type': 'W',
|
|
|
|
\ 'sub_type': 'style',
|
|
|
|
\ 'text': 'The scope of the variable ''indxStr'' can be reduced.',
|
|
|
|
\ 'code': 'variableScope'
|
|
|
|
\ },
|
|
|
|
\ ],
|
|
|
|
\ ale#handlers#cppcheck#HandleCppCheckFormat(bufnr(''), [
|
|
|
|
\ 'test.cpp:974:{column}: error:inconclusive Array ''n[3]'' accessed at index 3, which is out of bounds. [arrayIndexOutOfBounds]\',
|
|
|
|
\ ' n[3]=3;',
|
|
|
|
\ ' ^',
|
|
|
|
\ 'test.cpp:1185:{column}: style:{inconclusive:inconclusive} The scope of the variable ''indxStr'' can be reduced. [variableScope]\',
|
|
|
|
\ ' char indxStr[16];',
|
|
|
|
\ ' ^',
|
|
|
|
\ ])
|
|
|
|
|
2021-11-15 11:34:46 +00:00
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ {
|
|
|
|
\ 'lnum': 1,
|
|
|
|
\ 'col' : 16,
|
|
|
|
\ 'type': 'W',
|
|
|
|
\ 'sub_type': 'style',
|
|
|
|
\ 'text': 'misra violation (use --rule-texts=<file> to get proper output)',
|
|
|
|
\ 'code': 'misra-c2012-2.7'
|
|
|
|
\ },
|
|
|
|
\ ],
|
|
|
|
\ ale#handlers#cppcheck#HandleCppCheckFormat(bufnr(''), [
|
|
|
|
\ 'test.cpp:1:16: style: misra violation (use --rule-texts=<file> to get proper output) [misra-c2012-2.7]\',
|
|
|
|
\ 'void test( int parm ) {}',
|
|
|
|
\ ' ^',
|
|
|
|
\ ])
|
|
|
|
|
2017-06-22 13:08:58 +00:00
|
|
|
Execute(Problems from other files should be ignored by cppcheck):
|
|
|
|
call ale#test#SetFilename('test.cpp')
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ ],
|
|
|
|
\ ale#handlers#cppcheck#HandleCppCheckFormat(bufnr(''), [
|
2020-08-06 19:50:44 +00:00
|
|
|
\ 'bar.cpp:974:6: error: Array ''n[3]'' accessed at index 3, which is out of bounds. [arrayIndexOutOfBounds]\',
|
|
|
|
\ ' n[3]=3;',
|
|
|
|
\ ' ^',
|
2017-06-22 13:08:58 +00:00
|
|
|
\ ])
|