File tree Expand file tree Collapse file tree 1 file changed +8
-18
lines changed
csharp/ql/src/Language Abuse Expand file tree Collapse file tree 1 file changed +8
-18
lines changed Original file line number Diff line number Diff line change 14
14
import csharp
15
15
import semmle.code.csharp.commons.StructuralComparison
16
16
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
+ )
33
23
}
34
24
35
- from StructuralComparisonConfig c , NullCoalescingExpr nce
36
- where nce = c . getUselessNullCoalescingExpr ( )
25
+ from NullCoalescingExpr nce
26
+ where uselessNullCoalescingExpr ( nce )
37
27
select 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