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

Method addSuppressedRule

addons/misra.py:4270–4352  ·  view source on GitHub ↗

Add a suppression to the suppressions data structure Suppressions are stored in a dictionary of dictionaries that contains a list of tuples. The first dictionary is keyed by the MISRA rule in hundreds format. The value of that dictionary is a dictionary of

(self, ruleNum,
                          fileName=None,
                          lineNumber=None,
                          symbolName=None)

Source from the content-addressed store, hash-verified

4268 return self.violations.keys()
4269
4270 def addSuppressedRule(self, ruleNum,
4271 fileName=None,
4272 lineNumber=None,
4273 symbolName=None):
4274 """
4275 Add a suppression to the suppressions data structure
4276
4277 Suppressions are stored in a dictionary of dictionaries that
4278 contains a list of tuples.
4279
4280 The first dictionary is keyed by the MISRA rule in hundreds
4281 format. The value of that dictionary is a dictionary of filenames.
4282 If the value is None then the rule is assumed to be suppressed for
4283 all files.
4284 If the filename exists then the value of that dictionary contains a list
4285 with the scope of the suppression. If the list contains an item of None
4286 then the rule is assumed to be suppressed for the entire file. Otherwise
4287 the list contains line number, symbol name tuples.
4288 For each tuple either line number or symbol name can can be none.
4289
4290 """
4291 normalized_filename = None
4292
4293 if fileName is not None:
4294 normalized_filename = os.path.expanduser(fileName)
4295 normalized_filename = os.path.normpath(normalized_filename)
4296
4297 if lineNumber is not None or symbolName is not None:
4298 line_symbol = (lineNumber, symbolName)
4299 else:
4300 line_symbol = None
4301
4302 # If the rule is not in the dict already then add it
4303 if ruleNum not in self.suppressedRules:
4304 ruleItemList = []
4305 ruleItemList.append(line_symbol)
4306
4307 fileDict = {}
4308 fileDict[normalized_filename] = ruleItemList
4309
4310 self.suppressedRules[ruleNum] = fileDict
4311
4312 # Rule is added. Done.
4313 return
4314
4315 # Rule existed in the dictionary. Check for
4316 # filename entries.
4317
4318 # Get the dictionary for the rule number
4319 fileDict = self.suppressedRules[ruleNum]
4320
4321 # If the filename is not in the dict already add it
4322 if normalized_filename not in fileDict:
4323 ruleItemList = []
4324 ruleItemList.append(line_symbol)
4325
4326 fileDict[normalized_filename] = ruleItemList
4327

Callers 1

setSuppressionListMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected