Import project: Ignoring paths better

This commit is contained in:
Daniel Marjamäki 2019-09-12 09:32:24 +02:00
parent 4e222afa2c
commit 8855978f8a
2 changed files with 13 additions and 2 deletions

View File

@ -39,12 +39,17 @@ void ImportProject::ignorePaths(const std::vector<std::string> &ipaths)
for (std::list<FileSettings>::iterator it = fileSettings.begin(); it != fileSettings.end();) {
bool ignore = false;
for (std::string i : ipaths) {
if (!Path::isAbsolute(i))
i = mPath + i;
if (it->filename.size() > i.size() && it->filename.compare(0,i.size(),i)==0) {
ignore = true;
break;
}
if (!Path::isAbsolute(i)) {
i = mPath + i;
if (it->filename.size() > i.size() && it->filename.compare(0,i.size(),i)==0) {
ignore = true;
break;
}
}
}
if (ignore)
fileSettings.erase(it++);

View File

@ -179,3 +179,9 @@ def test_suppress_project():
assert stderr == ''
def test_exclude():
prjpath = getRelativeProjectPath()
ret, stdout, stderr = cppcheck(['-i' + prjpath, '--platform=win64', '--project=' + os.path.join(prjpath, 'helloworld.cppcheck')])
assert stdout == 'cppcheck: No C or C++ source files found.\n'