File tree Expand file tree Collapse file tree
cpp/ql/src/Best Practices/Likely Errors Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,6 +29,10 @@ class AffectedFile extends File {
2929 }
3030}
3131
32+ /**
33+ * A block, or an element we might find textually within a block that is
34+ * not a child of it in the AST.
35+ */
3236class BlockOrNonChild extends Element {
3337 BlockOrNonChild ( ) {
3438 ( this instanceof Block
@@ -68,6 +72,9 @@ class BlockOrNonChild extends Element {
6872 }
6973}
7074
75+ /**
76+ * A block that contains a non-child element.
77+ */
7178predicate emptyBlockContainsNonchild ( Block b ) {
7279 emptyBlock ( _, b ) and
7380 exists ( BlockOrNonChild c , AffectedFile file |
@@ -78,7 +85,12 @@ predicate emptyBlockContainsNonchild(Block b) {
7885 )
7986}
8087
88+ /**
89+ * A block that is entirely on one line, which also contains a comment. Chances
90+ * are the comment is intended to refer to the block.
91+ */
8192predicate lineComment ( Block b ) {
93+ emptyBlock ( _, b ) and
8294 exists ( File f , int line |
8395 f = b .getFile ( ) and
8496 line = b .getLocation ( ) .getStartLine ( ) and
You can’t perform that action at this time.
0 commit comments