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