From 3bb4d1d9192d363b8aa73429ecde50fbe11ca67a Mon Sep 17 00:00:00 2001 From: Grigoris Pavlakis <grigpavl@ece.auth.gr> Date: Sat, 23 Mar 2019 15:59:54 +0200 Subject: [PATCH] Remove an unnecessary statement Test commit for Python version --- ci/cppcheck-misra.sh | 1 + ci/summarizer.py | 26 ++++++++++++-------------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/ci/cppcheck-misra.sh b/ci/cppcheck-misra.sh index 529f96ae..b4cadcc7 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 8da54c59..b2a6e8fc 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): -- GitLab