Skip to content

Commit 23a9a30

Browse files
committed
Parse output messages using custom format
Allows for more control and fixes issues with outputs not recognized by the regex
1 parent a0359c9 commit 23a9a30

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

linter.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22

33

44
class Bandit(PythonLinter):
5-
cmd = ('bandit', '${args}', '-n', '1', '-f', 'txt', '-')
6-
regex = (
7-
r'^>>\sIssue:\s\[(?P<code>[B]\d+):.+\]\s(?P<message>.+)$\r?\n'
8-
r'^.*Severity:\s(?:(?P<error>High)|(?P<warning>(Medium|Low))).*$\r?\n'
9-
r'^.*Location:.*:(?P<line>\d+)$\r?\n'
10-
)
11-
multiline = True
12-
error_stream = util.STREAM_BOTH
5+
cmd = ('bandit', '${args}', '-n', '1', '-f', 'custom',
6+
'--msg-template', '[{line}][{test_id}][{severity}] {msg}', '-')
7+
regex = (r'^\[(?P<line>\d+)\]'
8+
r'\[(?P<code>[B]\d+)\]'
9+
r'\[(?:(?P<error>HIGH)|(?P<warning>(MEDIUM|LOW)))\]'
10+
r'\s(?P<message>.+)$')
11+
error_stream = util.STREAM_STDOUT
1312
defaults = {
1413
'selector': 'source.python',
1514
'--tests,': '',

0 commit comments

Comments
 (0)