Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
void complex_block() {
while (true) {
Comment thread
geoffw0 marked this conversation as resolved.
int a = 1;
int b = 2;
int c = 3;
int d = 4;
int e = 5;
int f = 6;
int g = 7;
int h = 8;
int i = 9;
int j = 10;
}
while (true) {
int a = 1;
int b = 2;
int c = 3;
int d = 4;
int e = 5;
int f = 6;
int g = 7;
int h = 8;
int i = 9;
int j = 10;
}
while (true) {
int a = 1;
int b = 2;
int c = 3;
int d = 4;
int e = 5;
int f = 6;
int g = 7;
int h = 8;
int i = 9;
int j = 10;
}
while (true) {
int a = 1;
int b = 2;
int c = 3;
int d = 4;
int e = 5;
int f = 6;
int g = 7;
int h = 8;
int i = 9;
int j = 10;
}
while (true) {
int a = 1;
int b = 2;
int c = 3;
int d = 4;
int e = 5;
int f = 6;
int g = 7;
int h = 8;
int i = 9;
int j = 10;
}
} // $ Alert

void not_complex_block() {
while (true) {
int a = 1;
int b = 2;
int c = 3;
int d = 4;
int e = 5;
}
while (true) {
int a = 1;
int b = 2;
int c = 3;
int d = 4;
int e = 5;
}
while (true) {
int a = 1;
int b = 2;
int c = 3;
int d = 4;
int e = 5;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
| BlockWithTooManyStatements.cpp:1:22:62:1 | { ... } | Block with too many statements (5 complex statements in the block). |
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
query: Best Practices/BlockWithTooManyStatements.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
void complex_condition(bool a, bool b, bool c, bool d, bool e, bool f, bool g, bool h, bool i, bool j,
bool k, bool l, bool m, bool n, bool o) {
if (a || b && c || d && e || f && g || h && i || j && k || l && m || n && o) { // $ Alert
Comment thread
geoffw0 marked this conversation as resolved.
}
}

void not_complex_condition(bool a, bool b, bool c, bool d, bool e, bool f) {
if (a && b || c && d || e && f) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
| ComplexCondition.cpp:3:7:3:77 | ... \|\| ... | Complex condition: too many logical operations in this expression. |
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
query: Best Practices/ComplexCondition.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
25 changes: 25 additions & 0 deletions cpp/ql/test/query-tests/Best Practices/UseOfGoto/UseOfGoto.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
bool cond();

void multiple_forward_and_backward_goto() { // $ Alert
backward_one:
if (cond()) goto forward_one;
backward_two:
if (cond()) goto forward_two;
forward_one:
if (cond()) goto backward_one;
forward_two:
if (cond()) goto backward_two;
}

void only_forward_goto() {
if (cond()) goto end;
Comment thread
geoffw0 marked this conversation as resolved.

// ...

if (cond()) goto end;

// ...

end:
// ...
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
| UseOfGoto.cpp:3:6:3:39 | definition of multiple_forward_and_backward_goto | Multiple forward and backward goto statements may make function multiple_forward_and_backward_goto hard to understand. |
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
query: Best Practices/UseOfGoto.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
Loading