File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed
csharp/ql/test/query-tests/Bad Practices/Control-Flow/ConstantCondition Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,7 @@ void M2(int i)
5050 j = ( int ? ) i ?? 1 ; // BAD
5151 s = "" ? . CommaJoinWith ( s ) ; // BAD
5252 s = s ?? "" ; // GOOD
53+ s = ( i == 0 ? s : null ) ?? s ; // BAD (False positive)
5354 }
5455}
5556
Original file line number Diff line number Diff line change 44| ConstantCondition.cs:49:17:49:18 | "" | Expression is never 'null'. |
55| ConstantCondition.cs:50:13:50:19 | (...) ... | Expression is never 'null'. |
66| ConstantCondition.cs:51:13:51:14 | "" | Expression is never 'null'. |
7- | ConstantCondition.cs:62:18:62:18 | 2 | Pattern never matches. |
8- | ConstantCondition.cs:64:18:64:18 | 3 | Pattern always matches. |
9- | ConstantCondition.cs:75:18:75:20 | access to type Int32 | Pattern never matches. |
7+ | ConstantCondition.cs:53:25:53:28 | null | Expression is always 'null'. |
8+ | ConstantCondition.cs:63:18:63:18 | 2 | Pattern never matches. |
9+ | ConstantCondition.cs:65:18:65:18 | 3 | Pattern always matches. |
10+ | ConstantCondition.cs:76:18:76:20 | access to type Int32 | Pattern never matches. |
1011| ConstantConditionBad.cs:5:16:5:20 | ... > ... | Condition always evaluates to 'false'. |
1112| ConstantConditionalExpressionCondition.cs:11:22:11:34 | ... == ... | Condition always evaluates to 'true'. |
1213| ConstantConditionalExpressionCondition.cs:12:21:12:25 | false | Condition always evaluates to 'false'. |
You can’t perform that action at this time.
0 commit comments