@@ -946,29 +946,60 @@ class Suppression:
946946 fileName The name of the file to suppress warnings for, can include wildcards
947947 lineNumber The number of the line to suppress warnings from, can be 0 to represent any line
948948 symbolName The name of the symbol to match warnings for, can include wildcards
949+ lineBegin The first line to suppress warnings from
950+ lineEnd The last line to suppress warnings from
951+ suppressionType The type of suppression which is applied (unique = None (default), file, block, blockBegin, blockEnd, macro)
949952 """
950953
951954 errorId = None
952955 fileName = None
953956 lineNumber = None
954957 symbolName = None
958+ lineBegin = None
959+ lineEnd = None
960+ suppressionType = None
955961
956962 def __init__ (self , element ):
957963 self .errorId = element .get ('errorId' )
958964 self .fileName = element .get ('fileName' )
959965 self .lineNumber = element .get ('lineNumber' )
960966 self .symbolName = element .get ('symbolName' )
967+ self .lineBegin = element .get ('lineBegin' )
968+ self .lineEnd = element .get ('lineEnd' )
969+ self .suppressionType = element .get ('type' )
961970
962971 def __repr__ (self ):
963- attrs = [' errorId' , "fileName" , "lineNumber" , "symbolName" ]
972+ attrs = [" errorId" , "fileName" , "lineNumber" , "symbolName" , "lineBegin" , "lineEnd" , "suppressionType " ]
964973 return "{}({})" .format (
965974 "Suppression" ,
966975 ", " .join (("{}={}" .format (a , repr (getattr (self , a ))) for a in attrs ))
967976 )
968977
969978 def isMatch (self , file , line , message , errorId ):
979+ # Line Suppression
970980 if ((self .fileName is None or fnmatch (file , self .fileName ))
971- and (self .lineNumber is None or int (line ) == int (self .lineNumber ))
981+ and (self .suppressionType == None ) # Verify use of default suppression type (None = unique)
982+ and (self .lineNumber != None and int (line ) == int (self .lineNumber ))
983+ and (self .symbolName is None or fnmatch (message , '*' + self .symbolName + '*' ))
984+ and fnmatch (errorId , self .errorId )):
985+ return True
986+ # File Suppression
987+ if ((self .fileName is None or fnmatch (file , self .fileName ))
988+ and (self .suppressionType != None and self .suppressionType == "file" ) # Verify use of file (global) suppression type
989+ and (self .symbolName is None or fnmatch (message , '*' + self .symbolName + '*' ))
990+ and fnmatch (errorId , self .errorId )):
991+ return True
992+ # Block Suppression Mode
993+ if ((self .fileName is None or fnmatch (file , self .fileName ))
994+ and (self .suppressionType != None and self .suppressionType == "block" ) # Type for Block suppression
995+ and (self .lineBegin != None and int (line ) > int (self .lineBegin )) # Code Match is between the Block suppression
996+ and (self .lineEnd != None and int (line ) < int (self .lineEnd )) # Code Match is between the Block suppression
997+ and (self .symbolName is None or fnmatch (message , '*' + self .symbolName + '*' ))
998+ and fnmatch (errorId , self .errorId )):
999+ return True
1000+ # Other Suppression (Globaly set via suppression file or cli command)
1001+ if ((self .fileName is None or fnmatch (file , self .fileName ))
1002+ and (self .suppressionType is None )
9721003 and (self .symbolName is None or fnmatch (message , '*' + self .symbolName + '*' ))
9731004 and fnmatch (errorId , self .errorId )):
9741005 return True
0 commit comments