summaryrefslogtreecommitdiff
path: root/test/handler/test_flawfinder_handler.vader
blob: 01dd1698d365ddc666a5a1312b9b16172800f1ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Before:
  Save b:ale_c_flawfinder_error_severity
  runtime ale_linters/c/flawfinder.vim

After:
  Restore
  call ale#linter#Reset()

Execute(The Flawfinder handler should work):
  AssertEqual
  \ [
    \   {
  \     'lnum': 31,
  \     'col': 4,
  \     'type': 'W',
  \     'text': "(buffer) strncpy: Easily used incorrectly",
  \   },
  \ ],
  \ ale#handlers#flawfinder#HandleFlawfinderFormat(347, [
  \   '<stdin>:31:4:  [1] (buffer) strncpy:Easily used incorrectly',
  \   'foo',
  \   'bar',
  \   'baz',
  \ ])

Execute(The Flawfinder error severity level should be configurable):
  let b:ale_c_flawfinder_error_severity = 2

  AssertEqual
  \ [
  \   {
  \     'lnum': 12,
  \     'col': 4,
  \     'type': 'E',
  \     'text': "(buffer) char: Statically-sized arrays can be bad",
  \   },
  \   {
  \     'lnum': 31,
  \     'col': 4,
  \     'type': 'W',
  \     'text': "(buffer) strncpy: Easily used incorrectly",
  \   },
  \ ],
  \ ale#handlers#flawfinder#HandleFlawfinderFormat(bufnr(''), [
  \   '<stdin>:12:4:  [2] (buffer) char:Statically-sized arrays can be bad',
  \   '<stdin>:31:4:  [1] (buffer) strncpy:Easily used incorrectly',
  \ ])