Skip to content

Commit ffcb5e7

Browse files
committed
SingleExecutor: process markup files after code with file settings
1 parent f4c48cf commit ffcb5e7

2 files changed

Lines changed: 35 additions & 14 deletions

File tree

cli/singleexecutor.cpp

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,25 +66,45 @@ unsigned int SingleExecutor::check()
6666
// filesettings
6767
// check all files of the project
6868
for (const ImportProject::FileSettings &fs : mSettings.project.fileSettings) {
69-
// TODO: handle markup files
70-
result += mCppcheck.check(fs);
71-
++c;
72-
if (!mSettings.quiet)
73-
reportStatus(c, mSettings.project.fileSettings.size(), c, mSettings.project.fileSettings.size());
74-
if (mSettings.clangTidy)
75-
mCppcheck.analyseClangTidy(fs);
69+
if (!mSettings.library.markupFile(fs.filename)
70+
|| !mSettings.library.processMarkupAfterCode(fs.filename)) {
71+
result += mCppcheck.check(fs);
72+
++c;
73+
if (!mSettings.quiet)
74+
reportStatus(c, mSettings.project.fileSettings.size(), c, mSettings.project.fileSettings.size());
75+
if (mSettings.clangTidy)
76+
mCppcheck.analyseClangTidy(fs);
77+
}
7678
}
7779
}
7880

7981
// second loop to parse all markup files which may not work until all
8082
// c/cpp files have been parsed and checked
81-
for (std::map<std::string, std::size_t>::const_iterator i = mFiles.cbegin(); i != mFiles.cend(); ++i) {
82-
if (mSettings.library.markupFile(i->first) && mSettings.library.processMarkupAfterCode(i->first)) {
83-
result += mCppcheck.check(i->first);
84-
processedsize += i->second;
85-
if (!mSettings.quiet)
86-
reportStatus(c + 1, mFiles.size(), processedsize, totalfilesize);
87-
c++;
83+
// TODO: get rid of duplicated code
84+
if (mSettings.project.fileSettings.empty()) {
85+
for (std::map<std::string, std::size_t>::const_iterator i = mFiles.cbegin(); i != mFiles.cend(); ++i) {
86+
if (mSettings.library.markupFile(i->first)
87+
&& mSettings.library.processMarkupAfterCode(i->first)) {
88+
result += mCppcheck.check(i->first);
89+
processedsize += i->second;
90+
if (!mSettings.quiet)
91+
reportStatus(c + 1, mFiles.size(), processedsize, totalfilesize);
92+
// TODO: call analyseClangTidy()
93+
c++;
94+
}
95+
}
96+
}
97+
else {
98+
for (const ImportProject::FileSettings &fs : mSettings.project.fileSettings) {
99+
if (mSettings.library.markupFile(fs.filename)
100+
&& mSettings.library.processMarkupAfterCode(fs.filename)) {
101+
result += mCppcheck.check(fs);
102+
++c;
103+
if (!mSettings.quiet)
104+
reportStatus(c, mSettings.project.fileSettings.size(), c, mSettings.project.fileSettings.size());
105+
if (mSettings.clangTidy)
106+
mCppcheck.analyseClangTidy(fs);
107+
}
88108
}
89109
}
90110
if (mCppcheck.analyseWholeProgram())

releasenotes.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ release notes for cppcheck-2.11
1414
- `constVariableReference`
1515
- `constVariablePointer`
1616
- More command-line parameters will now check if the given integer argument is actually valid. Several other internal string-to-integer conversions will not be error checked.
17+
- scanning projects (with -j1) will now defer the analysis of markup files until the whole code was processed

0 commit comments

Comments
 (0)