import java.util.*; public class CollectionTest { // should not be flagged since l1 is public public List l1 = new ArrayList(); // should not be flagged since l2 is a parameter public Set m(List l2) { l2.add(23); // should not be flagged since it is assigned an existing collection Collection l3 = l2; // should not be flagged since it is assigned an existing collection Collection l33; l33 = l2; // should not be flagged since it is returned Set s1 = new LinkedHashSet(); // should not be flagged since it is assigned to another variable List l4 = new ArrayList(); this.l1 = l4; // should not be flagged since its contents are accessed List l5 = new ArrayList(); if(!l5.contains(23)) l5.add(23); // should not be flagged since its contents are accessed List l6 = new ArrayList(); if(!l6.add(23)) return null; return s1; } public void n(Collection> ss) { // should not be flagged since it is implicitly assigned an existing collection for (Set s : ss) s.add(23); } // should be flagged private List useless = new ArrayList(); { useless.add(23); useless.remove(0); } // should not be flagged since it is annotated with @SuppressWarnings("unused") @SuppressWarnings("unused") private List l7 = new ArrayList(); // should not be flagged since it is annotated with a non-standard annotation suggesting reflective access @interface MyReflectionAnnotation {} @MyReflectionAnnotation private List l8 = new ArrayList(); }