Skip to content

Commit f08f274

Browse files
committed
pass Suppressions separately into CppCheckExecutor::reportSuppressions() [skip ci]
1 parent a178c86 commit f08f274

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

Diff for: cli/cppcheckexecutor.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,9 @@ int CppCheckExecutor::check_wrapper(CppCheck& cppcheck)
218218
return check_internal(cppcheck);
219219
}
220220

221-
bool CppCheckExecutor::reportSuppressions(const Settings &settings, bool unusedFunctionCheckEnabled, const std::list<std::pair<std::string, std::size_t>> &files, const std::list<FileSettings>& fileSettings, ErrorLogger& errorLogger) {
222-
const auto& suppressions = settings.nomsg.getSuppressions();
223-
if (std::any_of(suppressions.begin(), suppressions.end(), [](const Suppressions::Suppression& s) {
221+
bool CppCheckExecutor::reportSuppressions(const Settings &settings, const Suppressions& suppressions, bool unusedFunctionCheckEnabled, const std::list<std::pair<std::string, std::size_t>> &files, const std::list<FileSettings>& fileSettings, ErrorLogger& errorLogger) {
222+
const auto& suppr = suppressions.getSuppressions();
223+
if (std::any_of(suppr.begin(), suppr.end(), [](const Suppressions::Suppression& s) {
224224
return s.errorId == "unmatchedSuppression" && s.fileName.empty() && s.lineNumber == Suppressions::Suppression::NO_LINE;
225225
}))
226226
return false;
@@ -232,15 +232,15 @@ bool CppCheckExecutor::reportSuppressions(const Settings &settings, bool unusedF
232232

233233
for (std::list<std::pair<std::string, std::size_t>>::const_iterator i = files.cbegin(); i != files.cend(); ++i) {
234234
err |= Suppressions::reportUnmatchedSuppressions(
235-
settings.nomsg.getUnmatchedLocalSuppressions(i->first, unusedFunctionCheckEnabled), errorLogger);
235+
suppressions.getUnmatchedLocalSuppressions(i->first, unusedFunctionCheckEnabled), errorLogger);
236236
}
237237

238238
for (std::list<FileSettings>::const_iterator i = fileSettings.cbegin(); i != fileSettings.cend(); ++i) {
239239
err |= Suppressions::reportUnmatchedSuppressions(
240-
settings.nomsg.getUnmatchedLocalSuppressions(i->filename, unusedFunctionCheckEnabled), errorLogger);
240+
suppressions.getUnmatchedLocalSuppressions(i->filename, unusedFunctionCheckEnabled), errorLogger);
241241
}
242242
}
243-
err |= Suppressions::reportUnmatchedSuppressions(settings.nomsg.getUnmatchedGlobalSuppressions(unusedFunctionCheckEnabled), errorLogger);
243+
err |= Suppressions::reportUnmatchedSuppressions(suppressions.getUnmatchedGlobalSuppressions(unusedFunctionCheckEnabled), errorLogger);
244244
return err;
245245
}
246246

@@ -286,7 +286,7 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck) const
286286
cppcheck.analyseWholeProgram(settings.buildDir, mFiles, mFileSettings);
287287

288288
if (settings.severity.isEnabled(Severity::information) || settings.checkConfiguration) {
289-
const bool err = reportSuppressions(settings, cppcheck.isUnusedFunctionCheckEnabled(), mFiles, mFileSettings, *mStdLogger);
289+
const bool err = reportSuppressions(settings, settings.nomsg, cppcheck.isUnusedFunctionCheckEnabled(), mFiles, mFileSettings, *mStdLogger);
290290
if (err && returnValue == 0)
291291
returnValue = settings.exitCode;
292292
}

Diff for: cli/cppcheckexecutor.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
class CppCheck;
3232
class Settings;
3333
class ErrorLogger;
34+
class Suppressions;
3435

3536
/**
3637
* This class works as an example of how CppCheck can be used in external
@@ -81,7 +82,7 @@ class CppCheckExecutor {
8182

8283
protected:
8384

84-
static bool reportSuppressions(const Settings &settings, bool unusedFunctionCheckEnabled, const std::list<std::pair<std::string, std::size_t>> &files, const std::list<FileSettings>& fileSettings, ErrorLogger& errorLogger);
85+
static bool reportSuppressions(const Settings &settings, const Suppressions& suppressions, bool unusedFunctionCheckEnabled, const std::list<std::pair<std::string, std::size_t>> &files, const std::list<FileSettings>& fileSettings, ErrorLogger& errorLogger);
8586

8687
/**
8788
* Wrapper around check_internal

Diff for: test/testsuppressions.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ class TestSuppressions : public TestFixture {
265265
SingleExecutor executor(cppCheck, filelist, fileSettings, settings, settings.nomsg, *this);
266266
const unsigned int exitCode = executor.check();
267267

268-
CppCheckExecutor::reportSuppressions(settings, false, filelist, fileSettings, *this);
268+
CppCheckExecutor::reportSuppressions(settings, settings.nomsg, false, filelist, fileSettings, *this);
269269

270270
return exitCode;
271271
}
@@ -312,7 +312,7 @@ class TestSuppressions : public TestFixture {
312312
ThreadExecutor executor(filelist, fileSettings, settings, settings.nomsg, *this, CppCheckExecutor::executeCommand);
313313
const unsigned int exitCode = executor.check();
314314

315-
CppCheckExecutor::reportSuppressions(settings, false, filelist, fileSettings, *this);
315+
CppCheckExecutor::reportSuppressions(settings, settings.nomsg, false, filelist, fileSettings, *this);
316316

317317
return exitCode;
318318
}
@@ -360,7 +360,7 @@ class TestSuppressions : public TestFixture {
360360
ProcessExecutor executor(filelist, fileSettings, settings, settings.nomsg, *this, CppCheckExecutor::executeCommand);
361361
const unsigned int exitCode = executor.check();
362362

363-
CppCheckExecutor::reportSuppressions(settings, false, filelist, fileSettings, *this);
363+
CppCheckExecutor::reportSuppressions(settings, settings.nomsg, false, filelist, fileSettings, *this);
364364

365365
return exitCode;
366366
}

0 commit comments

Comments
 (0)