repo
stringlengths
1
191
file
stringlengths
23
351
code
stringlengths
0
5.32M
file_length
int64
0
5.32M
avg_line_length
float64
0
2.9k
max_line_length
int64
0
288k
extension_type
stringclasses
1 value
codeql
codeql-master/java/ql/test/query-tests/StringFormat/A.java
import java.util.Formatter; import java.io.PrintStream; import java.io.PrintWriter; import java.io.Console; import java.io.File; public class A { void f_string() { String.format("%s%s", ""); // missing } void f_formatter(Formatter x) { x.format("%s%s", ""); // missing } void f_printstream(PrintStream x) { x.format("%s%s", ""); // missing x.printf("%s%s", ""); // missing } void f_printwriter(PrintWriter x) { x.format("%s%s", ""); // missing x.printf("%s%s", ""); // missing } void f_console(Console x) { x.format("%s%s", ""); // missing x.printf("%s%s", ""); // missing x.readLine("%s%s", ""); // missing x.readPassword("%s%s", ""); // missing } void custom_format(Object o, String fmt, Object... args) { String.format(fmt, args); } void f_wrapper() { custom_format(new Object(), "%s%s", ""); // missing } void f() { String.format("%s", "", ""); // unused String.format("s", ""); // unused String.format("%2$s %2$s", "", ""); // unused String.format("%2$s %1$s", "", ""); // ok String.format("%2$s %s", ""); // missing String.format("%s%<s", "", ""); // unused String.format("%s%%%%%%%%s%n", "", ""); // unused String.format("%s%%%%%%%%s%n", ""); // ok String.format("%s%%%%%%%s%n", "", ""); // ok String.format("%s%%%%%%%s%n", ""); // missing String.format("%2$s %% %n %1$s %<s %s %<s %s %1$s", "", ""); // ok } final String f_fmt1 = "%s" + File.separator; final String f_fmt2 = "%s" + f_fmt1 + System.getProperty("line.separator"); final String f_fmt3 = "%s" + f_fmt2; void g(boolean b, int i) { String fmt1 = "%s" + (b ? "%s" : ""); String.format(fmt1, ""); // missing String.format(fmt1, "", ""); // ok String.format(fmt1, "", "", ""); // unused String fmt2 = "%s%" + i + "s%n"; String.format(fmt2, ""); // missing String.format(fmt2, "", ""); // ok String.format(fmt2, "", "", ""); // unused String.format(f_fmt3, "", ""); // missing String.format(f_fmt3, "", "", ""); // ok String.format(f_fmt3, "", "", "", ""); // unused String.format("%s%s", new Object[] { "a" }); // missing String.format("%s%s", new Object[] { "a", "b" }); // ok String.format("%s%s", new Object[] { "a", "b", "c" }); // unused Object[] a1 = new Object[] { "a", "b" }; String.format("%s%s%s", a1); // missing String.format("%s%s", a1); // ok String.format("%s", a1); // unused Object[] a2 = new Object[2]; String.format("%s%s%s", a2); // missing String.format("%s%s", a2); // ok String.format("%s", a2); // unused } }
2,638
28.651685
77
java
codeql
codeql-master/java/ql/test/query-tests/StartInConstructor/Test.java
import java.lang.Thread; public class Test { Thread myThread; public Test() { myThread = new Thread("myThread"); // BAD myThread.start(); } public static final class Final { Thread myThread; public Final() { myThread = new Thread("myThread"); // OK - class cannot be extended myThread.start(); } } private static class Private { Thread myThread; public Private() { myThread = new Thread("myThread"); // OK - class can only be extended in this file, and is not in fact extended myThread.start(); } } }
557
15.909091
79
java
codeql
codeql-master/java/ql/test/query-tests/StringComparison/StringComparison.java
class StringComparison { private static final String CONST = "foo"; public void test(String param) { String variable = "hello"; variable = param; String variable2 = "world"; variable2 += "it's me"; // OK if("" == "a") return; // OK if("" == param.intern()) return; // OK if("" == CONST) return; // OK if("".equals(variable)) return; // NOT OK if("" == variable) return; // NOT OK if("" == param) return; // NOT OK if("" == variable2) return; } }
510
14.484848
43
java
codeql
codeql-master/java/ql/test/query-tests/AutoBoxing/Test.java
class Test { void unbox(Integer i, Boolean b) { // NOT OK int j = i + 19; // OK if (i == null); // NOT OK if (i == 42); // NOT OK j += i; // NOT OK int k = i; // NOT OK bar(b); // NOT OK int l = i == null ? 0 : i; } void bar(boolean b) {} Integer box(int i) { Integer[] is = new Integer[1]; // NOT OK is[0] = i; // NOT OK Integer j = i; // NOT OK return i == -1 ? null : i; } void rebox(Integer i) { // NOT OK i += 19; } }
478
12.685714
35
java
codeql
codeql-master/java/ql/test/query-tests/ConfusingOverloading/TestConfusingOverloading.java
public class TestConfusingOverloading { class Super<T> { void test2(T t) {} void test(Super<T> other) {} } class Sub extends Super<Runnable> { void test(Sub other) {} } class Sub2 extends Super<Runnable> { @Override void test2(Runnable r) {} @Override void test(Super<Runnable> other) {} } } class TestDelegates { class A {} class B1 extends A {} class B2 extends A {} class C extends B1 {} void test(A a) {} // OK (all overloaded methods are either delegates or deprecated) void test(B1 b1) { test((A)b1); } // OK (delegate) void test(B2 b2) { test((A)b2); } // OK (delegate) void test(C c) { test((B1)c); } // OK (delegate) @Deprecated void test(Object obj) {} // OK (deprecated) }
712
24.464286
84
java
codeql
codeql-master/java/ql/test/query-tests/CallsToRunnableRun/CallsToRunnableRun.java
import java.lang.Runnable; public class CallsToRunnableRun extends Thread implements Runnable{ private Thread wrapped; private Runnable callback; @Override public void run() { wrapped.run(); callback.run(); } public void bad() { wrapped.run(); callback.run(); } }
286
14.105263
67
java
codeql
codeql-master/java/ql/test/query-tests/TypeMismatch/incomparable_equals/Test.java
package incomparable_equals; public class Test { private void assertTrue(boolean b) { if(!b) throw new AssertionError(); } void test() { assert !new Integer(1).equals("1"); assertTrue(!new StringBuffer().equals("")); } }
236
17.230769
45
java
codeql
codeql-master/java/ql/test/query-tests/TypeMismatch/incomparable_equals/F.java
package incomparable_equals; public class F { void m(int[] l, int[][] r) { l.equals(r); } }
96
12.857143
29
java
codeql
codeql-master/java/ql/test/query-tests/TypeMismatch/incomparable_equals/B.java
package incomparable_equals; public class B<T extends B> { T t; void test(String s) { t.equals(s); t.equals(this); } }
129
10.818182
29
java
codeql
codeql-master/java/ql/test/query-tests/TypeMismatch/incomparable_equals/D.java
package incomparable_equals; public class D<T> { public void test(java.util.List<? extends T> l, String s) { l.get(0).equals(s); } public static void main(String[] args) { new D<String>().test(java.util.Collections.singletonList("Hi!"), "Hi!"); } }
260
20.75
74
java
codeql
codeql-master/java/ql/test/query-tests/TypeMismatch/incomparable_equals/A.java
package incomparable_equals; public class A<T> { T t; void test(String s) { t.equals(s); } }
101
9.2
28
java
codeql
codeql-master/java/ql/test/query-tests/TypeMismatch/incomparable_equals/E.java
package incomparable_equals; class GraBase<T> { class GrBase { public boolean equals(Object other) { return false; } } } class GraDelegator<T,U> extends GraBase<T> {} class Gra4To4Hist<T> extends GraDelegator<T, T> { class Gr4To4Hist extends GraBase<T>.GrBase {} } public class E<P> { Gra4To4Hist<P>.Gr4To4Hist getGr4Main() { return null; } public boolean equals(Object other) { E<?> that = (E<?>)other; return getGr4Main().equals(that.getGr4Main()); } }
473
19.608696
56
java
codeql
codeql-master/java/ql/test/query-tests/TypeMismatch/incomparable_equals/MyEntry.java
package incomparable_equals; import java.util.Map.Entry; @SuppressWarnings("rawtypes") public abstract class MyEntry implements Entry { void test(Entry e) { this.equals(e); } }
182
17.3
48
java
codeql
codeql-master/java/ql/test/query-tests/TypeMismatch/incomparable_equals/C.java
package incomparable_equals; import java.util.ArrayList; import java.util.LinkedList; public class C { void test(LinkedList<String> ll, ArrayList<String> al) { ll.equals(al); } }
185
15.909091
57
java
codeql
codeql-master/java/ql/test/query-tests/TypeMismatch/remove_type_mismatch/B.java
package remove_type_mismatch; class B<E> { static interface I {} java.util.Collection<I> c; void test(E e) { c.remove(e); } }
136
11.454545
29
java
codeql
codeql-master/java/ql/test/query-tests/TypeMismatch/remove_type_mismatch/A.java
package remove_type_mismatch; import java.util.Collection; public class A { void test1(Collection<StringBuffer> c, String s, StringBuffer b) { c.remove(s); c.remove(b); } void test2(Collection<? extends CharSequence> c, A a, String b) { c.remove(a); c.remove(b); } } interface RunnableList extends Runnable, java.util.List {} class TestB { Collection<? extends Runnable> coll1 = null; Collection<? extends java.util.List> coll2 = null; Collection<RunnableList> coll3; { coll3.remove(""); } } class MyIntList extends java.util.LinkedList<Integer> { public boolean remove(Object o) { return super.remove(o); } } class TestC { MyIntList mil; { mil.remove(""); } } class MyOtherIntList<T> extends java.util.LinkedList<Integer> { public boolean remove(Object o) { return super.remove(o); } } class TestD { MyOtherIntList<Runnable> moil; { moil.remove(""); } }
892
18.844444
67
java
codeql
codeql-master/java/ql/test/query-tests/NonSerializableField/NonSerializableFieldTest.java
import java.io.Serializable; import java.io.Externalizable; import java.util.List; import java.util.Map; import java.util.HashMap; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.ObjectOutput; import java.io.ObjectInput; public class NonSerializableFieldTest { public static class NS{} public static class S implements Serializable{} public static class E implements Externalizable{ public void readExternal(ObjectInput oi){} public void writeExternal(ObjectOutput oo){} } public static class MySerializable<T> implements Serializable{} public static class SerializableBase implements Serializable{} public static class MyColl extends HashMap<Integer, Integer>{} public static class NotSerializable1<T> extends SerializableBase{ NS problematic1; List<NS> problematic2; Map<?, NS> problematic3; Map<NS, ?> problematic4; Map<Integer, Map<?, NS>> problematic5; Map problematic6; List<? extends NS> problematic7; List<? super NS> problematic8; T problematic9; List<T> problematic10; List<?> problematic11; Map<?, ?> problematic12; Map<Integer, Map<?, Double>> problematic13; Map<Integer, ?> problematic14; transient NS ok1; List<Integer> ok2; static NS ok3; S ok4; E ok5; MySerializable<Integer> ok6; MySerializable<?> ok7; MySerializable<T> ok8; MyColl ok9; } public static class NotSerializable2<T> extends SerializableBase{ NS ok1; // the presence of those two methods is usually enough proof that the implementor // deals with the problems (e.g. by throwing NotSerializableException) private void readObject(ObjectInputStream oos){} private void writeObject(ObjectOutputStream oos){} } // annotations usually signal that the implementor is aware of potential problems @SuppressWarnings("serial") public static class NotSerializable3<T> extends SerializableBase{ NS ok1; List<NS> ok2; } // We don't report Externalizable classes, since they completely take over control during // serialization. Furthermore, Externalizable has priority over Serializable! public static class ExternalizableSerializable implements Serializable, Externalizable { NS ok1; public void readExternal(ObjectInput in){ } public void writeExternal(ObjectOutput out){ } } public static interface Anonymous extends Serializable{} public static void main(String[] args){ Anonymous a1 = new Anonymous(){ NS problematic; }; @SuppressWarnings("serial") Anonymous a2 = new Anonymous(){ NS ok; }; } @SuppressWarnings("serial") public static void someAnnotatedMethod(){ Anonymous a = new Anonymous(){ NS ok; }; } // dummy implementations to avoid javax.ejb imports in tests @interface Stateless {} @interface Stateful {} class SessionBean implements Serializable {} class NonSerializableClass {} @Stateless class StatelessSessionEjb extends SessionBean { NonSerializableClass nonSerializableField; } @Stateful class StatefulSessionEjb extends SessionBean { NonSerializableClass nonSerializableField; } enum Enum { A(null); private NonSerializableClass nonSerializable; Enum(NonSerializableClass nonSerializable) { this.nonSerializable = nonSerializable; } } }
3,376
26.680328
91
java
codeql
codeql-master/java/ql/test/query-tests/DeadCode/NonAssignedFields/NonAssignedFieldsTest.java
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; public class NonAssignedFieldsTest { static class Node<T> { volatile Node<?> next; static final AtomicReferenceFieldUpdater<Node,Node> nextUpdater = AtomicReferenceFieldUpdater.newUpdater(Node.class, Node.class, "next"); } { Node<?> node = null; Node<?> next = node.next; } }
360
20.235294
75
java
codeql
codeql-master/java/ql/test/query-tests/EqualsArray/Test.java
public class Test { private final int[] numbers = { 1, 2, 3 }; // NOT OK public boolean areTheseMyNumbers(int[] numbers) { return this.numbers.equals(numbers); } // OK public boolean honestAreTheseMyNumbers(int[] numbers) { return this.numbers == numbers; } // NOT OK, but shouldn't be flagged by this query public boolean incomparable(String s) { return numbers.equals(s); } { numbers.hashCode(); } }
425
18.363636
56
java
codeql
codeql-master/java/ql/test/query-tests/ComplexCondition/ComplexCondition.java
class ComplexCondition { public boolean bad(boolean a, boolean b, boolean c) { if (a && (b || !c) || b && (a || !c) || c && (a || !b)) { return true; } else { return (a && !b) || (b && !c) || (a && !c) || (a && b || c); } } public boolean ok(boolean a, boolean b, boolean c) { if (a && b && c && !a && !b && !c) { return true; } else { return (a && !b) || (b && !c) || (a && !c) || (a && b && c); } } public boolean lengthy(boolean a, boolean b, boolean c) { return ok( new ComplexCondition() { // Imagine there was stuff here... }.ok(a || b, b || c, c || a), new ComplexCondition() { // ... and here ... }.ok(a || b, b || c, c || a), new ComplexCondition() { // ... and here. }.ok(a || b, b || c, c || a) ); } };
853
24.878788
66
java
codeql
codeql-master/java/ql/test/query-tests/PrintLnArray/Test.java
class Test { { // OK: calls PrintStream.println(char[]) System.out.println(new char[] { 'H', 'i' }); // NOT OK: calls PrintStream.println(Object) System.out.println(new byte[0]); } }
192
23.125
46
java
codeql
codeql-master/java/ql/test/query-tests/NonSerializableInnerClass/NonSerializableInnerClassTest.java
import java.io.Serializable; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.ObjectOutput; import java.io.ObjectInput; public class NonSerializableInnerClassTest { public static class S implements Serializable{} public int field; public static class Outer1{ public class Problematic1 implements Serializable{ } public class Problematic2 extends S{ } @SuppressWarnings("serial") public class Ok1 implements Serializable{ } public class Ok2 extends S{ private void readObject(ObjectInputStream oos){} private void writeObject(ObjectOutputStream oos){} } public class Ok3 extends S{ private void writeObject(ObjectOutputStream oos){} } public static class Ok4 extends S{ } public class Ok5 { } // in static contexts enclosing instances don't exist! static{ Serializable ok6 = new Serializable(){ }; } public static Serializable ok7 = new Serializable(){ }; public static void staticMethod(){ Serializable ok8 = new Serializable(){ }; } } public static class Outer2 extends S { public class Ok9 implements Serializable{ } } public class Problematic3 extends S { public class Problematic4 implements Serializable{ } // because NonSerializableInnerClassTest is not serializable } // we currently ignore anonymous classes public void instanceMethod(){ Serializable ok_ish1 = new Serializable(){ public void test(){ Serializable ok_ish2 = new Serializable(){ public void test(){ field = 5; } }; } }; } // the class is not used anywhere, but the serialVersionUID field is an indicator for later serialization private class Problematic7 implements Serializable{ public static final long serialVersionUID = 123; } // the class is not used anywhere private class Ok10 implements Serializable{ } // instantiations of this class are only assigned to non-serializable variables private class Ok11 implements Serializable{ } public void test(){ Object o = new Ok11(); System.out.println(new Ok11()); } }
2,172
24.869048
119
java
codeql
codeql-master/java/ql/test/query-tests/SimplifyBoolExpr/SimplifyBoolExpr.java
class Test { void f(boolean x, boolean y, Boolean a, Boolean b) { boolean w; w = a == false; w = x != true; w = a ? false : b; w = a ? true : false; w = x ? y : true; } void g(int x, int y) { boolean w; w = !(x > y); w = !(x != y); } public Boolean getBool(int i) { if (i > 2) return i == 3 ? true : null; // ok; expression can't be simplified return i == 1 ? false : null; // ok; expression can't be simplified } public Boolean getBoolNPE(int i) { if (i > 2) return i == 3 ? true : ((Boolean)null); // should be reported; both this and the simplified version have equal NPE behavior return i == 1 ? false : ((Boolean)null); // should be reported; both this and the simplified version have equal NPE behavior } }
793
29.538462
129
java
codeql
codeql-master/java/ql/test/query-tests/PointlessForwardingMethod/pointlessforwardingmethod/Test.java
package pointlessforwardingmethod; public class Test { // A method that is only called by a forwarder int addOne(int x, int one) { return x + one; } int addOne(byte x) { return addOne(x, 1); } // A method that is called by a forwarder and also used // in a separate way int addTwo(int x, int two) { return x + two; } int addTwo(byte x) { return addTwo(x, 2); } int addOneTwice(int x) { return addTwo(x, 2); } }
439
15.296296
56
java
codeql
codeql-master/java/ql/test/query-tests/UselessUpcast/Test.java
import java.util.ArrayList; class Super { int x; } class Sub extends Super { int x; } class TestSuper { void baz(Sub s) {} } class Test extends TestSuper { Test(Super o) {} Test(Sub s) { // OK this((Super)s); } { Sub s = null; // OK new Test((Super)s); // NOT OK Super o = (Super)s; // OK foo((Super)s); // NOT OK bar((Super)s); // OK baz((Super)s); // OK ArrayList a = (ArrayList)new ArrayList<Sub>(); // OK int x = ((Super)new Sub()).x; } void foo(Super o) {} void foo(Sub s) {} void bar(Super o) {} void baz(Super o) {} }
575
13.4
48
java
codeql
codeql-master/java/ql/test/query-tests/UselessUpcast/A.java
public class A<X extends A<X>> { private void m() { } private int pi; private void f(X x) { ((A<X>)x).m(); // OK int i = ((A<X>)x).pi; // OK } }
162
15.3
32
java
codeql
codeql-master/java/ql/test/query-tests/UselessUpcast/Test2.java
import java.util.HashMap; import java.util.Map; public class Test2 { public static void main(Sub[] args) { Map<Sub, Super> m = new HashMap<>(); Sub k = null, v = null; m.put(k, (Super) v); m.put(k, v); } }
216
18.727273
38
java
codeql
codeql-master/java/ql/test/query-tests/ConstantExpAppearsNonConstant/Test.java
//Test of ConstantExpAppearsNonConstant.ql import java.util.*; class Test{ public void tester(){ Random rnd = new Random(); int lit = 42; //OK int paren = (9); //OK int plusone = +1; //OK //Multiplication by 0 int mul_not_constant = 42 * 6; //OK int mul_constant_left = 0 * 60 * 60 * 24; //OK int mul_constant_right = 60 * 60 * 24 * 0; //OK int mul_is_not_constant = rnd.nextInt() * 1; //OK int mul_is_constant_int_left = (0+0) * rnd.nextInt(); //NOT OK int mul_is_constant_int_right = rnd.nextInt() * (1-1); //NOT OK long mul_is_constant_hex = rnd.nextLong() * (0x0F & 0xF0); //NOT OK long mul_is_constant_binary = rnd.nextLong() * (0b010101 & 0b101010); //NOT OK int mul_explicit_zero = rnd.nextInt() * 0; //OK (deliberate zero multiplication) //Remainder by 1 int rem_not_constant = 42 % 6; //OK int rem_constant = 60 % 1; //OK int rem_is_not_constant = rnd.nextInt() % 2; //OK int rem_is_constant_int = rnd.nextInt() % 1; //NOT OK double rem_is_constant_float = rnd.nextDouble() % 1; //OK (remainder by 1 on floats is not constant) long rem_is_constant_hex = rnd.nextLong() % 0x1; //NOT OK long rem_is_constant_binary = rnd.nextLong() % 01; //NOT OK //Bitwise 'and' by 0 int band_not_constant = 42 & 6; //OK int band_appears_constant_left = 0 & 60; //OK int band_appears_constant_right = 24 & 0; //OK int band_is_not_constant = rnd.nextInt() & 5; //OK int band_is_constant_left = 0 & rnd.nextInt(); //NOT OK int band_is_constant_right = rnd.nextInt() & 0; //NOT OK //Logical 'and' by false boolean and_not_constant = true && true; //OK boolean and_appears_constant_left = false && true; //OK boolean and_appears_constant_right = true && false; //OK boolean and_is_not_constant = (rnd.nextInt() > 0) && true; //OK boolean and_is_constant_left = false && (rnd.nextInt() > 0); // don't flag (deliberately disabled) boolean and_is_constant_right = (rnd.nextInt() > 0) && false; // don't flag (deliberately disabled) //Logical 'or' by true boolean or_not_constant = false || false; //OK boolean or_appears_constant_left = true || false; //OK boolean or_appears_constant_right = false || true; //OK boolean or_is_not_constant = (rnd.nextInt() > 0) || false; //OK boolean or_is_constant_left = true || (rnd.nextInt() > 0); //NOT OK boolean or_is_constant_right = (rnd.nextInt() > 0) || true; //NOT OK } }
2,355
40.333333
101
java
codeql
codeql-master/java/ql/test/query-tests/UselessComparisonTest/Test.java
class Test { private int z; void test(int x) { z = getInt(); if (x < 0 || z < 0) { throw new Exception(); } int y = 0; if (x >= 0) y++; // useless test due to test in line 5 being false if (z >= 0) y++; // useless test due to test in line 5 being false while(x >= 0) { if (y < 10) { z++; if (y == 15) z++; // useless test due to test in line 12 being true y++; z--; } else if (y > 7) { // useless test due to test in line 12 being false y--; } if (!(y != 5) && z >= 0) { // z >= 0 is always true due to line 5 (and z being increasing) int w = y < 3 ? 0 : 1; // useless test due to test in line 20 being true } x--; } } void test2(int x) { if (x != 0) { int w = x == 0 ? 1 : 2; // useless test due to test in line 27 being true x--; } else if (x == 0) { // useless test due to test in line 27 being false x++; } } int getInt() { return 0; } }
924
24.694444
93
java
codeql
codeql-master/java/ql/test/query-tests/UselessComparisonTest/B.java
import java.util.*; import java.util.function.*; public class B { int modcount = 0; int[] arr; public void modify(IntUnaryOperator func) { int mc = modcount; for (int i = 0; i < arr.length; i++) { arr[i] = func.applyAsInt(arr[i]); } // Always false unless there is a call path from func.applyAsInt(..) to // this method, but should not be reported, as checks guarding // ConcurrentModificationExceptions are expected to always be false in the // absence of API misuse. if (mc != modcount) throw new ConcurrentModificationException(); modcount++; } }
609
25.521739
78
java
codeql
codeql-master/java/ql/test/query-tests/UselessComparisonTest/A.java
import java.util.*; public class A { int getInt() { return new Object().hashCode(); } void unreachable() { } void test(int x, int y) { if (x < 3) { x++; if (x - 1 == 2) return; x--; if (x >= 2) unreachable(); // useless test } if (y > 0) { int z = (x >= 0) ? x : y; if (z < 0) unreachable(); // useless test } int k; while ((k = getInt()) >= 0) { if (k < 0) unreachable(); // useless test } if (x > 0) { int z = x & y; if (!(z <= x)) unreachable(); // useless test } if (x % 2 == 0) { for (int i = 0; i < x; i+=2) { if (i + 1 >= x) unreachable(); // useless test } } int r = new Random().nextInt(x); if (r >= x) unreachable(); // useless test if (x > Math.max(x, y)) unreachable(); // useless test if (x < Math.min(x, y)) unreachable(); // useless test int w; if (x > 7) { w = x + 10; } else if (y > 20) { w = y - 10; } else { w = 14; } w--; w -= 2; if (w <= 5) unreachable(); // useless test while ((w--) > 0) { if (w < 0) unreachable(); // useless test } if (w != -1) unreachable(); // useless test if (x > 20) { int i; for (i = x; i > 0; i--) { } if (i != 0) unreachable(); // useless test } if (getInt() > 0) { int z = y; if (getInt() > 5) { z++; if (z >= 3) return; } else { if (z >= 4) return; } if (z >= 4) unreachable(); // useless test } int length = getInt(); while (length > 0) { int cnt = getInt(); length -= cnt; } for (int i = 0; i < length; ++i) { } // useless test int b = getInt(); if (b > 4) b = 8; if (b > 8) unreachable(); // useless test int sz = getInt(); if (0 < x && x < sz) { while (sz < x) { // useless test - false negative sz <<= 1; } } } void overflowTests(int x, int y) { if (x > 0) { if (y + x <= y) overflow(); int d = x; if ((d += y) <= y) overflow(); } if (x >= 0 && y >= 0) { if (x + y < 0) overflow(); } int ofs = 1; while (ofs < x) { ofs = (ofs << 1) + 1; if (ofs <= 0) { ofs = x; overflow(); } } int sz = getInt(); if (0 < x && 0 < sz) { while (sz < x) { sz <<= 1; if (sz <= 0) overflow(); } } } void overflowTests2(int[] a, boolean b) { int newlen = b ? (a.length + 1) << 1 : (a.length >> 1) + a.length; if (newlen < 0) overflow(); } static final long VAL = 100L; long overflowAwareIncrease(long x) { if (x + VAL > x) { return x + VAL; } else { overflow(); return Long.MAX_VALUE; } } long overflowAwareDecrease(long x) { if (x - VAL < x) { return x - VAL; } else { overflow(); return Long.MIN_VALUE; } } void overflow() { } void unreachableCode() { if (true) return; for (int i = 0; i < 10; i++) { } } }
3,049
18.551282
70
java
codeql
codeql-master/java/ql/test/query-tests/UselessComparisonTest/C.java
public class C { double m1(double x) { return (x < 0 || x > 1 || Double.isNaN(x)) ? Double.NaN : x == 0 ? 0 : x == 1 ? 1 : 0.5; } void m2(double x) { if (x > 0) { double y = 1 - x; if (y > 0) { // OK } } } }
255
16.066667
61
java
codeql
codeql-master/java/ql/test/query-tests/NonSynchronizedOverride/Test.java
class Super { synchronized void quack() { System.out.println("Quack."); } synchronized Super self() { return this; } synchronized void foo() {} void bar() {} } class Sub extends Super { // NOT OK void quack() { super.quack(); super.quack(); } // OK Sub self() { return (Sub)super.self(); } // NOT OK void foo() { super.bar(); } } class A<T> { synchronized void foo() {} } class B extends A<Integer> { // NOT OK void foo() {} } class C extends A<String> { // NOT OK void foo() {} }
524
10.931818
31
java
codeql
codeql-master/java/ql/test/query-tests/ImpossibleCast/impossible_cast/A.java
package impossible_cast; import java.io.Serializable; public class A { { String[] s = (String[])new Object[] { "Hello, world!" }; } { Serializable[] ss = (Object[][])new Serializable[] {}; } }
197
21
61
java
codeql
codeql-master/java/ql/test/query-tests/BoxedVariable/BoxedVariable.java
import java.util.*; class Test { public void f() { Boolean done = false; // bad while (!done) { done = true; } Integer sum = 0; // bad for (int i = 0; i < 10; i++) sum += i; useBoxed(sum); Integer box = 42; // ok; only boxed usages useBoxed(box); Integer badbox = 17; // bad useBoxed(badbox); usePrim(badbox); Integer x = 1; // ok; null is used usePrim(x); x = null; Long y = getPrim(); // bad y = 15L; y = getPrim(); boolean dummy = y > 0; Long z = getPrim(); // ok; has boxed assignment z = 2L; z = getBoxed(); dummy = z > 0; } void forloop(List<Integer> l, int[] a) { int sum = 0; for (Integer okix : l) sum += okix; // ok; has boxed assignment for (Integer badix : a) sum += badix; // bad } void usePrim(int i) { } void useBoxed(Integer i) { } long getPrim() { return 42L; } Long getBoxed() { return 42L; } void overload() { Long x = 4L; // don't report; changing to long would change overload resolution boolean dummy = x > 0; assertEq(x, getBoxed()); } static void assertEq(Object x, Object y) { } static void assertEq(long x, long y) { } }
1,209
19.166667
83
java
codeql
codeql-master/java/ql/test/query-tests/lgtm-example-queries/Test.java
public class Test { int array() { int[] arr = new int[]{1,2,3}; int i = 0; arr[i++] = 4; // arrayaccess.ql return arr[i]; } void test() { // voidreturntype.ql } Object test2() { return null; // returnstatement.ql } }
237
12.222222
36
java
codeql
codeql-master/java/ql/test/query-tests/BadCheckOdd/BadCheckOdd.java
import java.util.Collection; class BadCheckOdd { public boolean goodLiteral() { return 10 % 2 > 0; } public boolean badLiteral() { return -10 % 2 > 0; } public boolean badBrackets1() { return -10 % 2 > (0); } public boolean badBrackets2() { return -10 % (2) > 0;// } public boolean badBrackets3() { return (-10) % 2 > 0; } public boolean badBrackets4() { return (-10 % 2) > 0; } // TODO: support for these cases // public boolean goodVarLiteral() { // int x = 10; // return x % 2 > 0; // } // // public boolean goodVarSize(Collection<String> collection) { // int x = collection.size(); // return x % 2 > 0; // } public boolean goodArrayLength(int[] array) { return array.length % 2 > 0; } public boolean goodStringLength(String string) { return string.length() % 2 > 0; } public boolean badVarLiteral() { int x = -10; return x % 2 > 0; } public boolean badParam(int x) { return x % 2 > 0; } public boolean badSometimes(boolean positive) { int x; if(positive) x = 10; else x = -10; return x % 2 > 0; } private int f; public boolean badField() { return f % 2 >0; } }
1,159
15.571429
62
java
codeql
codeql-master/java/ql/test/query-tests/NonPrivateField/NonPrivateFieldTest.java
import java.util.*; public class NonPrivateFieldTest { public @interface Rule {} // JUnit-like annotation public static class Fields{ public static String problematic1 = "value"; public final int problematic2 = 0; public final int problematic3; final int problematic4 = 9; // omitted access descriptor static int problematic5 = 0; public int problematic6 = 0; protected Double problematic7 = 0.0; // protected but not used in derived classes static int[] problematic8; public static final int ok1 = 0; // public static finals are usually fine, even if not accessed by anything from outside public static int ok2 = 0; // foreign write access protected int ok3 = 1; // read access by sub class @Rule public int ok4; // annotated public members are often accessed via reflection (e.g. JUnit's Rule Annotation) public Fields(){ problematic3 = 0; } public void someAccessorMethod(){ problematic5 = 8; // field access within declaring class does not count as foreign access } } public static class Accessor1 extends Fields{ public Accessor1(){ Fields.ok2 = ok3; // read and write access outside of declaring class } } public static interface IFace{ int ok4 = 0; // interface fields are implicitly public final static } public static enum E{ OK5; // enum constants are implicitly public static final } }
1,590
32.145833
134
java
codeql
codeql-master/java/ql/test/query-tests/MissingSpaceTypo/A.java
public class A { public void missing() { String s; s = "this text" + "is missing a space"; s = "the class java.util.ArrayList" + "without a space"; s = "This isn't" + "right."; s = "There's 1" + "thing wrong"; s = "There's A/B" + "and no space"; s = "Wait for it...." + "No space!"; s = "Is there a space?" + "No!"; } public void ok() { String s; s = "some words%n" + "and more"; s = "some words\n" + "and more"; s = "the class java.util." + "ArrayList"; s = "some data: a,b,c," + "d,e,f"; } }
621
18.4375
41
java
codeql
codeql-master/java/ql/test/query-tests/ContainerSizeCmpZero/Main.java
import java.util.*; public class Main { public static void arrays(String[] args) { // NOT OK: always true if (args.length >= 0) { System.out.println("At least zero arguments!!"); } // NOT OK: always true if (0 <= args.length) { System.out.println("At least zero arguments!!"); } // NOT OK: always false if (args.length < 0) { System.out.println("At least zero arguments!!"); } // NOT OK: always false if (0 > args.length) { System.out.println("At least zero arguments!!"); } // OK: sometimes could be false if (args.length > 0) { System.out.println("Greater than zero arguments!!"); } // OK: sometimes could be false if (0 < args.length) { System.out.println("Greater than zero arguments!!"); } // OK: sometimes could be true if (args.length <= 0) { System.out.println("Greater than zero arguments!!"); } // OK: sometimes could be true if (0 >= args.length) { System.out.println("Greater than zero arguments!!"); } } public static void containers(ArrayList<String> xs, Vector<String> ys) { Boolean b; // NOT OK b = xs.size() >= 0; b = 0 <= xs.size(); b = 0 <= ys.size(); b = xs.size() < 0; b = 0 > ys.size(); // OK b = xs.size() >= -1; // OK b = 0 < xs.size(); } // Slight obfuscations that the query doesn't match currently public static void missedCases(ArrayList<String> xs) { Boolean b; // OK: not currently matched b = xs.size() >= (short)0; b = xs.size() >= (byte)0; b = xs.size() >= 0 + 0; b = xs.size() >= 0 - 0; } public static void nestedContainers(Vector<ArrayList<String>> xs) { Boolean b; // NOT OK b = xs.size() >= 0; b = xs.size() < 0; // NOT OK b = xs.get(0).size() >= 0; // NOT OK b = xs.get(0).get(0).length() >= 0; } public static void mapTests(TreeMap<String, String> xs) { Boolean b; // NOT OK: Always true b = xs.size() >= 0; // NOT OK: Always true b = 0 <= xs.size(); // OK: can be false b = xs.size() >= -1; // OK: can be false b = 0 < xs.size(); } public static void rawTypes(Set s, ArrayList a, HashMap m) { Boolean b; // NOT OK b = s.size() >= 0; b = a.size() >= 0; b = 0 <= m.size(); } }
2,780
22.369748
71
java
codeql
codeql-master/java/ql/test/query-tests/MissingCallToSuperClone/Test.java
class IAmAGoodCloneable implements Cloneable { public Object clone() { return super.clone(); } } class Sub1 extends IAmAGoodCloneable { public Object clone() { return super.clone(); } } class IAmABadCloneable implements Cloneable { public Object clone() { return null; } } class Sub2 extends IAmABadCloneable { public Object clone() { return super.clone(); } } class IMayBeAGoodCloneable implements Cloneable { public native Object clone(); } class Sub3 extends IMayBeAGoodCloneable { public Object clone() { return super.clone(); } }
549
24
91
java
codeql
codeql-master/java/ql/test/query-tests/WriteOnlyContainer/CollectionTest.java
import java.util.*; public class CollectionTest { // should not be flagged since l1 is public public List<Integer> l1 = new ArrayList<Integer>(); // should not be flagged since l2 is a parameter public Set<Integer> m(List<Integer> l2) { l2.add(23); // should not be flagged since it is assigned an existing collection Collection<Integer> l3 = l2; // should not be flagged since it is assigned an existing collection Collection<Integer> l33; l33 = l2; // should not be flagged since it is returned Set<Integer> s1 = new LinkedHashSet<Integer>(); // should not be flagged since it is assigned to another variable List<Integer> l4 = new ArrayList<Integer>(); this.l1 = l4; // should not be flagged since its contents are accessed List<Integer> l5 = new ArrayList<Integer>(); if(!l5.contains(23)) l5.add(23); // should not be flagged since its contents are accessed List<Integer> l6 = new ArrayList<Integer>(); if(!l6.add(23)) return null; return s1; } public void n(Collection<Set<Integer>> ss) { // should not be flagged since it is implicitly assigned an existing collection for (Set<Integer> s : ss) s.add(23); } // should be flagged private List<Integer> useless = new ArrayList<Integer>(); { useless.add(23); useless.remove(0); } // should not be flagged since it is annotated with @SuppressWarnings("unused") @SuppressWarnings("unused") private List<Integer> l7 = new ArrayList<Integer>(); // should not be flagged since it is annotated with a non-standard annotation suggesting reflective access @interface MyReflectionAnnotation {} @MyReflectionAnnotation private List<Integer> l8 = new ArrayList<Integer>(); }
1,697
31.653846
107
java
codeql
codeql-master/java/ql/test/query-tests/WriteOnlyContainer/MapTest.java
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>(); }
1,870
34.980769
107
java
codeql
codeql-master/java/ql/test/query-tests/DoubleCheckedLocking/A.java
public class A { public class B { public int x = 2; public void setX(int x) { this.x = x; } } private String s1; public String getString1() { if (s1 == null) { synchronized(this) { if (s1 == null) { s1 = "string"; // BAD, immutable but read twice outside sync } } } return s1; } private String s2; public String getString2() { String x = s2; if (x == null) { synchronized(this) { x = s2; if (x == null) { x = "string"; // OK, immutable and read once outside sync s2 = x; } } } return x; } private B b1; public B getter1() { B x = b1; if (x == null) { synchronized(this) { if ((x = b1) == null) { b1 = new B(); // BAD, not volatile x = b1; } } } return x; } private volatile B b2; public B getter2() { B x = b2; if (x == null) { synchronized(this) { if ((x = b2) == null) { b2 = new B(); // OK x = b2; System.out.println("OK"); } } } return x; } private volatile B b3; public B getter3() { if (b3 == null) { synchronized(this) { if (b3 == null) { b3 = new B(); b3.x = 7; // BAD, post update init } } } return b3; } private volatile B b4; public B getter4() { if (b4 == null) { synchronized(this) { if (b4 == null) { b4 = new B(); b4.setX(7); // BAD, post update init } } } return b4; } static class FinalHelper<T> { public final T x; public FinalHelper(T x) { this.x = x; } } private FinalHelper<B> b5; public B getter5() { if (b5 == null) { synchronized(this) { if (b5 == null) { B b = new B(); b5 = new FinalHelper<B>(b); // BAD, racy read on b5 outside synchronized-block } } } return b5.x; // Potential NPE here, as the two b5 reads may be reordered } private FinalHelper<B> b6; public B getter6() { FinalHelper<B> a = b6; if (a == null) { synchronized(this) { a = b6; if (a == null) { B b = new B(); a = new FinalHelper<B>(b); b6 = a; // OK, published through final field with a single non-synced read } } } return a.x; } }
2,451
18.307087
88
java
codeql
codeql-master/java/ql/test/query-tests/CloseResource/CloseReader/CloseReader.java
import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; class CloseReader { public static void test1() throws IOException { BufferedReader br = new BufferedReader(new FileReader("C:\\test.txt")); System.out.println(br.readLine()); } public static void test2() throws FileNotFoundException, IOException { BufferedReader br = null; try { br = new BufferedReader(new FileReader("C:\\test.txt")); System.out.println(br.readLine()); } finally { if(br != null) br.close(); // 'br' is closed } } public static void test3() throws IOException { BufferedReader br = null; try { br = new BufferedReader(new FileReader("C:\\test.txt")); System.out.println(br.readLine()); } finally { cleanup(br); // 'br' is closed within a helper method } } public static void test4() throws IOException { InputStreamReader reader = null; try { // InputStreamReader may throw an exception, in which case the ... reader = new InputStreamReader( // ... FileInputStream is not closed by the finally block new FileInputStream("C:\\test.txt"), "UTF-8"); System.out.println(reader.read()); } finally { if (reader != null) reader.close(); } } public static void test5() throws IOException { FileInputStream fis = null; InputStreamReader reader = null; try { fis = new FileInputStream("C:\\test.txt"); reader = new InputStreamReader(fis); System.out.println(reader.read()); } finally { if (fis != null) fis.close(); // 'fis' is closed if (reader != null) reader.close(); // 'reader' is closed } } public static void test6() throws IOException { BufferedReader br = null; try { br = new BufferedReader(new FileReader("C:\\test.txt")); System.out.println(br.readLine()); } finally { cleanup(null, br); // 'br' is closed within a varargs helper method, invoked with multiple args } } public static void cleanup(java.io.Closeable... closeables) throws IOException { for (java.io.Closeable c : closeables) { if (c != null) { c.close(); } } } public static class LogFile { private BufferedReader fileRd; LogFile(String path) { FileReader fr = null; try { fr = new FileReader(path); } catch (FileNotFoundException e) { System.out.println("Error: File not readable: " + path); System.exit(1); } init(fr); } private void init(InputStreamReader reader) { fileRd = new BufferedReader(reader); } public void readStuff() { System.out.println(fileRd.readLine()); fileRd.close(); } } }
2,698
23.761468
98
java
codeql
codeql-master/java/ql/test/query-tests/IgnoreExceptionalReturn/Test.java
import java.io.*; public class Test { public static void main(String[] args) throws IOException { new File("foo").createNewFile(); new File("foo").delete(); // Don't flag: there's usually nothing to do new File("foo").mkdir(); new File("foo").mkdirs(); // Don't flag: the return value is uninformative/misleading new File("foo").renameTo(new File("bar")); new File("foo").setLastModified(0L); new File("foo").setReadOnly(); new File("foo").setWritable(true); } }
482
31.2
87
java
codeql
codeql-master/java/ql/test/query-tests/UnreleasedLock/UnreleasedLock.java
class Test { static class MyLock { void lock() throws RuntimeException { } boolean tryLock() { return true; } void unlock() { } boolean isHeldByCurrentThread() { return true; } } void f() throws RuntimeException { } void g() throws RuntimeException { } MyLock mylock = new MyLock(); void bad1() { mylock.lock(); f(); mylock.unlock(); } void good2() { mylock.lock(); try { f(); } finally { mylock.unlock(); } } void bad3() { mylock.lock(); f(); try { g(); } finally { mylock.unlock(); } } void bad4() { mylock.lock(); try { f(); } finally { g(); mylock.unlock(); } } void bad5(boolean lockmore) { mylock.lock(); try { f(); if (lockmore) { mylock.lock(); } g(); } finally { mylock.unlock(); } } void good6() { if (!mylock.tryLock()) { return; } try { f(); } finally { mylock.unlock(); } } void bad7() { if (!mylock.tryLock()) { return; } f(); mylock.unlock(); } void good7() { try { if (mylock.tryLock()) { return; } } finally { if (mylock.isHeldByCurrentThread()) { mylock.unlock(); } } } void good8() { boolean locked = mylock.tryLock(); if (!locked) { return; } try { f(); } finally { mylock.unlock(); } } }
1,302
12.161616
50
java
codeql
codeql-master/java/ql/test/query-tests/ConstantLoopCondition/A.java
class A { boolean otherCond() { return 3 > 5; } void f(int initx) { boolean done = false; while(!done) { // BAD: main loop condition is constant in the loop if (otherCond()) break; } int x = initx * 2; int i = 0; for(x++; ; i++) { if (x > 5 && otherCond()) { // BAD: x>5 is constant in the loop and guards all exits if (i > 3) break; if (otherCond()) return; } } x = initx; i = 0; while(true) { if (x > 5) break; // OK: more than one exit if (i > 3) break; i++; } for(int j = 0; j < 2 * initx; i++) { // BAD: j<initx is constant in the loop } while(initx > 0) { // OK: loop used as an if-statement break; } } }
740
20.171429
90
java
codeql
codeql-master/java/ql/test/query-tests/WrongNanComparison/Test.java
class Test { void f(double x, float y) { if (x == Double.NaN) return; if (y == Float.NaN) return; } }
114
15.428571
32
java
codeql
codeql-master/java/ql/test/query-tests/InconsistentEqualsHashCode/Test.java
class Super { protected int myInt = 1; public boolean equals(Object other) { if (other == null) return false; if (other.getClass() != getClass()) return false; if (myInt != ((Super)other).myInt) return false; return true; } public int hashCode() { return myInt; } } class NoEquals extends Super { // BAD public int hashCode() { return myInt+1; } } class NoHashCode extends Super { // BAD public boolean equals(Object other) { return true; } } class RefiningEquals extends Super { protected long myLong = 1; // OK: a finer equals than the supertype equals, so the hash code is still valid public boolean equals(Object other) { return (super.equals(other) && myLong == ((RefiningEquals)other).myLong); } }
751
17.8
81
java
codeql
codeql-master/java/ql/test/query-tests/UnreadLocal/A.java
public class A { public long ex1(int i, int w1, int w2, int w3, long[][][] bits) { long nword = ~0L << i; long[][] a2; long[] a3; if (w1 < 42 && (a2 = bits[w1]) != null && (a3 = a2[w2]) != null && ((nword = ~a3[w3] & (~0L << i))) == 0L) { w3 = 7; w2 = 5; w1 = 3; loop: for (; w1 != 42; ++w1) { if ((a2 = bits[w1]) != null) for (; w2 != 42; ++w2) { if ((a3 = a2[w2]) != null) for (; w3 != 42; ++w3) if ((nword = ~a3[w3]) != 0) break loop; w3 = 0; } w2 = w3 = 0; } } return (((w1 << 3) + (w2 << 3) + w3) << 3) + nword; } public void ex2() { for (int i = 0; i < 5; i++) { int x = 42; x = x + 3; // DEAD } } public int ex3(int param) { param += 3; // DEAD param = 4; int x = 7; ++x; // DEAD x = 10; int y = 5; y = (++y) + 5; // DEAD (++y) return x + y + param; } public void ex4() { boolean exc; exc = true; // OK try { new Object(); exc = false; } finally { if (exc) { ex3(0); } } int x; try { x = 5; // DEAD ex3(0); x = 7; ex3(x); } catch (Exception e) { } boolean valid; try { if (ex3(4) > 4) { valid = false; // DEAD } ex3(0); valid = true; } catch(Exception e) { valid = false; } if (valid) return; } // ensure extraction of java.lang.RuntimeException public void noop() throws RuntimeException { } }
1,974
24.649351
69
java
codeql
codeql-master/java/ql/test/query-tests/UnreadLocal/UnreadLocal/ImplicitReads.java
package test; public class ImplicitReads { private static class B implements AutoCloseable { long time = 123; @Override public void close () { System.out.println("Closing at time " + time); } } public void test() { // Not flagged due to implicit read in finally block try (B b = new B()) { System.out.println("test"); } // Not flagged due to implicit read in finally block try (B b = null) {} } public void test2(B b) { if (b.time > 3) { System.out.println("test"); } B c = null; if (c == null) { System.out.println("test"); } // Assignment is useless c = b; // Not flagged due to implicit read in implicit finally block try(B d = b) {} } }
771
16.953488
65
java
codeql
codeql-master/java/ql/test/query-tests/UnreadLocal/UnreadLocal/UnreadLocals.java
package test; public class UnreadLocals { public static class Something { int x; } public Something something; public int alpha; int beta; private int gamma; public UnreadLocals () { int alpha = 2; int _beta = 4; this.alpha = 3; beta = _beta; Something something1 = new Something(); Something something2 = new Something(); something = something1; gamma = -1; something = makeSomething(); makeSomething(); } private static Something makeSomething () { return new Something(); } }
606
14.564103
43
java
codeql
codeql-master/java/ql/test/query-tests/NumberFormatException/Test.java
import java.io.*; public class Test { public static void main(String[] args) { test1(); test2(); test3(); } static void test1() { Byte.parseByte("123"); Byte.decode("123"); Byte.valueOf("123"); Byte.valueOf("123", 10); Byte.valueOf("7f", 16); new Byte("123"); new Byte((byte) 123); // don't flag: wrong constructor Short.parseShort("123"); Short.decode("123"); Short.valueOf("123"); Short.valueOf("123", 10); Short.valueOf("7abc", 16); new Short("123"); new Short((short) 123); // don't flag: wrong constructor Integer.parseInt("123"); Integer.decode("123"); Integer.valueOf("123"); Integer.valueOf("123", 10); Integer.valueOf("1234beef", 16); new Integer("123"); new Integer(123); // don't flag: wrong constructor Long.parseLong("123"); Long.decode("123"); Long.valueOf("123"); Long.valueOf("123", 10); Long.valueOf("deadbeef", 16); new Long("123"); new Long(123l); // don't flag: wrong constructor Float.parseFloat("2.7818281828"); Float.valueOf("2.7818281828"); new Float("2.7818281828"); new Float(2.7818281828f); // don't flag: wrong constructor Double.parseDouble("2.7818281828"); Double.valueOf("2.7818281828"); new Double("2.7818281828"); new Double(2.7818281828); // don't flag: wrong constructor } static void test2() { // Don't flag any of these. The exception is caught. try { Byte.parseByte("123"); Byte.decode("123"); Byte.valueOf("123"); Byte.valueOf("123", 10); Byte.valueOf("7f", 16); new Byte("123"); Short.parseShort("123"); Short.decode("123"); Short.valueOf("123"); Short.valueOf("123", 10); Short.valueOf("7abc", 16); new Short("123"); Integer.parseInt("123"); Integer.decode("123"); Integer.valueOf("123"); Integer.valueOf("123", 10); Integer.valueOf("1234beef", 16); new Integer("123"); Long.parseLong("123"); Long.decode("123"); Long.valueOf("123"); Long.valueOf("123", 10); Long.valueOf("deadbeef", 16); new Long("123"); Float.parseFloat("2.7818281828"); Float.valueOf("2.7818281828"); new Float("2.7818281828"); Double.parseDouble("2.7818281828"); Double.valueOf("2.7818281828"); new Double("2.7818281828"); } catch (NumberFormatException e) { // parse error } } static void test3() throws NumberFormatException { // Don't flag any of these: the exception is explcitly declared Byte.parseByte("123"); Byte.decode("123"); Byte.valueOf("123"); Byte.valueOf("123", 10); Byte.valueOf("7f", 16); new Byte("123"); Short.parseShort("123"); Short.decode("123"); Short.valueOf("123"); Short.valueOf("123", 10); Short.valueOf("7abc", 16); new Short("123"); Integer.parseInt("123"); Integer.decode("123"); Integer.valueOf("123"); Integer.valueOf("123", 10); Integer.valueOf("1234beef", 16); new Integer("123"); Long.parseLong("123"); Long.decode("123"); Long.valueOf("123"); Long.valueOf("123", 10); Long.valueOf("deadbeef", 16); new Long("123"); Float.parseFloat("2.7818281828"); Float.valueOf("2.7818281828"); new Float("2.7818281828"); Double.parseDouble("2.7818281828"); Double.valueOf("2.7818281828"); new Double("2.7818281828"); } }
3,978
28.043796
71
java
codeql
codeql-master/java/ql/test/stubs/apache-ldap-1.0.2/org/apache/directory/api/ldap/model/entry/Value.java
package org.apache.directory.api.ldap.model.entry; public interface Value<T> { }
82
15.6
50
java
codeql
codeql-master/java/ql/test/stubs/apache-ldap-1.0.2/org/apache/directory/api/ldap/model/exception/LdapInvalidDnException.java
package org.apache.directory.api.ldap.model.exception; public class LdapInvalidDnException extends LdapException { }
118
22.8
59
java
codeql
codeql-master/java/ql/test/stubs/apache-ldap-1.0.2/org/apache/directory/api/ldap/model/exception/LdapException.java
package org.apache.directory.api.ldap.model.exception; public class LdapException extends Exception { }
105
20.2
54
java
codeql
codeql-master/java/ql/test/stubs/apache-ldap-1.0.2/org/apache/directory/api/ldap/model/filter/EqualityNode.java
package org.apache.directory.api.ldap.model.filter; import org.apache.directory.api.ldap.model.entry.Value; public class EqualityNode<T> implements ExprNode { public EqualityNode(String attribute, Value<T> value) { } public EqualityNode(String attribute, String value) { } }
281
30.333333
59
java
codeql
codeql-master/java/ql/test/stubs/apache-ldap-1.0.2/org/apache/directory/api/ldap/model/filter/ExprNode.java
package org.apache.directory.api.ldap.model.filter; public interface ExprNode { }
83
15.8
51
java
codeql
codeql-master/java/ql/test/stubs/apache-ldap-1.0.2/org/apache/directory/api/ldap/model/name/Dn.java
package org.apache.directory.api.ldap.model.name; import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException; public class Dn { public Dn(String... upRdns) throws LdapInvalidDnException { } public String getName() { return null; } }
256
27.555556
76
java
codeql
codeql-master/java/ql/test/stubs/apache-ldap-1.0.2/org/apache/directory/api/ldap/model/cursor/EntryCursor.java
package org.apache.directory.api.ldap.model.cursor; public interface EntryCursor { }
86
16.4
51
java
codeql
codeql-master/java/ql/test/stubs/apache-ldap-1.0.2/org/apache/directory/api/ldap/model/cursor/SearchCursor.java
package org.apache.directory.api.ldap.model.cursor; public interface SearchCursor { }
87
16.6
51
java
codeql
codeql-master/java/ql/test/stubs/apache-ldap-1.0.2/org/apache/directory/api/ldap/model/message/SearchRequestImpl.java
package org.apache.directory.api.ldap.model.message; import org.apache.directory.api.ldap.model.exception.LdapException; import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.api.ldap.model.filter.ExprNode; public class SearchRequestImpl implements SearchRequest { public Dn getBase() { return null; } public SearchRequest setBase(Dn baseDn) { return null; } public SearchRequest setFilter(ExprNode filter) { return null; } public SearchRequest setFilter(String filter) throws LdapException { return null; } }
546
41.076923
85
java
codeql
codeql-master/java/ql/test/stubs/apache-ldap-1.0.2/org/apache/directory/api/ldap/model/message/SearchRequest.java
package org.apache.directory.api.ldap.model.message; import org.apache.directory.api.ldap.model.exception.LdapException; import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.api.ldap.model.filter.ExprNode; public interface SearchRequest { Dn getBase(); SearchRequest setBase(Dn baseDn); SearchRequest setFilter(ExprNode filter); SearchRequest setFilter(String filter) throws LdapException; }
429
32.076923
67
java
codeql
codeql-master/java/ql/test/stubs/apache-ldap-1.0.2/org/apache/directory/api/ldap/model/message/SearchScope.java
package org.apache.directory.api.ldap.model.message; public enum SearchScope { }
82
15.6
52
java
codeql
codeql-master/java/ql/test/stubs/apache-ldap-1.0.2/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
package org.apache.directory.ldap.client.api; import org.apache.directory.api.ldap.model.exception.LdapException; import org.apache.directory.api.ldap.model.cursor.EntryCursor; import org.apache.directory.api.ldap.model.cursor.SearchCursor; import org.apache.directory.api.ldap.model.message.SearchRequest; import org.apache.directory.api.ldap.model.message.SearchScope; import org.apache.directory.api.ldap.model.name.Dn; public class LdapNetworkConnection implements LdapConnection { public SearchCursor search(SearchRequest searchRequest) throws LdapException { return null; } public EntryCursor search(String baseDn, String filter, SearchScope scope, String... attributes) throws LdapException { return null; } public EntryCursor search(Dn baseDn, String filter, SearchScope scope, String... attributes) throws LdapException { return null; } }
858
49.529412
136
java
codeql
codeql-master/java/ql/test/stubs/apache-ldap-1.0.2/org/apache/directory/ldap/client/api/LdapConnection.java
package org.apache.directory.ldap.client.api; import org.apache.directory.api.ldap.model.exception.LdapException; import org.apache.directory.api.ldap.model.cursor.EntryCursor; import org.apache.directory.api.ldap.model.cursor.SearchCursor; import org.apache.directory.api.ldap.model.message.SearchRequest; import org.apache.directory.api.ldap.model.message.SearchScope; import org.apache.directory.api.ldap.model.name.Dn; public interface LdapConnection { SearchCursor search(SearchRequest searchRequest) throws LdapException; EntryCursor search(String baseDn, String filter, SearchScope scope, String... attributes) throws LdapException; EntryCursor search(Dn baseDn, String filter, SearchScope scope, String... attributes) throws LdapException; }
761
41.333333
113
java
codeql
codeql-master/java/ql/test/stubs/springframework-5.2.3/org/springframework/core/io/ResourceLoader.java
package org.springframework.core.io; public interface ResourceLoader {}
73
17.5
36
java
codeql
codeql-master/java/ql/test/stubs/springframework-5.2.3/org/springframework/core/io/InputStreamSource.java
/* * Copyright 2002-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.springframework.core.io; import java.io.IOException; import java.io.InputStream; /** * Simple interface for objects that are sources for an {@link InputStream}. * * <p>This is the base interface for Spring's more extensive {@link Resource} interface. * * <p>For single-use streams, {@link InputStreamResource} can be used for any * given {@code InputStream}. Spring's {@link ByteArrayResource} or any * file-based {@code Resource} implementation can be used as a concrete * instance, allowing one to read the underlying content stream multiple times. * This makes this interface useful as an abstract content source for mail * attachments, for example. * * @author Juergen Hoeller * @since 20.01.2004 * @see java.io.InputStream * @see Resource * @see InputStreamResource * @see ByteArrayResource */ public interface InputStreamSource { /** * Return an {@link InputStream} for the content of an underlying resource. * <p>It is expected that each call creates a <i>fresh</i> stream. * <p>This requirement is particularly important when you consider an API such * as JavaMail, which needs to be able to read the stream multiple times when * creating mail attachments. For such a use case, it is <i>required</i> * that each {@code getInputStream()} call returns a fresh stream. * @return the input stream for the underlying resource (must not be {@code null}) * @throws java.io.FileNotFoundException if the underlying resource doesn't exist * @throws IOException if the content stream could not be opened */ InputStream getInputStream() throws IOException; }
2,234
38.210526
88
java
codeql
codeql-master/java/ql/test/stubs/springframework-5.2.3/org/springframework/core/io/Resource.java
/* * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.springframework.core.io; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.URI; import java.net.URL; import java.nio.channels.Channels; import java.nio.channels.ReadableByteChannel; import org.springframework.lang.Nullable; /** * Interface for a resource descriptor that abstracts from the actual * type of underlying resource, such as a file or class path resource. * * <p>An InputStream can be opened for every resource if it exists in * physical form, but a URL or File handle can just be returned for * certain resources. The actual behavior is implementation-specific. * * @author Juergen Hoeller * @since 28.12.2003 * @see #getInputStream() * @see #getURL() * @see #getURI() * @see #getFile() * @see WritableResource * @see ContextResource * @see UrlResource * @see FileUrlResource * @see FileSystemResource * @see ClassPathResource * @see ByteArrayResource * @see InputStreamResource */ public interface Resource extends InputStreamSource { /** * Determine whether this resource actually exists in physical form. * <p>This method performs a definitive existence check, whereas the * existence of a {@code Resource} handle only guarantees a valid * descriptor handle. */ boolean exists(); /** * Indicate whether non-empty contents of this resource can be read via * {@link #getInputStream()}. * <p>Will be {@code true} for typical resource descriptors that exist * since it strictly implies {@link #exists()} semantics as of 5.1. * Note that actual content reading may still fail when attempted. * However, a value of {@code false} is a definitive indication * that the resource content cannot be read. * @see #getInputStream() * @see #exists() */ default boolean isReadable() { return exists(); } /** * Indicate whether this resource represents a handle with an open stream. * If {@code true}, the InputStream cannot be read multiple times, * and must be read and closed to avoid resource leaks. * <p>Will be {@code false} for typical resource descriptors. */ default boolean isOpen() { return false; } /** * Determine whether this resource represents a file in a file system. * A value of {@code true} strongly suggests (but does not guarantee) * that a {@link #getFile()} call will succeed. * <p>This is conservatively {@code false} by default. * @since 5.0 * @see #getFile() */ default boolean isFile() { return false; } /** * Return a URL handle for this resource. * @throws IOException if the resource cannot be resolved as URL, * i.e. if the resource is not available as descriptor */ URL getURL() throws IOException; /** * Return a URI handle for this resource. * @throws IOException if the resource cannot be resolved as URI, * i.e. if the resource is not available as descriptor * @since 2.5 */ URI getURI() throws IOException; /** * Return a File handle for this resource. * @throws java.io.FileNotFoundException if the resource cannot be resolved as * absolute file path, i.e. if the resource is not available in a file system * @throws IOException in case of general resolution/reading failures * @see #getInputStream() */ File getFile() throws IOException; /** * Return a {@link ReadableByteChannel}. * <p>It is expected that each call creates a <i>fresh</i> channel. * <p>The default implementation returns {@link Channels#newChannel(InputStream)} * with the result of {@link #getInputStream()}. * @return the byte channel for the underlying resource (must not be {@code null}) * @throws java.io.FileNotFoundException if the underlying resource doesn't exist * @throws IOException if the content channel could not be opened * @since 5.0 * @see #getInputStream() */ default ReadableByteChannel readableChannel() throws IOException { return Channels.newChannel(getInputStream()); } /** * Determine the content length for this resource. * @throws IOException if the resource cannot be resolved * (in the file system or as some other known physical resource type) */ long contentLength() throws IOException; /** * Determine the last-modified timestamp for this resource. * @throws IOException if the resource cannot be resolved * (in the file system or as some other known physical resource type) */ long lastModified() throws IOException; /** * Create a resource relative to this resource. * @param relativePath the relative path (relative to this resource) * @return the resource handle for the relative resource * @throws IOException if the relative resource cannot be determined */ Resource createRelative(String relativePath) throws IOException; /** * Determine a filename for this resource, i.e. typically the last * part of the path: for example, "myfile.txt". * <p>Returns {@code null} if this type of resource does not * have a filename. */ @Nullable String getFilename(); /** * Return a description for this resource, * to be used for error output when working with the resource. * <p>Implementations are also encouraged to return this value * from their {@code toString} method. * @see Object#toString() */ String getDescription(); }
5,870
31.798883
83
java
codeql
codeql-master/java/ql/test/stubs/springframework-5.2.3/org/springframework/core/io/support/ResourcePatternResolver.java
package org.springframework.core.io.support; import org.springframework.core.io.ResourceLoader; public interface ResourcePatternResolver extends ResourceLoader {}
165
26.666667
66
java
codeql
codeql-master/java/ql/test/stubs/springframework-5.2.3/org/springframework/core/env/EnvironmentCapable.java
package org.springframework.core.env; public interface EnvironmentCapable {}
78
18.75
38
java
codeql
codeql-master/java/ql/test/stubs/springframework-5.2.3/org/springframework/security/config/Customizer.java
package org.springframework.security.config; @FunctionalInterface public interface Customizer<T> { void customize(T t); }
125
17
44
java
codeql
codeql-master/java/ql/test/stubs/springframework-5.2.3/org/springframework/security/config/annotation/SecurityConfigurerAdapter.java
package org.springframework.security.config.annotation; public abstract class SecurityConfigurerAdapter<O, B extends SecurityBuilder<O>> implements SecurityConfigurer<O, B> {}
179
35
80
java
codeql
codeql-master/java/ql/test/stubs/springframework-5.2.3/org/springframework/security/config/annotation/SecurityConfigurer.java
package org.springframework.security.config.annotation; public interface SecurityConfigurer<O, B extends SecurityBuilder<O>> {}
129
31.5
71
java
codeql
codeql-master/java/ql/test/stubs/springframework-5.2.3/org/springframework/security/config/annotation/AbstractSecurityBuilder.java
package org.springframework.security.config.annotation; public abstract class AbstractSecurityBuilder<O> implements SecurityBuilder<O> {}
139
34
81
java
codeql
codeql-master/java/ql/test/stubs/springframework-5.2.3/org/springframework/security/config/annotation/SecurityBuilder.java
package org.springframework.security.config.annotation; public interface SecurityBuilder<O> {}
96
23.25
55
java
codeql
codeql-master/java/ql/test/stubs/springframework-5.2.3/org/springframework/security/config/annotation/AbstractConfiguredSecurityBuilder.java
package org.springframework.security.config.annotation; public abstract class AbstractConfiguredSecurityBuilder<O, B extends SecurityBuilder<O>> extends AbstractSecurityBuilder<O> {}
186
36.4
88
java
codeql
codeql-master/java/ql/test/stubs/springframework-5.2.3/org/springframework/security/config/annotation/web/AbstractRequestMatcherRegistry.java
package org.springframework.security.config.annotation.web; import org.springframework.security.web.util.matcher.RequestMatcher; public abstract class AbstractRequestMatcherRegistry<C> { public C anyRequest() { return null; } public C requestMatchers(RequestMatcher... requestMatchers) { return null; } }
323
22.142857
68
java
codeql
codeql-master/java/ql/test/stubs/springframework-5.2.3/org/springframework/security/config/annotation/web/HttpSecurityBuilder.java
package org.springframework.security.config.annotation.web; import org.springframework.security.config.annotation.SecurityBuilder; import org.springframework.security.web.DefaultSecurityFilterChain; public interface HttpSecurityBuilder<H extends HttpSecurityBuilder<H>> extends SecurityBuilder<DefaultSecurityFilterChain> {}
329
40.25
78
java
codeql
codeql-master/java/ql/test/stubs/springframework-5.2.3/org/springframework/security/config/annotation/web/configurers/AbstractInterceptUrlConfigurer.java
package org.springframework.security.config.annotation.web.configurers; import org.springframework.security.config.annotation.web.HttpSecurityBuilder; abstract class AbstractInterceptUrlConfigurer<C extends AbstractInterceptUrlConfigurer<C, H>, H extends HttpSecurityBuilder<H>> extends AbstractHttpConfigurer<C, H> { abstract class AbstractInterceptUrlRegistry<R extends AbstractInterceptUrlRegistry<R, T>, T> extends AbstractConfigAttributeRequestMatcherRegistry<T> { } }
483
43
127
java
codeql
codeql-master/java/ql/test/stubs/springframework-5.2.3/org/springframework/security/config/annotation/web/configurers/AbstractHttpConfigurer.java
package org.springframework.security.config.annotation.web.configurers; import org.springframework.security.config.annotation.SecurityConfigurerAdapter; import org.springframework.security.config.annotation.web.HttpSecurityBuilder; import org.springframework.security.web.DefaultSecurityFilterChain; public abstract class AbstractHttpConfigurer<T extends AbstractHttpConfigurer<T, B>, B extends HttpSecurityBuilder<B>> extends SecurityConfigurerAdapter<DefaultSecurityFilterChain, B> {}
491
53.666667
118
java
codeql
codeql-master/java/ql/test/stubs/springframework-5.2.3/org/springframework/security/config/annotation/web/configurers/AbstractConfigAttributeRequestMatcherRegistry.java
package org.springframework.security.config.annotation.web.configurers; import org.springframework.security.config.annotation.web.AbstractRequestMatcherRegistry; public abstract class AbstractConfigAttributeRequestMatcherRegistry<C> extends AbstractRequestMatcherRegistry<C> {}
282
39.428571
89
java
codeql
codeql-master/java/ql/test/stubs/springframework-5.2.3/org/springframework/security/config/annotation/web/configurers/ExpressionUrlAuthorizationConfigurer.java
package org.springframework.security.config.annotation.web.configurers; import org.springframework.security.config.annotation.web.HttpSecurityBuilder; public final class ExpressionUrlAuthorizationConfigurer<H extends HttpSecurityBuilder<H>> extends AbstractInterceptUrlConfigurer<ExpressionUrlAuthorizationConfigurer<H>, H> { public class ExpressionInterceptUrlRegistry extends ExpressionUrlAuthorizationConfigurer<H>.AbstractInterceptUrlRegistry<ExpressionInterceptUrlRegistry, AuthorizedUrl> { } public class AuthorizedUrl { public ExpressionInterceptUrlRegistry permitAll() { return null; } } }
617
35.352941
120
java
codeql
codeql-master/java/ql/test/stubs/springframework-5.2.3/org/springframework/security/config/annotation/web/builders/HttpSecurity.java
package org.springframework.security.config.annotation.web.builders; import org.springframework.security.config.annotation.AbstractConfiguredSecurityBuilder; import org.springframework.security.config.annotation.SecurityBuilder; import org.springframework.security.config.annotation.web.HttpSecurityBuilder; import org.springframework.security.web.DefaultSecurityFilterChain; import org.springframework.security.web.util.matcher.RequestMatcher; import org.springframework.security.config.Customizer; import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer; import org.springframework.security.config.annotation.web.AbstractRequestMatcherRegistry; public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<DefaultSecurityFilterChain, HttpSecurity> implements SecurityBuilder<DefaultSecurityFilterChain>, HttpSecurityBuilder<HttpSecurity> { public HttpSecurity requestMatcher(RequestMatcher requestMatcher) { return this; } public HttpSecurity authorizeRequests( Customizer<ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry> authorizeRequestsCustomizer) throws Exception { return this; } public ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry authorizeRequests() throws Exception { return null; } public HttpSecurity requestMatchers(Customizer<RequestMatcherConfigurer> requestMatcherCustomizer) { return this; } public RequestMatcherConfigurer requestMatchers() { return null; } public final class MvcMatchersRequestMatcherConfigurer extends RequestMatcherConfigurer { } public class RequestMatcherConfigurer extends AbstractRequestMatcherRegistry<RequestMatcherConfigurer> { } }
1,756
38.931818
125
java
codeql
codeql-master/java/ql/test/stubs/springframework-5.2.3/org/springframework/security/web/SecurityFilterChain.java
package org.springframework.security.web; public interface SecurityFilterChain {}
83
20
41
java
codeql
codeql-master/java/ql/test/stubs/springframework-5.2.3/org/springframework/security/web/DefaultSecurityFilterChain.java
package org.springframework.security.web; public final class DefaultSecurityFilterChain implements SecurityFilterChain {}
123
30
79
java
codeql
codeql-master/java/ql/test/stubs/springframework-5.2.3/org/springframework/security/web/util/matcher/RequestMatcher.java
package org.springframework.security.web.util.matcher; public interface RequestMatcher {}
91
22
54
java
codeql
codeql-master/java/ql/test/stubs/springframework-5.2.3/org/springframework/lang/Nullable.java
/* * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.springframework.lang; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * A common Spring annotation to declare that annotated elements can be {@code null} under * some circumstance. * * <p>Leverages JSR-305 meta-annotations to indicate nullability in Java to common * tools with JSR-305 support and used by Kotlin to infer nullability of Spring API. * * <p>Should be used at parameter, return value, and field level. Methods override should * repeat parent {@code @Nullable} annotations unless they behave differently. * * <p>Can be used in association with {@code @NonNullApi} or {@code @NonNullFields} to * override the default non-nullable semantic to nullable. * * @author Sebastien Deleuze * @author Juergen Hoeller * @since 5.0 * @see NonNullApi * @see NonNullFields * @see NonNull */ @Target({ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) @Documented public @interface Nullable { }
1,754
34.1
90
java
codeql
codeql-master/java/ql/test/stubs/springframework-5.2.3/org/springframework/expression/Expression.java
package org.springframework.expression; public interface Expression { Object getValue() throws EvaluationException; Object getValue(EvaluationContext context) throws EvaluationException; Class<?> getValueType() throws EvaluationException; Class<?> getValueType(EvaluationContext context) throws EvaluationException; void setValue(Object rootObject, Object value) throws EvaluationException; }
403
27.857143
77
java
codeql
codeql-master/java/ql/test/stubs/springframework-5.2.3/org/springframework/expression/EvaluationException.java
package org.springframework.expression; public class EvaluationException extends RuntimeException {}
101
33
60
java
codeql
codeql-master/java/ql/test/stubs/springframework-5.2.3/org/springframework/expression/ExpressionParser.java
package org.springframework.expression; public interface ExpressionParser { Expression parseExpression(String string); }
126
20.166667
46
java
codeql
codeql-master/java/ql/test/stubs/springframework-5.2.3/org/springframework/expression/EvaluationContext.java
package org.springframework.expression; public interface EvaluationContext {}
78
25.333333
39
java
codeql
codeql-master/java/ql/test/stubs/springframework-5.2.3/org/springframework/expression/spel/support/SimpleEvaluationContext.java
package org.springframework.expression.spel.support; import org.springframework.expression.*; public class SimpleEvaluationContext implements EvaluationContext { public static Builder forReadWriteDataBinding() { return null; } public static class Builder { public SimpleEvaluationContext build() { return null; } } }
345
25.615385
68
java
codeql
codeql-master/java/ql/test/stubs/springframework-5.2.3/org/springframework/expression/spel/support/StandardEvaluationContext.java
package org.springframework.expression.spel.support; import org.springframework.expression.*; public class StandardEvaluationContext implements EvaluationContext {}
166
32.4
70
java
codeql
codeql-master/java/ql/test/stubs/springframework-5.2.3/org/springframework/expression/spel/standard/SpelExpressionParser.java
package org.springframework.expression.spel.standard; import org.springframework.expression.*; public class SpelExpressionParser implements ExpressionParser { public SpelExpressionParser() {} public Expression parseExpression(String string) { return null; } }
275
26.6
69
java
codeql
codeql-master/java/ql/test/stubs/springframework-5.2.3/org/springframework/web/bind/annotation/RequestParam.java
package org.springframework.web.bind.annotation; import java.lang.annotation.*; @Target(value=ElementType.PARAMETER) @Retention(value=RetentionPolicy.RUNTIME) @Documented public @interface RequestParam { }
208
22.222222
48
java
codeql
codeql-master/java/ql/test/stubs/springframework-5.2.3/org/springframework/web/bind/annotation/RequestMapping.java
package org.springframework.web.bind.annotation; import java.lang.annotation.*; @Target(value={ElementType.METHOD,ElementType.TYPE}) @Retention(value=RetentionPolicy.RUNTIME) @Documented public @interface RequestMapping { }
226
24.222222
52
java
codeql
codeql-master/java/ql/test/stubs/springframework-5.2.3/org/springframework/web/context/WebApplicationContext.java
package org.springframework.web.context; import org.springframework.context.ApplicationContext; public interface WebApplicationContext extends ApplicationContext {}
167
27
68
java
codeql
codeql-master/java/ql/test/stubs/springframework-5.2.3/org/springframework/web/multipart/MultipartRequest.java
/* * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.springframework.web.multipart; import java.util.Iterator; import java.util.List; import java.util.Map; import org.springframework.lang.Nullable; import org.springframework.util.MultiValueMap; /** * This interface defines the multipart request access operations that are exposed * for actual multipart requests. It is extended by {@link MultipartHttpServletRequest}. * * @author Juergen Hoeller * @author Arjen Poutsma * @since 2.5.2 */ public interface MultipartRequest { /** * Return an {@link java.util.Iterator} of String objects containing the * parameter names of the multipart files contained in this request. These * are the field names of the form (like with normal parameters), not the * original file names. * @return the names of the files */ Iterator<String> getFileNames(); /** * Return the contents plus description of an uploaded file in this request, * or {@code null} if it does not exist. * @param name a String specifying the parameter name of the multipart file * @return the uploaded content in the form of a {@link MultipartFile} object */ @Nullable MultipartFile getFile(String name); /** * Return the contents plus description of uploaded files in this request, * or an empty list if it does not exist. * @param name a String specifying the parameter name of the multipart file * @return the uploaded content in the form of a {@link MultipartFile} list * @since 3.0 */ List<MultipartFile> getFiles(String name); /** * Return a {@link java.util.Map} of the multipart files contained in this request. * @return a map containing the parameter names as keys, and the * {@link MultipartFile} objects as values */ Map<String, MultipartFile> getFileMap(); /** * Return a {@link MultiValueMap} of the multipart files contained in this request. * @return a map containing the parameter names as keys, and a list of * {@link MultipartFile} objects as values * @since 3.0 */ MultiValueMap<String, MultipartFile> getMultiFileMap(); /** * Determine the content type of the specified request part. * @param paramOrFileName the name of the part * @return the associated content type, or {@code null} if not defined * @since 3.1 */ @Nullable String getMultipartContentType(String paramOrFileName); }
2,936
32.375
88
java