Merge pull request #6177 from maxvisser/patch-1
Update shellcheck junit integration for newer version of shellcheck
This commit is contained in:
1 file changed
+20
-3
@@ -45,11 +45,17 @@ def process_lines(lines):
|
|||||||
new_issues = []
|
new_issues = []
|
||||||
code = None
|
code = None
|
||||||
|
|
||||||
RE_VIOLATION = re.compile(r"\^-- (SC[\w]+): (.*)")
|
RE_VIOLATION = re.compile(r"\^(-)+(\^)? (SC[\w]+) \((\w+)\): (.*)")
|
||||||
|
HTTP_VIOLATION = re.compile(r"^https?://")
|
||||||
|
line_num = 0
|
||||||
|
skip_next_line = False
|
||||||
|
|
||||||
for line in lines:
|
for line in lines:
|
||||||
# start a new block
|
# start a new block
|
||||||
if line == '':
|
if skip_next_line:
|
||||||
|
skip_next_line = False
|
||||||
|
continue
|
||||||
|
elif line == '':
|
||||||
if current_file is not None:
|
if current_file is not None:
|
||||||
file_data = files.get(current_file, {})
|
file_data = files.get(current_file, {})
|
||||||
files[current_file] = file_data
|
files[current_file] = file_data
|
||||||
@@ -74,11 +80,19 @@ def process_lines(lines):
|
|||||||
code = None
|
code = None
|
||||||
elif code is None and len(new_issues) == 0:
|
elif code is None and len(new_issues) == 0:
|
||||||
code = line
|
code = line
|
||||||
|
elif line.startswith('Did you mean:') or line.startswith('For more information:') or HTTP_VIOLATION.match(line.strip()):
|
||||||
|
skip_next_line = True
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
match = RE_VIOLATION.match(line.strip())
|
match = RE_VIOLATION.match(line.strip())
|
||||||
if not match:
|
if not match:
|
||||||
print('Error: Issue parsing line "{0}"'.format(line.strip()))
|
print('Error: Issue parsing line "{0}"'.format(line.strip()))
|
||||||
else:
|
else:
|
||||||
|
next_line_num = line_num + 2
|
||||||
|
if next_line_num < len(lines):
|
||||||
|
next_line = lines[next_line_num]
|
||||||
|
if next_line.startswith('Did you mean:'):
|
||||||
|
line += '\n' + lines[next_line_num] + '\n' + lines[next_line_num+1]
|
||||||
new_issues.append({
|
new_issues.append({
|
||||||
'shellcheck_id': match.group(1),
|
'shellcheck_id': match.group(1),
|
||||||
'message': match.group(2),
|
'message': match.group(2),
|
||||||
@@ -86,7 +100,7 @@ def process_lines(lines):
|
|||||||
})
|
})
|
||||||
|
|
||||||
previous_line = line
|
previous_line = line
|
||||||
|
line_num += 1
|
||||||
return files
|
return files
|
||||||
|
|
||||||
|
|
||||||
@@ -104,6 +118,9 @@ def output_junit(files, args):
|
|||||||
with open(args.files, 'r') as f:
|
with open(args.files, 'r') as f:
|
||||||
tests = len(f.readlines())
|
tests = len(f.readlines())
|
||||||
|
|
||||||
|
if tests < failures:
|
||||||
|
tests = failures
|
||||||
|
|
||||||
root = ElementTree.Element("testsuite",
|
root = ElementTree.Element("testsuite",
|
||||||
name="shellcheck",
|
name="shellcheck",
|
||||||
tests="{0}".format(tests),
|
tests="{0}".format(tests),
|
||||||
|
|||||||
Reference in new issue
Block a user