Skip to content

Commit 50d297b

Browse files
Enable useStlAlgorithm in selfcheck (#4725)
1 parent f8f66ae commit 50d297b

3 files changed

Lines changed: 11 additions & 9 deletions

File tree

.selfcheck_suppressions

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ shadowFunction
22
bitwiseOnBoolean
33

44
# temporary suppressions - fix the warnings!
5-
useStlAlgorithm
65
simplifyUsing:lib/valueptr.h
76
varid0:gui/projectfile.cpp
87

cli/cppcheckexecutor.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,11 @@ int CppCheckExecutor::check_wrapper(CppCheck& cppcheck)
243243
}
244244

245245
bool CppCheckExecutor::reportSuppressions(const Settings &settings, bool unusedFunctionCheckEnabled, const std::map<std::string, std::size_t> &files, ErrorLogger& errorLogger) {
246-
for (const Suppressions::Suppression& suppression: settings.nomsg.getSuppressions()) {
247-
if (suppression.errorId == "unmatchedSuppression" && suppression.fileName.empty() && suppression.lineNumber == Suppressions::Suppression::NO_LINE)
248-
return false;
249-
}
246+
const auto& suppressions = settings.nomsg.getSuppressions();
247+
if (std::any_of(suppressions.begin(), suppressions.end(), [](const Suppressions::Suppression& s) {
248+
return s.errorId == "unmatchedSuppression" && s.fileName.empty() && s.lineNumber == Suppressions::Suppression::NO_LINE;
249+
}))
250+
return false;
250251

251252
bool err = false;
252253
if (settings.jointSuppressionReport) {

lib/symboldatabase.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4633,10 +4633,12 @@ const Token *Scope::checkVariable(const Token *tok, AccessControl varaccess, con
46334633

46344634
const Variable *Scope::getVariable(const std::string &varname) const
46354635
{
4636-
for (const Variable& var: varlist) {
4637-
if (var.name() == varname)
4638-
return &var;
4639-
}
4636+
auto it = std::find_if(varlist.begin(), varlist.end(), [&varname](const Variable& var) {
4637+
return var.name() == varname;
4638+
});
4639+
if (it != varlist.end())
4640+
return &*it;
4641+
46404642
if (definedType) {
46414643
for (const Type::BaseInfo& baseInfo: definedType->derivedFrom) {
46424644
if (baseInfo.type && baseInfo.type->classScope) {

0 commit comments

Comments
 (0)