From 23a9a300f20252ec84eab404ce233f91e7183aae Mon Sep 17 00:00:00 2001 From: ROpdebee Date: Sat, 26 Jan 2019 06:27:58 +0100 Subject: [PATCH] Parse output messages using custom format Allows for more control and fixes issues with outputs not recognized by the regex --- linter.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/linter.py b/linter.py index 98c3840..b3c7ac9 100644 --- a/linter.py +++ b/linter.py @@ -2,14 +2,13 @@ class Bandit(PythonLinter): - cmd = ('bandit', '${args}', '-n', '1', '-f', 'txt', '-') - regex = ( - r'^>>\sIssue:\s\[(?P[B]\d+):.+\]\s(?P.+)$\r?\n' - r'^.*Severity:\s(?:(?PHigh)|(?P(Medium|Low))).*$\r?\n' - r'^.*Location:.*:(?P\d+)$\r?\n' - ) - multiline = True - error_stream = util.STREAM_BOTH + cmd = ('bandit', '${args}', '-n', '1', '-f', 'custom', + '--msg-template', '[{line}][{test_id}][{severity}] {msg}', '-') + regex = (r'^\[(?P\d+)\]' + r'\[(?P[B]\d+)\]' + r'\[(?:(?PHIGH)|(?P(MEDIUM|LOW)))\]' + r'\s(?P.+)$') + error_stream = util.STREAM_STDOUT defaults = { 'selector': 'source.python', '--tests,': '',