Skip to content

Commit 766a70e

Browse files
committed
cppcheck.cpp: small refactoring in checkFile()
1 parent 370672c commit 766a70e

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

lib/cppcheck.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -800,10 +800,10 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string
800800
}
801801

802802
// Run define rules on raw code
803-
for (const Settings::Rule &rule : mSettings.rules) {
804-
if (rule.tokenlist != "define")
805-
continue;
806-
803+
const auto it = std::find_if(mSettings.rules.cbegin(), mSettings.rules.cend(), [](const Settings::Rule& rule) {
804+
return rule.tokenlist == "define";
805+
});
806+
if (it != mSettings.rules.cend()) {
807807
std::string code;
808808
const std::list<Directive> &directives = preprocessor.getDirectives();
809809
for (const Directive &dir : directives) {
@@ -814,7 +814,6 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string
814814
std::istringstream istr2(code);
815815
tokenizer2.list.createTokens(istr2);
816816
executeRules("define", tokenizer2);
817-
break;
818817
}
819818

820819
if (!mSettings.force && configurations.size() > mSettings.maxConfigs) {

0 commit comments

Comments
 (0)