We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c15137e commit 150aa5dCopy full SHA for 150aa5d
csharp/ql/src/Bad Practices/Control-Flow/ConstantCondition.ql
@@ -119,9 +119,14 @@ class ConstantMatchingCondition extends ConstantCondition {
119
}
120
121
override predicate isWhiteListed() {
122
- exists(SwitchExpr se, int i |
123
- se.getCase(i).getPattern() = this.(DiscardExpr) and
124
- i > 0
+ exists(Switch se, Case c, int i | c = se.getCase(i) |
+ c.getPattern() = this.(DiscardExpr) and
+ (
125
+ i > 0
126
+ or
127
+ i = 0 and
128
+ exists(Expr cond | c.getCondition() = cond and not isConstantCondition(cond, true))
129
+ )
130
)
131
or
132
this = any(PositionalPatternExpr ppe).getPattern(_)
0 commit comments