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

Method isSuppressed

lib/suppressions.cpp:409–454  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

407}
408
409SuppressionList::Suppression::Result SuppressionList::Suppression::isSuppressed(const SuppressionList::ErrorMessage &errmsg) const
410{
411 if (type == SuppressionList::Type::macro) {
412 if (errmsg.macroNames.count(macroName) == 0)
413 return Result::None;
414 if (hash > 0 && hash != errmsg.hash)
415 return Result::Checked;
416 if (!errorId.empty() && !matchglob(errorId, errmsg.errorId))
417 return Result::Checked;
418 } else {
419 if ((SuppressionList::Type::unique == type) && (lineNumber != NO_LINE) && (lineNumber != errmsg.lineNumber)) {
420 if (!thisAndNextLine || lineNumber + 1 != errmsg.lineNumber)
421 return Result::None;
422 }
423 if (!fileName.empty() && !PathMatch::match(fileName, errmsg.getFileName()))
424 return Result::None;
425 if (hash > 0 && hash != errmsg.hash)
426 return Result::Checked;
427 // the empty check is a hack to allow wildcard suppressions on IDs to be marked as checked
428 if (!errorId.empty() && (errmsg.errorId.empty() || !matchglob(errorId, errmsg.errorId)))
429 return Result::Checked;
430 if ((SuppressionList::Type::block == type) && ((errmsg.lineNumber < lineBegin) || (errmsg.lineNumber > lineEnd)))
431 return Result::Checked;
432 }
433 if (!symbolName.empty()) {
434 bool matchedSymbol = false;
435 for (std::string::size_type pos = 0; pos < errmsg.symbolNames.size();) {
436 const std::string::size_type pos2 = errmsg.symbolNames.find('\n',pos);
437 std::string symname;
438 if (pos2 == std::string::npos) {
439 symname = errmsg.symbolNames.substr(pos);
440 pos = pos2;
441 } else {
442 symname = errmsg.symbolNames.substr(pos,pos2-pos);
443 pos = pos2+1;
444 }
445 if (matchglob(symbolName, symname)) {
446 matchedSymbol = true;
447 break;
448 }
449 }
450 if (!matchedSymbol)
451 return Result::Checked;
452 }
453 return Result::Matched;
454}
455
456bool SuppressionList::Suppression::isMatch(const SuppressionList::ErrorMessage &errmsg)
457{

Callers 2

reportErrMethod · 0.45
checkMethod · 0.45

Calls 6

matchglobFunction · 0.85
matchFunction · 0.70
emptyMethod · 0.45
sizeMethod · 0.45
findMethod · 0.45
isMatchMethod · 0.45

Tested by

no test coverage detected