Repository navigation
C++: Fill gaps in query tests (part 2) #22729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
dea8803
C++: Test complex-block statement thresholds
geoffw0 1a733a6
C++: Test complex-condition operator threshold
geoffw0 c8a09a0
C++: Test goto target counts
geoffw0 b35b1f4
C++: Adjust the tests with thresholds so as to test the extremes, not…
geoffw0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
86 changes: 86 additions & 0 deletions
86
...test/query-tests/Best Practices/BlockWithTooManyStatements/BlockWithTooManyStatements.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| void complex_block() { | ||
| 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; | ||
| } | ||
| 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; | ||
| } | ||
| } | ||
1 change: 1 addition & 0 deletions
1
...query-tests/Best Practices/BlockWithTooManyStatements/BlockWithTooManyStatements.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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). | |
2 changes: 2 additions & 0 deletions
2
...st/query-tests/Best Practices/BlockWithTooManyStatements/BlockWithTooManyStatements.qlref
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| query: Best Practices/BlockWithTooManyStatements.ql | ||
| postprocess: utils/test/InlineExpectationsTestQuery.ql |
10 changes: 10 additions & 0 deletions
10
cpp/ql/test/query-tests/Best Practices/ComplexCondition/ComplexCondition.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
|
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) { | ||
| } | ||
| } | ||
1 change: 1 addition & 0 deletions
1
cpp/ql/test/query-tests/Best Practices/ComplexCondition/ComplexCondition.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. | |
2 changes: 2 additions & 0 deletions
2
cpp/ql/test/query-tests/Best Practices/ComplexCondition/ComplexCondition.qlref
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
25
cpp/ql/test/query-tests/Best Practices/UseOfGoto/UseOfGoto.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
|
geoffw0 marked this conversation as resolved.
|
||
|
|
||
| // ... | ||
|
|
||
| if (cond()) goto end; | ||
|
|
||
| // ... | ||
|
|
||
| end: | ||
| // ... | ||
| } | ||
1 change: 1 addition & 0 deletions
1
cpp/ql/test/query-tests/Best Practices/UseOfGoto/UseOfGoto.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. | |
2 changes: 2 additions & 0 deletions
2
cpp/ql/test/query-tests/Best Practices/UseOfGoto/UseOfGoto.qlref
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| query: Best Practices/UseOfGoto.ql | ||
| postprocess: utils/test/InlineExpectationsTestQuery.ql |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.