MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / Suppression

Class Suppression

addons/cppcheckdata.py:945–1012  ·  view source on GitHub ↗

Suppression class This class contains a suppression entry to suppress a warning. Attributes errorId The id string of the error to suppress, can be a wildcard fileName The name of the file to suppress warnings for, can include wildcards lineNumber The number of

Source from the content-addressed store, hash-verified

943
944
945class Suppression:
946 """
947 Suppression class
948 This class contains a suppression entry to suppress a warning.
949
950 Attributes
951 errorId The id string of the error to suppress, can be a wildcard
952 fileName The name of the file to suppress warnings for, can include wildcards
953 lineNumber The number of the line to suppress warnings from, can be 0 to represent any line
954 symbolName The name of the symbol to match warnings for, can include wildcards
955 lineBegin The first line to suppress warnings from
956 lineEnd The last line to suppress warnings from
957 suppressionType The type of suppression which is applied (unique = None (default), file, block, blockBegin, blockEnd, macro)
958 """
959
960 errorId = None
961 fileName = None
962 lineNumber = None
963 symbolName = None
964 lineBegin = None
965 lineEnd = None
966 suppressionType = None
967
968 def __init__(self, element):
969 self.errorId = element.get('errorId')
970 self.fileName = element.get('fileName')
971 self.lineNumber = element.get('lineNumber')
972 self.symbolName = element.get('symbolName')
973 self.lineBegin = element.get('lineBegin')
974 self.lineEnd = element.get('lineEnd')
975 self.suppressionType = element.get('type')
976
977 def __repr__(self):
978 attrs = ["errorId", "fileName", "lineNumber", "symbolName", "lineBegin", "lineEnd","suppressionType"]
979 return "{}({})".format(
980 "Suppression",
981 ", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs))
982 )
983
984 def isMatch(self, file, line, message, errorId):
985 # Line Suppression
986 if ((self.fileName is None or fnmatch(file, self.fileName))
987 and (self.suppressionType is None) # Verify use of default suppression type (None = unique)
988 and (self.lineNumber is not None and int(line) == int(self.lineNumber))
989 and (self.symbolName is None or fnmatch(message, '*'+self.symbolName+'*'))
990 and fnmatch(errorId, self.errorId)):
991 return True
992 # File Suppression
993 if ((self.fileName is None or fnmatch(file, self.fileName))
994 and (self.suppressionType is not None and self.suppressionType == "file") # Verify use of file (global) suppression type
995 and (self.symbolName is None or fnmatch(message, '*'+self.symbolName+'*'))
996 and fnmatch(errorId, self.errorId)):
997 return True
998 # Block Suppression Mode
999 if ((self.fileName is None or fnmatch(file, self.fileName))
1000 and (self.suppressionType is not None and self.suppressionType == "block") # Type for Block suppression
1001 and (self.lineBegin is not None and int(line) > int(self.lineBegin)) # Code Match is between the Block suppression
1002 and (self.lineEnd is not None and int(line) < int(self.lineEnd)) # Code Match is between the Block suppression

Callers 1

__init__Method · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected