View Javadoc
1   import edu.umd.cs.findbugs.annotations.ExpectWarning;
2   
3   class UselessAssignments {
4   	@ExpectWarning("UuF,UrF")
5   	int foo, bar,g1,g2;
6   
7   	@ExpectWarning("DLS,SA")
8   	public UselessAssignments(int Foo, int Bar) {
9   		int x,y;
10  		foo = foo;
11  		Bar = Bar;
12  		g1 = g1 = 0;
13  		x = x = 0;
14  	}
15  
16  	static void setFoo(UselessAssignments ua1, UselessAssignments ua2) {
17  		ua1.foo = ua2.foo = 1;
18  		ua1.bar = ua1.bar = ua1.bar = 2;
19      }
20  
21  	int oops() {
22  		int i = 7;
23          i = ++i;
24  		i = i++;
25  		foo = foo++;
26  		foo = ++foo;
27          return i;
28  	}
29  
30  	public static void report(UselessAssignments ua1, UselessAssignments ua2) {
31  		ua1.foo = ua1.foo = ua1.foo = 17;
32  	}
33      public static void doNotReport(UselessAssignments ua1, UselessAssignments ua2) {
34  		ua1.bar = ua2.bar = 42;
35  	}
36  
37  }