File tree Expand file tree Collapse file tree
src/Best Practices/Likely Errors
test/query-tests/Best Practices/Likely Errors/EmptyBlock Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -78,7 +78,20 @@ predicate emptyBlockContainsNonchild(Block b) {
7878 )
7979}
8080
81+ predicate lineComment ( Block b ) {
82+ exists ( File f , int line |
83+ f = b .getFile ( ) and
84+ line = b .getLocation ( ) .getStartLine ( ) and
85+ line = b .getLocation ( ) .getEndLine ( ) and
86+ exists ( Comment c |
87+ c .getFile ( ) = f and
88+ c .getLocation ( ) .getStartLine ( ) = line
89+ )
90+ )
91+ }
92+
8193from ControlStructure s , Block eb
8294where emptyBlock ( s , eb )
8395 and not emptyBlockContainsNonchild ( eb )
96+ and not lineComment ( eb )
8497select eb , "Empty block without comment"
Original file line number Diff line number Diff line change 11| empty_block.cpp:7:10:7:11 | { ... } | Empty block without comment |
22| empty_block.cpp:10:10:11:3 | { ... } | Empty block without comment |
33| empty_block.cpp:18:10:19:3 | { ... } | Empty block without comment |
4- | empty_block.cpp:53:10:53:11 | { ... } | Empty block without comment |
5- | empty_block.cpp:56:10:56:11 | { ... } | Empty block without comment |
You can’t perform that action at this time.
0 commit comments