Merge pull request #2713 from whoopsmith/no_duplicate_misra_violtions

misra.py: Squelch duplicate violation messages
This commit is contained in:
Daniel Marjamäki 2020-07-20 08:00:01 +02:00 committed by GitHub
commit b812d48397
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 4 deletions

View File

@ -1059,6 +1059,8 @@ class MisraChecker:
self.severity = None self.severity = None
self.existing_violations = set()
def __repr__(self): def __repr__(self):
attrs = ["settings", "verify_expected", "verify_actual", "violations", attrs = ["settings", "verify_expected", "verify_actual", "violations",
"ruleTexts", "suppressedRules", "dumpfileSuppressions", "ruleTexts", "suppressedRules", "dumpfileSuppressions",
@ -2726,6 +2728,12 @@ class MisraChecker:
if self.severity: if self.severity:
cppcheck_severity = self.severity cppcheck_severity = self.severity
this_violation = '{}-{}-{}-{}'.format(location.file, location.linenr, location.column, ruleNum)
# If this is new violation then record it and show it. If not then
# skip it since it has already been displayed.
if not this_violation in self.existing_violations:
self.existing_violations.add(this_violation)
cppcheckdata.reportError(location, cppcheck_severity, errmsg, 'misra', errorId, misra_severity) cppcheckdata.reportError(location, cppcheck_severity, errmsg, 'misra', errorId, misra_severity)
if misra_severity not in self.violations: if misra_severity not in self.violations: