@@ -11,54 +11,54 @@ class CompareIdenticalValues : Super
1111{
1212 public void M ( )
1313 {
14- if ( this . Foo == Foo ) ; // $ Alert
15- if ( base . Foo == Foo ) ; // $ Alert
14+ if ( this . Foo == Foo ) ; // $ Alert[cs/comparison-of-identical-expressions]
15+ if ( base . Foo == Foo ) ; // $ Alert[cs/comparison-of-identical-expressions]
1616 if ( Foo == new CompareIdenticalValues ( ) . Foo ) ;
1717
1818 var x = "Abc" ;
1919 if ( x == "Abc" ) ;
20- var temp = x == x ; // BAD: but flagged by cs/constant-comparison
20+ var temp = x == x ; // $ Alert[cs/constant-condition] // BAD: but flagged by cs/constant-condition
2121
2222 double d = double . NaN ;
23- if ( d == d ) ; // $ Alert // !double.IsNan(d)
24- if ( d <= d ) ; // $ Alert // !double.IsNan(d), but unlikely to be intentional
25- if ( d >= d ) ; // $ Alert // !double.IsNan(d), but unlikely to be intentional
26- if ( d != d ) ; // $ Alert // double.IsNan(d)
27- if ( d > d ) ; // $ Alert // always false
28- if ( d < d ) ; // $ Alert // always false
23+ if ( d == d ) ; // $ Alert[cs/comparison-of-identical-expressions] // !double.IsNan(d)
24+ if ( d <= d ) ; // $ Alert[cs/comparison-of-identical-expressions] // !double.IsNan(d), but unlikely to be intentional
25+ if ( d >= d ) ; // $ Alert[cs/comparison-of-identical-expressions] // !double.IsNan(d), but unlikely to be intentional
26+ if ( d != d ) ; // $ Alert[cs/comparison-of-identical-expressions] // double.IsNan(d)
27+ if ( d > d ) ; // $ Alert[cs/comparison-of-identical-expressions] // always false
28+ if ( d < d ) ; // $ Alert[cs/comparison-of-identical-expressions] // always false
2929
3030 float f = float . NaN ;
31- if ( f == f ) ; // $ Alert // !float.IsNan(f)
32- if ( f <= f ) ; // $ Alert // !float.IsNan(f), but unlikely to be intentional
33- if ( f >= f ) ; // $ Alert // !float.IsNan(f), but unlikely to be intentional
34- if ( f != f ) ; // $ Alert // float.IsNan(f)
35- if ( f > f ) ; // $ Alert // always false
36- if ( f < f ) ; // $ Alert // always false
31+ if ( f == f ) ; // $ Alert[cs/comparison-of-identical-expressions] // !float.IsNan(f)
32+ if ( f <= f ) ; // $ Alert[cs/comparison-of-identical-expressions] // !float.IsNan(f), but unlikely to be intentional
33+ if ( f >= f ) ; // $ Alert[cs/comparison-of-identical-expressions] // !float.IsNan(f), but unlikely to be intentional
34+ if ( f != f ) ; // $ Alert[cs/comparison-of-identical-expressions] // float.IsNan(f)
35+ if ( f > f ) ; // $ Alert[cs/comparison-of-identical-expressions] // always false
36+ if ( f < f ) ; // $ Alert[cs/comparison-of-identical-expressions] // always false
3737
3838 int i = 0 ;
39- if ( i == i ) ; // BAD: but flagged by cs/constant-condition
40- if ( i != i ) ; // BAD: but flagged by cs/constant-condition
39+ if ( i == i ) ; // $ Alert[cs/constant-condition] // BAD: but flagged by cs/constant-condition
40+ if ( i != i ) ; // $ Alert[cs/constant-condition] // BAD: but flagged by cs/constant-condition
4141
4242 CompareIdenticalValues c = null ;
43- c . Prop . Equals ( c . Prop ) ; // $ Alert
44- Equals ( c . Prop . Prop . Prop . Foo + 2 , c . Prop . Prop . Prop . Foo + 2 ) ; // $ Alert
43+ c . Prop . Equals ( c . Prop ) ; // $ Alert[cs/comparison-of-identical-expressions]
44+ Equals ( c . Prop . Prop . Prop . Foo + 2 , c . Prop . Prop . Prop . Foo + 2 ) ; // $ Alert[cs/comparison-of-identical-expressions]
4545 Equals ( c . Prop . Prop . Prop . Foo , c . Prop . Prop . Foo ) ;
4646
4747 if ( base . Bar == Bar ) ;
48- if ( Bar == this . Bar ) ; // $ Alert
49- Equals ( this ) ; // $ Alert
48+ if ( Bar == this . Bar ) ; // $ Alert[cs/comparison-of-identical-expressions]
49+ Equals ( this ) ; // $ Alert[cs/comparison-of-identical-expressions]
5050
51- if ( 1 + 1 == 2 ) ; // BAD: but flagged by cs/constant-condition
52- if ( 1 + 1 == 3 ) ;
53- if ( 0 == 1 ) ;
51+ if ( 1 + 1 == 2 ) ; // $ Alert[cs/constant-condition] // BAD: but flagged by cs/constant-condition
52+ if ( 1 + 1 == 3 ) ; // $ Alert[cs/constant-condition] // BAD: but flagged by cs/constant-condition
53+ if ( 0 == 1 ) ; // $ Alert[cs/constant-condition] // BAD: but flagged by cs/constant-condition
5454
5555 var a = new int [ 0 ] ;
56- if ( a [ 0 ] == a [ 0 ] ) ; // $ Alert
56+ if ( a [ 0 ] == a [ 0 ] ) ; // $ Alert[cs/comparison-of-identical-expressions]
5757
58- if ( this . Bar [ 0 ] == Bar [ 1 - 1 ] ) ; // $ Alert
58+ if ( this . Bar [ 0 ] == Bar [ 1 - 1 ] ) ; // $ Alert[cs/comparison-of-identical-expressions]
5959 if ( this . Bar [ 0 ] == Bar [ 1 ] ) ;
6060
61- if ( this . Prop [ Foo ] == Prop [ this . Foo ] ) ; // $ Alert
61+ if ( this . Prop [ Foo ] == Prop [ this . Foo ] ) ; // $ Alert[cs/comparison-of-identical-expressions]
6262 if ( this . Prop [ 0 ] == Prop [ 1 ] ) ;
6363 }
6464
@@ -73,17 +73,17 @@ public void IsBoxed<T>(T x) where T : I
7373
7474 public void IsBoxedWrong1 < T > ( T x ) where T : struct
7575 {
76- ReferenceEquals ( x , x ) ; // $ Alert
76+ ReferenceEquals ( x , x ) ; // $ Alert[cs/comparison-of-identical-expressions]
7777 }
7878
7979 public void IsBoxedWrong2 < T > ( T x ) where T : class
8080 {
81- ReferenceEquals ( x , x ) ; // $ Alert
81+ ReferenceEquals ( x , x ) ; // $ Alert[cs/comparison-of-identical-expressions]
8282 }
8383
8484 public void IsBoxedWrong3 < T > ( T x ) where T : Super
8585 {
86- ReferenceEquals ( x , x ) ; // $ Alert
86+ ReferenceEquals ( x , x ) ; // $ Alert[cs/comparison-of-identical-expressions]
8787 }
8888
8989 public int this [ int i ] { get { return 0 ; } }
0 commit comments