diff --git a/ci/cppcheck-misra.sh b/ci/cppcheck-misra.sh index 529f96aee9be670dcce09b11b086dcc853ee7513..b4cadcc79c540651c3c4ed6f83c9c8bec740c10a 100755 --- a/ci/cppcheck-misra.sh +++ b/ci/cppcheck-misra.sh @@ -26,4 +26,5 @@ sed -i -r 's/(.*Script.*)|(.*Checking.*)|(.*MISRA.*)//gm; /(^$)/d; s/(\s\(.*\)\s # run the summarizer for a nice, clean summary of errors echo -e "\u001b[34;1mSummarizing results...\u001b[0m" +python3 --version python3 ci/summarizer.py ci/report.msr diff --git a/ci/summarizer.py b/ci/summarizer.py index 8da54c59d0df89ebda9864f48c6e3cae0b100225..b2a6e8fc0c672a7d219d5993ee766f783800f11c 100755 --- a/ci/summarizer.py +++ b/ci/summarizer.py @@ -1,7 +1,6 @@ #!/bin/env python3 from sys import argv -from sys import exit from collections import Counter """ @@ -33,22 +32,21 @@ class Summarizer(object): if len(self.file_lines) == 0: print(bold + green + "Static analysis for MISRA compliance complete. No errors found." + end) return 0 - else: - for line in self.file_lines: # remove duplicate lines - if line not in lines_seen: - lines_seen.add(line) + for line in self.file_lines: # remove duplicate lines + if line not in lines_seen: + lines_seen.add(line) - line_contents = line.split(':') - file_name = line_contents[0] # first part is the filename (index 0) - error = (line_contents[1], line_contents[2].strip('\n')) # index 1 is the line number, index 2 is the number of violated rule + line_contents = line.split(':') + file_name = line_contents[0] # first part is the filename (index 0) + error = (line_contents[1], line_contents[2].strip('\n')) # index 1 is the line number, index 2 is the number of violated rule - if file_name not in errors_map.keys(): - errors_map[file_name] = list() # create a new list for the new filename and append the tuple in it - errors_map[file_name].append(error) - else: - errors_map[file_name].append(error) # do not append if it already exists + if file_name not in errors_map.keys(): + errors_map[file_name] = list() # create a new list for the new filename and append the tuple in it + errors_map[file_name].append(error) + else: + errors_map[file_name].append(error) # do not append if it already exists - return errors_map # return the completed error dictionary + return errors_map # return the completed error dictionary def pretty_print(self, errors):