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

Method globalSuppressions

test/testsuppressions.cpp:1392–1406  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1390 }
1391
1392 void globalSuppressions() { // Testing that Cppcheck::useGlobalSuppressions works (#8515)
1393 const auto settings = dinit(Settings,
1394 $.quiet = true,
1395 $.exitCode = 1,
1396 $.templateFormat = templateFormat);
1397
1398 Suppressions supprs;
1399 ASSERT_EQUALS("", supprs.nomsg.addSuppressionLine("uninitvar"));
1400
1401 CppCheck cppCheck(settings, supprs, *this, nullptr, false, nullptr); // <- do not "use global suppressions". pretend this is a thread that just checks a file.
1402
1403 const char code[] = "int f() { int a; return a; }";
1404 ASSERT_EQUALS(0, cppCheck.checkBuffer(FileWithDetails("test.c", Standards::Language::C, 0),code, sizeof(code))); // <- no unsuppressed error is seen
1405 ASSERT_EQUALS("[test.c:1:25]: (error) Uninitialized variable: a [uninitvar]\n", errout_str()); // <- report error so ThreadExecutor can suppress it and make sure the global suppression is matched.
1406 }
1407
1408 void inlinesuppress_unusedFunction() const { // #4210, #4946 - wrong report of "unmatchedSuppression" for "unusedFunction"
1409 SuppressionList suppressions;

Callers

nothing calls this directly

Calls 3

addSuppressionLineMethod · 0.80
checkBufferMethod · 0.80
FileWithDetailsClass · 0.50

Tested by

no test coverage detected