File tree Expand file tree Collapse file tree 4 files changed +36
-0
lines changed
csharp/ql/test/query-tests/Useless Code/FutileConditional Expand file tree Collapse file tree 4 files changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ using System ;
2
+
3
+ class FutileConditionalTest
4
+ {
5
+
6
+ public void M ( string s )
7
+ {
8
+ if ( s . Length > 0 ) ; // $ Alert
9
+
10
+ if ( s . Length > 1 )
11
+ {
12
+ } // $ Alert
13
+
14
+ if ( s . Length > 2 ) // GOOD: because of else-branch
15
+ {
16
+ }
17
+ else
18
+ {
19
+ Console . WriteLine ( "hello" ) ;
20
+ }
21
+
22
+ if ( s . Length > 3 )
23
+ {
24
+ }
25
+ else
26
+ {
27
+ } // $ Alert
28
+ }
29
+ }
Original file line number Diff line number Diff line change
1
+ | FutileConditional.cs:8:9:8:27 | if (...) ... | If-statement with an empty then-branch and no else-branch. |
2
+ | FutileConditional.cs:10:9:12:9 | if (...) ... | If-statement with an empty then-branch and no else-branch. |
3
+ | FutileConditional.cs:22:9:27:9 | if (...) ... | If-statement with an empty then-branch and no else-branch. |
Original file line number Diff line number Diff line change
1
+ query: Useless code/FutileConditional.ql
2
+ postprocess: utils/test/InlineExpectationsTestQuery.ql
Original file line number Diff line number Diff line change
1
+ semmle-extractor-options: /nostdlib /noconfig
2
+ semmle-extractor-options: --load-sources-from-project:${testdir}/../../../resources/stubs/_frameworks/Microsoft.NETCore.App/Microsoft.NETCore.App.csproj
You can’t perform that action at this time.
0 commit comments