Migrate Java code to separate QL repo.

This commit is contained in:
Pavel Avgustinov
2018-08-30 10:48:05 +01:00
parent d957c151a6
commit 846c9d5860
2319 changed files with 134386 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
import java.util.*;
public class MapTest {
// should not be flagged since l1 is public
public Map<String, Integer> l1 = new HashMap<String, Integer>();
// should not be flagged since l2 is a parameter
public Map<String, Integer> m(Map<String, Integer> l2) {
l2.remove("");
// should not be flagged since it is assigned an existing map
Map<String, Integer> l3 = l2;
// should not be flagged since it is assigned an existing map
Map<String, Integer> l33;
l33 = l2;
// should not be flagged since it is returned
Map<String, Integer> s1 = new LinkedHashMap<String, Integer>();
// should not be flagged since it is assigned to another variable
Map<String, Integer> l4 = new HashMap<String, Integer>();
this.l1 = l4;
// should not be flagged since its contents are accessed
Map<String, Integer> l5 = new HashMap<String, Integer>();
if(!l5.containsKey("hello"))
l5.put("hello", 23);
// should not be flagged since its contents are accessed
Map<String, Integer> l6 = new HashMap<String, Integer>();
if(l6.remove("") != null)
return null;
return s1;
}
public void n(Collection<Map<String, Integer>> ms) {
// should not be flagged since it is implicitly assigned an existing collection
for (Map<String, Integer> m : ms)
m.put("world", 42);
}
// should be flagged
private Map<String, Integer> useless = new HashMap<String, Integer>();
{
useless.put("hello", 23);
useless.remove("hello");
}
// should not be flagged since it is annotated with @SuppressWarnings("unused")
@SuppressWarnings("unused")
private Map<String, Integer> l7 = new HashMap<String, Integer>();
// should not be flagged since it is annotated with a non-standard annotation suggesting reflective access
@interface MyReflectionAnnotation {}
@MyReflectionAnnotation
private Map<String, Integer> l8 = new HashMap<String, Integer>();
}