Skip to content

Commit 8855978

Browse files
committed
Import project: Ignoring paths better
1 parent 4e222af commit 8855978

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

lib/importproject.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,17 @@ void ImportProject::ignorePaths(const std::vector<std::string> &ipaths)
3939
for (std::list<FileSettings>::iterator it = fileSettings.begin(); it != fileSettings.end();) {
4040
bool ignore = false;
4141
for (std::string i : ipaths) {
42-
if (!Path::isAbsolute(i))
43-
i = mPath + i;
4442
if (it->filename.size() > i.size() && it->filename.compare(0,i.size(),i)==0) {
4543
ignore = true;
4644
break;
4745
}
46+
if (!Path::isAbsolute(i)) {
47+
i = mPath + i;
48+
if (it->filename.size() > i.size() && it->filename.compare(0,i.size(),i)==0) {
49+
ignore = true;
50+
break;
51+
}
52+
}
4853
}
4954
if (ignore)
5055
fileSettings.erase(it++);

test/cli/test-helloworld.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,9 @@ def test_suppress_project():
179179
assert stderr == ''
180180

181181

182+
def test_exclude():
183+
prjpath = getRelativeProjectPath()
184+
ret, stdout, stderr = cppcheck(['-i' + prjpath, '--platform=win64', '--project=' + os.path.join(prjpath, 'helloworld.cppcheck')])
185+
assert stdout == 'cppcheck: No C or C++ source files found.\n'
186+
187+

0 commit comments

Comments
 (0)