Skip to content

Commit

Permalink
Specify only a substring of the checker name for suppression
Browse files Browse the repository at this point in the history
csordasmarton committed Apr 1, 2019
1 parent 2485d1c commit 6db6098
Showing 4 changed files with 31 additions and 7 deletions.
7 changes: 5 additions & 2 deletions codechecker_common/source_code_comment_handler.py
Original file line number Diff line number Diff line change
@@ -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)
24 changes: 19 additions & 5 deletions docs/web/user_guide.md
Original file line number Diff line number Diff line change
@@ -1164,11 +1164,11 @@ not found, the user will be asked, in the command-line, to provide credentials.

# Source code comments for review status <a name="source-code-comments"></a>

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() {
6 changes: 6 additions & 0 deletions web/tests/projects/suppress/suppress.cpp
Original file line number Diff line number Diff line change
@@ -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;
1 change: 1 addition & 0 deletions web/tests/projects/suppress/suppress.expected
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 6db6098

Please sign in to comment.