Skip to content

Commit 9ce83c2

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 9ce83c2

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

linter.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,9 @@
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', '--msg-template', '[{line}][{test_id}][{severity}] {msg}', '-')
6+
regex = r'^\[(?P<line>\d+)\]\[(?P<code>[B]\d+)\]\[(?:(?P<error>HIGH)|(?P<warning>(MEDIUM|LOW)))\]\s(?P<message>.+)$'
7+
error_stream = util.STREAM_STDOUT
138
defaults = {
149
'selector': 'source.python',
1510
'--tests,': '',

0 commit comments

Comments
 (0)