File tree Expand file tree Collapse file tree
csharp/ql/src/Language Abuse Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414import csharp
1515import semmle.code.csharp.commons.StructuralComparison
1616
17- class StructuralComparisonConfig extends StructuralComparisonConfiguration {
18- StructuralComparisonConfig ( ) { this = "UselessNullCoalescingExpression" }
19-
20- override predicate candidate ( ControlFlowElement x , ControlFlowElement y ) {
21- exists ( NullCoalescingExpr nce |
22- x .( Access ) = nce .getLeftOperand ( ) and
23- y .( Access ) = nce .getRightOperand ( ) .getAChildExpr * ( )
24- )
25- }
26-
27- NullCoalescingExpr getUselessNullCoalescingExpr ( ) {
28- exists ( AssignableAccess x |
29- result .getLeftOperand ( ) = x and
30- forex ( AssignableAccess y | same ( x , y ) | y instanceof AssignableRead and not y .isRefArgument ( ) )
31- )
32- }
17+ private predicate uselessNullCoalescingExpr ( NullCoalescingExpr nce ) {
18+ forex ( AssignableAccess y |
19+ y = nce .getRightOperand ( ) .getAChildExpr * ( ) and sameGvn ( nce .getLeftOperand ( ) , y )
20+ |
21+ y instanceof AssignableRead and not y .isRefArgument ( )
22+ )
3323}
3424
35- from StructuralComparisonConfig c , NullCoalescingExpr nce
36- where nce = c . getUselessNullCoalescingExpr ( )
25+ from NullCoalescingExpr nce
26+ where uselessNullCoalescingExpr ( nce )
3727select nce , "Both operands of this null-coalescing expression access the same variable or property."
You can’t perform that action at this time.
0 commit comments