Skip to content

Commit

Permalink
starts with * => match any path
Browse files Browse the repository at this point in the history
  • Loading branch information
danmar committed Apr 8, 2024
1 parent cf2f7bb commit fc9f3ef
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions gui/projectfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -763,8 +763,10 @@ QList<SuppressionList::Suppression> ProjectFile::getCheckingSuppressions() const
const QRegularExpression re2("^[^/]+$");
QList<SuppressionList::Suppression> result;
for (SuppressionList::Suppression suppression : mSuppressions) {
if (re1.match(suppression.fileName.c_str()).hasMatch() || re2.match(suppression.fileName.c_str()).hasMatch())
suppression.fileName = QFileInfo(mFilename).absolutePath().toStdString() + "/" + suppression.fileName;
if (re1.match(suppression.fileName.c_str()).hasMatch() || re2.match(suppression.fileName.c_str()).hasMatch()) {
if (suppression.fileName[0] != '*')
suppression.fileName = QFileInfo(mFilename).absolutePath().toStdString() + "/" + suppression.fileName;
}
result << suppression;
}
return result;
Expand Down
2 changes: 1 addition & 1 deletion gui/test/projectfile/testprojectfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ void TestProjectFile::getCheckingSuppressionsStar() const
ProjectFile projectFile;
projectFile.setFilename("/some/path/123.cppcheck");
projectFile.setSuppressions(suppressions);
QCOMPARE(projectFile.getCheckingSuppressions()[0].fileName, "/some/path/*.cpp");
QCOMPARE(projectFile.getCheckingSuppressions()[0].fileName, "*.cpp");
}

QTEST_MAIN(TestProjectFile)
Expand Down

0 comments on commit fc9f3ef

Please sign in to comment.