diff --git a/codechecker_common/source_code_comment_handler.py b/codechecker_common/source_code_comment_handler.py index 687fc31ac7..b1e7f22775 100644 --- a/codechecker_common/source_code_comment_handler.py +++ b/codechecker_common/source_code_comment_handler.py @@ -304,8 +304,11 @@ def filter_source_line_comments(self, bug_line, checker_name): comment_len = len(checker_name_comments) if 'all' in line_comment['checkers'] and not comment_len: all_checker_comment = line_comment - if checker_name in line_comment['checkers']: - checker_name_comments.append(line_comment) + + for c in line_comment['checkers']: + if c in checker_name and c != 'all': + checker_name_comments.append(line_comment) + break if not comment_len and all_checker_comment: checker_name_comments.append(all_checker_comment) diff --git a/docs/web/user_guide.md b/docs/web/user_guide.md index bc519619b4..85fabc473a 100644 --- a/docs/web/user_guide.md +++ b/docs/web/user_guide.md @@ -1164,11 +1164,11 @@ not found, the user will be asked, in the command-line, to provide credentials. # Source code comments for review status -Source code comments can be used in the source files to change the review status -of a specific or all checker results found in a particular line of code. -Source code comment should be above the line where the defect was found, and __no__ -empty lines are allowed between the line with the bug and the source code -comment. +Source code comments can be used in the source files to change the review +status of a specific or all checker results found in a particular line of code. +Source code comment should be above the line where the defect was found, and +__no__ empty lines are allowed between the line with the bug and the source +code comment. Comment lines staring with `//` or C style `/**/` comments are supported. Watch out for the comment format! @@ -1203,6 +1203,20 @@ void test() { } ``` +## Change review status of a specific checker result by using a substring of the checker name +There is no need to specify the whole checker name in the source code comment +like `deadcode.DeadStores`, because it will not be resilient to package name +changes. You are able to specify only a substring of the checker name for the +source code comment: +```cpp +void test() { + int x; + // codechecker_confirmed [DeadStores] suppress deadcode + x = 1; // warn +} +``` + + ## Change review status of all checker result ```cpp void test() { diff --git a/web/tests/projects/suppress/suppress.cpp b/web/tests/projects/suppress/suppress.cpp index 6c96255600..65f6ff8665 100644 --- a/web/tests/projects/suppress/suppress.cpp +++ b/web/tests/projects/suppress/suppress.cpp @@ -38,6 +38,12 @@ void foo6() sizeof(45); } +void foo7() +{ + // codechecker_confirmed [sizeof-expression] substring of the checker name + sizeof(46); +} + int main() { return 0; diff --git a/web/tests/projects/suppress/suppress.expected b/web/tests/projects/suppress/suppress.expected index 737734951c..5dd2ad6776 100644 --- a/web/tests/projects/suppress/suppress.expected +++ b/web/tests/projects/suppress/suppress.expected @@ -3,3 +3,4 @@ 45a2fef6845f54eaf070ad03d19c7981||suppress.cpp||foo3 simple||intentional 9fb26da7f3224ec0c63cfe3617c8a14e||suppress.cpp||foo4 simple||confirmed 75290eaa234caeb95e45fedc1ab6a43d||suppress.cpp||foo5 simple||confirmed +f81ed46c9a231ece5949d53366acb83e||suppress.cpp||substring of the checker name||confirmed