@@ -1059,6 +1059,8 @@ def __init__(self, settings, stdversion="c90"):
10591059
10601060 self .severity = None
10611061
1062+ self .existing_violations = set ()
1063+
10621064 def __repr__ (self ):
10631065 attrs = ["settings" , "verify_expected" , "verify_actual" , "violations" ,
10641066 "ruleTexts" , "suppressedRules" , "dumpfileSuppressions" ,
@@ -2726,11 +2728,17 @@ def reportError(self, location, num1, num2):
27262728 if self .severity :
27272729 cppcheck_severity = self .severity
27282730
2729- cppcheckdata .reportError (location , cppcheck_severity , errmsg , 'misra' , errorId , misra_severity )
2731+ this_violation = '{}-{}-{}-{}' .format (location .file , location .linenr , location .column , ruleNum )
2732+
2733+ # If this is new violation then record it and show it. If not then
2734+ # skip it since it has already been displayed.
2735+ if not this_violation in self .existing_violations :
2736+ self .existing_violations .add (this_violation )
2737+ cppcheckdata .reportError (location , cppcheck_severity , errmsg , 'misra' , errorId , misra_severity )
27302738
2731- if misra_severity not in self .violations :
2732- self .violations [misra_severity ] = []
2733- self .violations [misra_severity ].append ('misra-' + errorId )
2739+ if misra_severity not in self .violations :
2740+ self .violations [misra_severity ] = []
2741+ self .violations [misra_severity ].append ('misra-' + errorId )
27342742
27352743 def loadRuleTexts (self , filename ):
27362744 num1 = 0
0 commit comments