Summary: In D17156724, we forked nullsafe tests, which was a strategy to introduce nullsafe-gradual mode back then. The reason was "gradual" mode is a pretty big change in a way Infer handles annotations, so we wanted to tests both scenarios: gradual and non-gradual mode. The plan was to deprecate "non-gradual" tests at some point, hence we decided to go with duplication. Now we have a better approach to ensure "gradual" features are well covered. The approach is the following. 1. [Mostly finished] Improve existings tests so that they cover negative and positive cases. With this, we can safely add something like --non-annotated-default UNKNOWN_NULLABILITY to the test config and be sure tests still make sense (i.e. don't pass simply because annotations don't make sense anymore) 2. [In progress]. Refactor nullsafe code so that instead of using of Annot.ml everywhere we use a special abstraction telling if the class is annotated with Nullable, Nonnull, or not annotated. With this change, we essenstially have a single place we need to test, which removes the need to have 2 pair of tests for each feature. 3. [To be done]. Introduce Uknown nullability and add small number of tests specifically for that feature (together with existing tests). NOTE: I did not rename `nullsafe-default` back to `nullsafe` to not pollute blame without need. Reviewed By: artempyanykh Differential Revision: D17395743 fbshipit-source-id: 3d3e062f6master
parent
b6c3f40ab0
commit
4f8629727e
@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"external-java-packages": [
|
|
||||||
"external."
|
|
||||||
],
|
|
||||||
"nullsafe-strict-containers": true
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package codetoanalyze.java.nullsafe_gradual;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
public class ActivityFieldNotInitialized {
|
|
||||||
|
|
||||||
class BadActivityWithOnCreate extends Activity {
|
|
||||||
|
|
||||||
private String field;
|
|
||||||
|
|
||||||
protected void onCreate(Bundle bundle) {}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,140 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package codetoanalyze.java.nullsafe_gradual;
|
|
||||||
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import com.facebook.infer.annotation.FalseOnNull;
|
|
||||||
import com.facebook.infer.annotation.PropagatesNullable;
|
|
||||||
import com.facebook.infer.annotation.TrueOnNull;
|
|
||||||
import com.google.common.base.Strings;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public class CustomAnnotations {
|
|
||||||
|
|
||||||
static class MyTextUtils {
|
|
||||||
|
|
||||||
@TrueOnNull
|
|
||||||
static boolean isEmpty(@Nullable java.lang.CharSequence s) {
|
|
||||||
return s == null || s.equals("");
|
|
||||||
}
|
|
||||||
|
|
||||||
@FalseOnNull
|
|
||||||
static boolean isNotEmpty(@Nullable java.lang.CharSequence s) {
|
|
||||||
return s != null && s.length() > 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class TestTextUtilsIsEmpty {
|
|
||||||
void textUtilsNotIsEmpty(@Nullable CharSequence s) {
|
|
||||||
if (!TextUtils.isEmpty(s)) {
|
|
||||||
s.toString(); // OK
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void textUtilsIsEmpty(@Nullable CharSequence s) {
|
|
||||||
if (TextUtils.isEmpty(s)) {
|
|
||||||
s.toString(); // BAD
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void myTextUtilsNotIsEmpty(@Nullable CharSequence s) {
|
|
||||||
if (!MyTextUtils.isEmpty(s)) {
|
|
||||||
s.toString(); // OK
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void myTextUtilsIsEmpty(@Nullable CharSequence s) {
|
|
||||||
if (MyTextUtils.isEmpty(s)) {
|
|
||||||
s.toString(); // BAD
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void myTextUtilsIsNotEmpty(@Nullable CharSequence s) {
|
|
||||||
if (MyTextUtils.isNotEmpty(s)) {
|
|
||||||
s.toString(); // OK
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void myTextUtilsNotIsNotEmpty(@Nullable CharSequence s) {
|
|
||||||
if (!MyTextUtils.isNotEmpty(s)) {
|
|
||||||
s.toString(); // BAD
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Tests for the annotation @PropagatesNullable
|
|
||||||
class TestPropagatesNullable {
|
|
||||||
|
|
||||||
// one parameter: means return null iff s is null
|
|
||||||
String m(@PropagatesNullable String s) {
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
void mBad() {
|
|
||||||
m(null).length(); // bad: m returns null
|
|
||||||
}
|
|
||||||
|
|
||||||
void mGood() {
|
|
||||||
m("").length();
|
|
||||||
}
|
|
||||||
|
|
||||||
// limitation: we currently cannot check the body, and just trust the annotation
|
|
||||||
String cannotCheckBody(@PropagatesNullable String s) {
|
|
||||||
return null; // nothing is reported here
|
|
||||||
}
|
|
||||||
|
|
||||||
void illustrateFalseNegativeAsCannotCheckBody() {
|
|
||||||
cannotCheckBody("").length(); // this is an NPE but is not found
|
|
||||||
}
|
|
||||||
|
|
||||||
// second parameter: means return null iff s2 is null
|
|
||||||
String m2(@Nullable String s1, @PropagatesNullable String s2) {
|
|
||||||
return s2;
|
|
||||||
}
|
|
||||||
|
|
||||||
void m2Bad() {
|
|
||||||
m2(null, null).length(); // bad: m2 returns null
|
|
||||||
}
|
|
||||||
|
|
||||||
void m2Good() {
|
|
||||||
m2(null, "").length();
|
|
||||||
}
|
|
||||||
|
|
||||||
// two parameters: means return null iff either s1 or s2 is null
|
|
||||||
String m12(@PropagatesNullable String s1, @PropagatesNullable String s2) {
|
|
||||||
return s1 == null ? s1 : s2;
|
|
||||||
}
|
|
||||||
|
|
||||||
void m12Bad1() {
|
|
||||||
m12(null, "").length(); // bad: m12 returns null
|
|
||||||
}
|
|
||||||
|
|
||||||
void m12Bad2() {
|
|
||||||
m12("", null).length(); // bad: m12 returns null
|
|
||||||
}
|
|
||||||
|
|
||||||
void m12Good() {
|
|
||||||
m12("", "").length();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class TestModeledTrueOnNull {
|
|
||||||
|
|
||||||
void testIsEmptyOrNullOk(@Nullable String string) {
|
|
||||||
if (!Strings.isNullOrEmpty(string)) {
|
|
||||||
string.contains("Infer");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void testIsEmptyOrNullBad(@Nullable String string) {
|
|
||||||
if (Strings.isNullOrEmpty(string)) {
|
|
||||||
string.contains("Infer");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,156 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package codetoanalyze.java.nullsafe_gradual;
|
|
||||||
|
|
||||||
import android.widget.EditText;
|
|
||||||
import com.facebook.infer.annotation.SuppressViewNullability;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import javax.inject.Inject;
|
|
||||||
|
|
||||||
// for butterknife
|
|
||||||
@interface Bind {}
|
|
||||||
|
|
||||||
public class FieldNotInitialized {
|
|
||||||
|
|
||||||
String a;
|
|
||||||
|
|
||||||
@Nullable String b;
|
|
||||||
|
|
||||||
@Inject String d; // Means: assume it will be initialized via dependency injection
|
|
||||||
|
|
||||||
@Bind EditText f; // Means: assume it will be initialized, and ignore null assignment
|
|
||||||
|
|
||||||
@SuppressViewNullability EditText g;
|
|
||||||
|
|
||||||
// Eradicate should only report one initialization error
|
|
||||||
FieldNotInitialized() {}
|
|
||||||
|
|
||||||
void testNullifyFields() {
|
|
||||||
f = null; // OK the framework could write null into the field
|
|
||||||
g = null; // OK the framework could write null into the field
|
|
||||||
}
|
|
||||||
|
|
||||||
class OnlyRead {
|
|
||||||
Object o;
|
|
||||||
|
|
||||||
OnlyRead() {
|
|
||||||
Object x = o; // not initialized
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class WriteItself {
|
|
||||||
Object o;
|
|
||||||
|
|
||||||
WriteItself() {
|
|
||||||
o = o; // not initialized
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class Swap {
|
|
||||||
Object o1;
|
|
||||||
Object o2;
|
|
||||||
|
|
||||||
Swap() {
|
|
||||||
o1 = o2; // not initialized
|
|
||||||
o2 = new Object();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class SwapOK {
|
|
||||||
Object o1;
|
|
||||||
Object o2;
|
|
||||||
|
|
||||||
SwapOK() {
|
|
||||||
o1 = new Object();
|
|
||||||
o2 = o1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class OnlyReadIndirect {
|
|
||||||
Object o1;
|
|
||||||
Object o2;
|
|
||||||
|
|
||||||
private void indirect() {
|
|
||||||
Object x = o1; // not initialized
|
|
||||||
o2 = new Object();
|
|
||||||
}
|
|
||||||
|
|
||||||
OnlyReadIndirect() {
|
|
||||||
indirect();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class ConditionalFieldInit {
|
|
||||||
Object o1;
|
|
||||||
@Nullable Object o2 = null;
|
|
||||||
|
|
||||||
public ConditionalFieldInit() {
|
|
||||||
if (o2 != null) {
|
|
||||||
o1 = new Object(); // Not always initialized
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class InitIfNull {
|
|
||||||
Object o;
|
|
||||||
|
|
||||||
public InitIfNull() {
|
|
||||||
if (o == null) o = new Object();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class InitIfNull2 {
|
|
||||||
Object o;
|
|
||||||
|
|
||||||
public InitIfNull2(Object x) {
|
|
||||||
if (o == null) o = x;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class InitIfNull3 {
|
|
||||||
Object o;
|
|
||||||
|
|
||||||
Object getNotNull() {
|
|
||||||
return new Object();
|
|
||||||
}
|
|
||||||
|
|
||||||
public InitIfNull3() {
|
|
||||||
if (o == null) o = getNotNull();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class InitCircular {
|
|
||||||
String s;
|
|
||||||
|
|
||||||
InitCircular() {
|
|
||||||
String tmp = s;
|
|
||||||
s = tmp; // s is not initialized: circular initialization
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class InitWithOtherClass {
|
|
||||||
class OtherClass {
|
|
||||||
String s = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
String s;
|
|
||||||
|
|
||||||
InitWithOtherClass(OtherClass x) {
|
|
||||||
s = x.s;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class InitWithThisClass {
|
|
||||||
|
|
||||||
String s;
|
|
||||||
|
|
||||||
InitWithThisClass(InitWithThisClass x) {
|
|
||||||
s = x.s;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,367 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package codetoanalyze.java.nullsafe_gradual;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.view.View;
|
|
||||||
import com.facebook.infer.annotation.Assertions;
|
|
||||||
import com.facebook.infer.annotation.Cleanup;
|
|
||||||
import com.facebook.infer.annotation.Initializer;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
abstract class A {
|
|
||||||
final String fld;
|
|
||||||
|
|
||||||
A(String s) {
|
|
||||||
this.fld = s;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// for butterknife
|
|
||||||
@interface InjectView {}
|
|
||||||
|
|
||||||
class FragmentExample extends Fragment {
|
|
||||||
|
|
||||||
View view;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroyView() {
|
|
||||||
view = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class FieldNotNullable extends A {
|
|
||||||
@Nullable String x;
|
|
||||||
String y;
|
|
||||||
String fld; // Shadow the field defined in A
|
|
||||||
String static_s = null; // Static initializer error
|
|
||||||
|
|
||||||
FieldNotNullable(String s) {
|
|
||||||
super(s);
|
|
||||||
x = null;
|
|
||||||
y = s;
|
|
||||||
this.fld = s;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setXNull() {
|
|
||||||
x = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setXNullable(@Nullable String s) {
|
|
||||||
x = s;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setYNull() {
|
|
||||||
y = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setYNullable(@Nullable String s) {
|
|
||||||
y = s;
|
|
||||||
}
|
|
||||||
|
|
||||||
FieldNotNullable(Integer n) {
|
|
||||||
super("");
|
|
||||||
this.fld = "";
|
|
||||||
y = x == null ? "abc" : "def";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class MixedInitializers extends Activity {
|
|
||||||
|
|
||||||
private String field1 = "1";
|
|
||||||
private String field2;
|
|
||||||
private String field3;
|
|
||||||
|
|
||||||
MixedInitializers() {
|
|
||||||
field2 = "2";
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void onCreate(Bundle bundle) {
|
|
||||||
field3 = "3";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class TestInitializerBuilder {
|
|
||||||
String required1;
|
|
||||||
String required2;
|
|
||||||
@Nullable String optional;
|
|
||||||
|
|
||||||
// No FIELD_NOT_INITIALIZED error should be reported, because of the @Initializer annotations.
|
|
||||||
TestInitializerBuilder() {}
|
|
||||||
|
|
||||||
// This is an initializer and must always be called before build().
|
|
||||||
@Initializer
|
|
||||||
TestInitializerBuilder setRequired1(String required1) {
|
|
||||||
this.required1 = required1;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// This is an initializer and must always be called before build().
|
|
||||||
@Initializer
|
|
||||||
TestInitializerBuilder setRequired2(String required2) {
|
|
||||||
this.required2 = required2;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
TestInitializerBuilder setOptional(String optional) {
|
|
||||||
this.optional = optional;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
TestInitializer build() {
|
|
||||||
// Fail hard if the required fields are not initialzed
|
|
||||||
Assertions.assertCondition(required1 != null && required2 != null);
|
|
||||||
|
|
||||||
return new TestInitializer(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Cleanup
|
|
||||||
void testCleanup() {
|
|
||||||
this.required1 = null;
|
|
||||||
this.required2 = null;
|
|
||||||
this.optional = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class TestInitializer {
|
|
||||||
String required1; // should always be set
|
|
||||||
String required2; // should always be set
|
|
||||||
@Nullable String optional; // optionally set
|
|
||||||
|
|
||||||
TestInitializer(TestInitializerBuilder b) {
|
|
||||||
required1 = b.required1;
|
|
||||||
required2 = b.required2;
|
|
||||||
optional = b.optional;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void testInitializerClientA() {
|
|
||||||
TestInitializerBuilder b = new TestInitializerBuilder();
|
|
||||||
b.setRequired1("hello");
|
|
||||||
b.setRequired2("world");
|
|
||||||
TestInitializer x = b.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void testInitializerClientB() {
|
|
||||||
TestInitializerBuilder b = new TestInitializerBuilder();
|
|
||||||
b.setRequired1("a");
|
|
||||||
b.setRequired2("b");
|
|
||||||
b.setOptional("c");
|
|
||||||
TestInitializer x = b.build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class NestedFieldAccess {
|
|
||||||
|
|
||||||
class C {
|
|
||||||
@Nullable String s;
|
|
||||||
}
|
|
||||||
|
|
||||||
class CC {
|
|
||||||
@Nullable C c;
|
|
||||||
}
|
|
||||||
|
|
||||||
class CCC {
|
|
||||||
@Nullable CC cc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Test {
|
|
||||||
@Nullable String s;
|
|
||||||
C myc;
|
|
||||||
|
|
||||||
Test() {
|
|
||||||
myc = new C();
|
|
||||||
}
|
|
||||||
|
|
||||||
void test() {
|
|
||||||
if (s != null) {
|
|
||||||
int n = s.length();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void test1() {
|
|
||||||
if (myc.s != null) {
|
|
||||||
int n = myc.s.length();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void test2(C c) {
|
|
||||||
if (c.s != null) {
|
|
||||||
int n = c.s.length();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void test2_local() {
|
|
||||||
C c = new C();
|
|
||||||
if (c.s != null) {
|
|
||||||
int n = c.s.length();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void test3(CC cc) {
|
|
||||||
if (cc.c != null && cc.c.s != null) {
|
|
||||||
int n = cc.c.s.length();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void test4(CCC ccc) {
|
|
||||||
if (ccc.cc != null && ccc.cc.c != null && ccc.cc.c.s != null) {
|
|
||||||
int n = ccc.cc.c.s.length();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void test5(@Nullable CCC ccc) {
|
|
||||||
if (ccc == null || ccc.cc == null || ccc.cc.c == null || ccc.cc.c.s == null) {
|
|
||||||
} else {
|
|
||||||
int n = ccc.cc.c.s.length();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class TestFunctionsIdempotent {
|
|
||||||
@Nullable String s;
|
|
||||||
String dontAssignNull;
|
|
||||||
|
|
||||||
TestFunctionsIdempotent() {
|
|
||||||
dontAssignNull = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
String getS(int n) {
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
TestFunctionsIdempotent getSelf() {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FlatOK1(TestFunctionsIdempotent x) {
|
|
||||||
if (getS(3) != null) {
|
|
||||||
dontAssignNull = getS(3);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FlatOK2(TestFunctionsIdempotent x) {
|
|
||||||
if (x.getS(3) != null) {
|
|
||||||
dontAssignNull = x.getS(3);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FlatBAD1(TestFunctionsIdempotent x) {
|
|
||||||
if (x.getS(3) != null) {
|
|
||||||
dontAssignNull = getS(3);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FlatBAD2(TestFunctionsIdempotent x) {
|
|
||||||
if (x.getS(3) != null) {
|
|
||||||
dontAssignNull = x.getS(4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void NestedOK1() {
|
|
||||||
if (getSelf().getS(3) != null) {
|
|
||||||
dontAssignNull = getSelf().getS(3);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void NestedOK2() {
|
|
||||||
if (getSelf().getSelf().getS(3) != null) {
|
|
||||||
dontAssignNull = getSelf().getSelf().getS(3);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void NestedBAD1() {
|
|
||||||
if (getSelf().getS(3) != null) {
|
|
||||||
dontAssignNull = getSelf().getS(4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void NestedBAD2() {
|
|
||||||
if (getS(3) != null) {
|
|
||||||
dontAssignNull = getSelf().getS(3);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void NestedBAD3() {
|
|
||||||
if (getSelf().getSelf().getS(3) != null) {
|
|
||||||
dontAssignNull = getSelf().getS(3);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class TestContainsKey {
|
|
||||||
void testMapContainsKey(java.util.Map<Integer, String> m) {
|
|
||||||
if (m.containsKey(3)) {
|
|
||||||
m.get(3).isEmpty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void testMapContainsKeyInsideWhileLoop(java.util.Map<Integer, String> m) {
|
|
||||||
while (true) {
|
|
||||||
if (m.containsKey(3)) {
|
|
||||||
m.get(3).isEmpty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void testImmutableMapContainsKey(com.google.common.collect.ImmutableMap<Integer, String> m) {
|
|
||||||
if (m.containsKey(3)) {
|
|
||||||
m.get(3).isEmpty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test Map.put()
|
|
||||||
class TestPut {
|
|
||||||
String dontAssignNull = "";
|
|
||||||
|
|
||||||
public void putConstString(java.util.Map<String, String> map, String key) {
|
|
||||||
map.put(key, "abc");
|
|
||||||
dontAssignNull = map.get(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void putNull(java.util.Map<String, String> map, String key) {
|
|
||||||
map.put(key, "abc");
|
|
||||||
map.put(key, null);
|
|
||||||
dontAssignNull = map.get(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void putWithContainsKey(java.util.Map<String, String> map, String key) {
|
|
||||||
if (!map.containsKey(key)) {
|
|
||||||
map.put(key, "abc");
|
|
||||||
}
|
|
||||||
dontAssignNull = map.get(key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// support assignments of null to @InjectView fields, generated by butterknife
|
|
||||||
class SupportButterKnife {
|
|
||||||
@InjectView String s;
|
|
||||||
|
|
||||||
SupportButterKnife() {}
|
|
||||||
|
|
||||||
void dereferencingIsOK() {
|
|
||||||
int n = s.length();
|
|
||||||
}
|
|
||||||
|
|
||||||
void assignNullIsOK() {
|
|
||||||
s = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void methodWithNullableCapturedParameterBad_FN(@Nullable Object parameter) {
|
|
||||||
Object object =
|
|
||||||
new Object() {
|
|
||||||
void foo() {
|
|
||||||
parameter.toString();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
package codetoanalyze.java.nullsafe_gradual;
|
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
@Retention(RetentionPolicy.CLASS)
|
|
||||||
@Target(ElementType.TYPE)
|
|
||||||
public @interface GeneratedGraphQL {}
|
|
@ -1,136 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package codetoanalyze.java.nullsafe_gradual;
|
|
||||||
|
|
||||||
import external.library.SomeExternalClass;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
class SubclassExample {
|
|
||||||
|
|
||||||
class T {
|
|
||||||
public void f() {}
|
|
||||||
}
|
|
||||||
|
|
||||||
class A {
|
|
||||||
|
|
||||||
public T foo() {
|
|
||||||
return new T();
|
|
||||||
}
|
|
||||||
|
|
||||||
public @Nullable T bar() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deref(@Nullable T t) {
|
|
||||||
if (t != null) {
|
|
||||||
t.f();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void noDeref(T t) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
class B extends A {
|
|
||||||
|
|
||||||
public @Nullable T foo() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public T bar() {
|
|
||||||
return new T();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
interface I {
|
|
||||||
public T baz();
|
|
||||||
}
|
|
||||||
|
|
||||||
class C implements I {
|
|
||||||
|
|
||||||
public @Nullable T baz() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class D extends A {
|
|
||||||
|
|
||||||
public void deref(T t) {
|
|
||||||
t.f();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void noDeref(@Nullable T t) {
|
|
||||||
if (t != null) {
|
|
||||||
t.f();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class ConstructorsAreExcluded {
|
|
||||||
class Base {
|
|
||||||
Base(@Nullable String s) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
class Derived extends Base {
|
|
||||||
Derived(String s) { // OK: there's no sub-typing between constructors
|
|
||||||
super(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class ExtendsExternalLibrary extends SomeExternalClass {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @Nullable Object externalMethod1() {
|
|
||||||
// subtyping error on the return type not reported as we cannot
|
|
||||||
// rely on the external libraries to be correctly annotated
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void externalMethod2(Object object) {
|
|
||||||
// subtyping error on the parameter type are reported
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class InconsistentSubclassAnnotation implements InconsistentSubclassAnnotationInterface {
|
|
||||||
|
|
||||||
public static void callFromSuperclass(SubclassExample.A a) {
|
|
||||||
SubclassExample.T t = a.foo();
|
|
||||||
t.f();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void callWithNullableParam(SubclassExample.A a, @Nullable SubclassExample.T t) {
|
|
||||||
a.deref(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String implementInAnotherFile(String s) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
public @Nullable Object overloadedMethod() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object overloadedMethod(Object object) {
|
|
||||||
return object;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class Super {
|
|
||||||
String overloadingMethodLookupFP(int i) {
|
|
||||||
return Integer.toString(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class Sub extends Super {
|
|
||||||
@Nullable
|
|
||||||
String overloadingMethodLookupFP(Object object) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package codetoanalyze.java.nullsafe_gradual;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public interface InconsistentSubclassAnnotationInterface {
|
|
||||||
|
|
||||||
public String implementInAnotherFile(@Nullable String s);
|
|
||||||
|
|
||||||
Object overloadedMethod();
|
|
||||||
|
|
||||||
Object overloadedMethod(Object object);
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
|
|
||||||
public class JunitExample extends TestCase {
|
|
||||||
|
|
||||||
private Object mField;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void setUp() throws Exception {
|
|
||||||
super.setUp();
|
|
||||||
mField = new Object();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testSomething() {
|
|
||||||
mField.toString();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package codetoanalyze.java.nullsafe_gradual;
|
|
||||||
|
|
||||||
import java.lang.ref.PhantomReference;
|
|
||||||
import java.lang.ref.Reference;
|
|
||||||
import java.lang.ref.SoftReference;
|
|
||||||
import java.lang.ref.WeakReference;
|
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
|
||||||
|
|
||||||
public class LibraryCalls {
|
|
||||||
|
|
||||||
String badReferenceDereference(Reference ref) {
|
|
||||||
return ref.get().toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
String badWeakReferenceDereference(WeakReference ref) {
|
|
||||||
return ref.get().toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
String badPhantomReferenceDereference(PhantomReference ref) {
|
|
||||||
return ref.get().toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
String badSoftReferenceDereference(SoftReference ref) {
|
|
||||||
return ref.get().toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
String badAtomicReferenceDereference(AtomicReference ref) {
|
|
||||||
return ref.get().toString();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
# Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
#
|
|
||||||
# This source code is licensed under the MIT license found in the
|
|
||||||
# LICENSE file in the root directory of this source tree.
|
|
||||||
|
|
||||||
TESTS_DIR = ../../..
|
|
||||||
|
|
||||||
INFER_OPTIONS = \
|
|
||||||
--eradicate-only \
|
|
||||||
--eradicate-return-over-annotated \
|
|
||||||
--eradicate-condition-redundant \
|
|
||||||
--debug-exceptions
|
|
||||||
INFERPRINT_OPTIONS = --issues-tests
|
|
||||||
SOURCES = $(wildcard *.java) $(wildcard $(TESTS_DIR)/external/library/*.java)
|
|
||||||
|
|
||||||
include $(TESTS_DIR)/javac.make
|
|
@ -1,18 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
package codetoanalyze.java.nullsafe_gradual;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public class MyPreconditions {
|
|
||||||
|
|
||||||
public static native <T> T checkNotNull(@Nullable T t);
|
|
||||||
|
|
||||||
public static native void checkState(boolean expression);
|
|
||||||
|
|
||||||
public static native void checkArgument(boolean expression);
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package codetoanalyze.java.nullsafe_gradual;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public class NoReuseUndefFunctionValues {
|
|
||||||
|
|
||||||
Object mObject1;
|
|
||||||
Object mObject2;
|
|
||||||
|
|
||||||
native Object create();
|
|
||||||
|
|
||||||
public NoReuseUndefFunctionValues(@Nullable Object object) {
|
|
||||||
if (object != null) {
|
|
||||||
this.mObject1 = object;
|
|
||||||
} else {
|
|
||||||
this.mObject1 = this.create();
|
|
||||||
}
|
|
||||||
if (object != null) {
|
|
||||||
this.mObject2 = object;
|
|
||||||
} else {
|
|
||||||
this.mObject2 = this.create();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,58 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package codetoanalyze.java.nullsafe_gradual;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public class NullFieldAccess {
|
|
||||||
class C {
|
|
||||||
int n;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface I {
|
|
||||||
@Nullable C c = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable C x;
|
|
||||||
C y;
|
|
||||||
static final @Nullable C z = null;
|
|
||||||
|
|
||||||
NullFieldAccess() {
|
|
||||||
y = new C();
|
|
||||||
}
|
|
||||||
|
|
||||||
int useX() {
|
|
||||||
C c = x;
|
|
||||||
return c.n;
|
|
||||||
}
|
|
||||||
|
|
||||||
int useY() {
|
|
||||||
C c = y;
|
|
||||||
return c.n;
|
|
||||||
}
|
|
||||||
|
|
||||||
int useZ() {
|
|
||||||
C c = z;
|
|
||||||
return c.n;
|
|
||||||
}
|
|
||||||
|
|
||||||
int useInterface(I i) {
|
|
||||||
C c = i.c;
|
|
||||||
return c.n;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable Object[] objects;
|
|
||||||
|
|
||||||
int arrayLength() {
|
|
||||||
return objects.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
Object arrayAccess() {
|
|
||||||
return objects[0];
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,369 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package codetoanalyze.java.nullsafe_gradual;
|
|
||||||
|
|
||||||
import android.app.AlarmManager;
|
|
||||||
import android.app.PendingIntent;
|
|
||||||
import com.facebook.infer.annotation.Assertions;
|
|
||||||
import com.google.common.base.Preconditions;
|
|
||||||
import com.google.common.base.Verify;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public class NullMethodCall {
|
|
||||||
|
|
||||||
void callOnNull() {
|
|
||||||
String s = null;
|
|
||||||
int n = s.length();
|
|
||||||
}
|
|
||||||
|
|
||||||
void callOnEmptyString() {
|
|
||||||
String s = "";
|
|
||||||
int n = s.length();
|
|
||||||
}
|
|
||||||
|
|
||||||
void callAfterYodaCondition(@Nullable String s) {
|
|
||||||
if (null != s) {
|
|
||||||
int n = s.length();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int objectLength(@Nullable Object o) {
|
|
||||||
if (o instanceof String) {
|
|
||||||
String s = (String) o;
|
|
||||||
return s.length(); // OK: s cannot be null because of instanceof
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int testCheckState(@Nullable String s1, @Nullable String s2) {
|
|
||||||
Preconditions.checkState(s1 != null && s2 != null, "bad");
|
|
||||||
return s1.length() + s2.length();
|
|
||||||
}
|
|
||||||
|
|
||||||
int testPrivateStaticInnerClassField() {
|
|
||||||
String s;
|
|
||||||
S.sfld = "abc";
|
|
||||||
s = S.sfld;
|
|
||||||
return s.length();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class S {
|
|
||||||
private static @Nullable String sfld;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable String fld;
|
|
||||||
private @Nullable String pfld;
|
|
||||||
|
|
||||||
public class Inner {
|
|
||||||
int outerField() {
|
|
||||||
String s = fld;
|
|
||||||
return s.length();
|
|
||||||
}
|
|
||||||
|
|
||||||
int outerFieldInitialized() {
|
|
||||||
fld = "abc";
|
|
||||||
String s = fld;
|
|
||||||
return s.length();
|
|
||||||
}
|
|
||||||
|
|
||||||
int outerPrivateField() {
|
|
||||||
String s = pfld;
|
|
||||||
return s.length();
|
|
||||||
}
|
|
||||||
|
|
||||||
int outerPrivateFieldInitialized() {
|
|
||||||
pfld = "abc";
|
|
||||||
String s = pfld;
|
|
||||||
return s.length();
|
|
||||||
}
|
|
||||||
|
|
||||||
int outerPrivateFieldCheckNotNull() {
|
|
||||||
Preconditions.checkNotNull(pfld);
|
|
||||||
String s = pfld;
|
|
||||||
return s.length();
|
|
||||||
}
|
|
||||||
|
|
||||||
int outerPrivateFieldCheckState() {
|
|
||||||
Preconditions.checkState(pfld != null);
|
|
||||||
String s = pfld;
|
|
||||||
return s.length();
|
|
||||||
}
|
|
||||||
|
|
||||||
int outerPrivateFieldAssertNotNull() {
|
|
||||||
Assertions.assertNotNull(pfld);
|
|
||||||
String s = pfld;
|
|
||||||
return s.length();
|
|
||||||
}
|
|
||||||
|
|
||||||
int outerPrivateFieldAssumeNotNull() {
|
|
||||||
Assertions.assumeNotNull(pfld);
|
|
||||||
String s = pfld;
|
|
||||||
return s.length();
|
|
||||||
}
|
|
||||||
|
|
||||||
int outerPrivateFieldAssertCondition() {
|
|
||||||
Assertions.assertCondition(pfld != null, "explanation");
|
|
||||||
String s = pfld;
|
|
||||||
return s.length();
|
|
||||||
}
|
|
||||||
|
|
||||||
int outerPrivateFieldAssumeCondition() {
|
|
||||||
Assertions.assumeCondition(pfld != null, "explanation");
|
|
||||||
String s = pfld;
|
|
||||||
return s.length();
|
|
||||||
}
|
|
||||||
|
|
||||||
int outerPrivateFieldCheckStateYoda() {
|
|
||||||
Preconditions.checkState(null != pfld);
|
|
||||||
String s = pfld;
|
|
||||||
return s.length();
|
|
||||||
}
|
|
||||||
|
|
||||||
String outerFieldGuardPrivate() {
|
|
||||||
if (pfld != null) return pfld.toString();
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
String outerFieldGuardPublic() {
|
|
||||||
if (fld != null) return fld.toString();
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
public class InnerInner {
|
|
||||||
int outerouterPrivateFieldInitialized() {
|
|
||||||
pfld = "abc";
|
|
||||||
String s = pfld;
|
|
||||||
return s.length();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
String getNullable() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
void testVariableAssigmentInsideConditional() {
|
|
||||||
String s = null;
|
|
||||||
if ((s = getNullable()) != null) {
|
|
||||||
int n = s.length();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void testFieldAssigmentInsideConditional() {
|
|
||||||
if ((fld = getNullable()) != null) {
|
|
||||||
int n = fld.length();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String abc = "abc";
|
|
||||||
|
|
||||||
void testFieldAssignmentIfThenElse(String name) {
|
|
||||||
String s = (name.length() == 0) ? null : abc;
|
|
||||||
int n = s.length();
|
|
||||||
}
|
|
||||||
|
|
||||||
static String throwsExn() throws java.io.IOException {
|
|
||||||
throw new java.io.IOException();
|
|
||||||
}
|
|
||||||
|
|
||||||
void testExceptionPerInstruction(int z) throws java.io.IOException {
|
|
||||||
String s = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
s = throwsExn();
|
|
||||||
} finally {
|
|
||||||
int n = s.length();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class InitializeAndExceptions {
|
|
||||||
String s;
|
|
||||||
|
|
||||||
String bad() throws java.io.IOException {
|
|
||||||
throw new java.io.IOException();
|
|
||||||
}
|
|
||||||
|
|
||||||
InitializeAndExceptions() throws java.io.IOException {
|
|
||||||
s = bad(); // should not report field not initialized
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class InitializeViaPrivateMethod {
|
|
||||||
String name;
|
|
||||||
|
|
||||||
private void reallyInitName(String s) {
|
|
||||||
name = s;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initName(String s) {
|
|
||||||
reallyInitName(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
InitializeViaPrivateMethod() {
|
|
||||||
initName("abc");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class CheckNotNullVararg {
|
|
||||||
void checkNotNull(String msg, Object... objects) {}
|
|
||||||
|
|
||||||
void testCheckNotNullVaratg(@Nullable String s1, @Nullable String s2) {
|
|
||||||
checkNotNull("hello", s1, s2);
|
|
||||||
s1.isEmpty();
|
|
||||||
s2.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
void testRepeatedCheckNotNull(@Nullable String s) {
|
|
||||||
checkNotNull("abc", s);
|
|
||||||
checkNotNull("abc", s.toString());
|
|
||||||
s.toString().isEmpty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testSystemGetPropertyReturn() {
|
|
||||||
String s = System.getProperty("");
|
|
||||||
int n = s.length();
|
|
||||||
}
|
|
||||||
|
|
||||||
int testSystemGetenvBad() {
|
|
||||||
String envValue = System.getenv("WHATEVER");
|
|
||||||
return envValue.length();
|
|
||||||
}
|
|
||||||
|
|
||||||
class SystemExitDoesNotReturn {
|
|
||||||
native boolean whoknows();
|
|
||||||
|
|
||||||
void testOK() {
|
|
||||||
String s = null;
|
|
||||||
if (whoknows()) {
|
|
||||||
s = "a";
|
|
||||||
} else {
|
|
||||||
System.exit(1);
|
|
||||||
}
|
|
||||||
int n = s.length();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testMapGetBad(
|
|
||||||
Map<String, String> m, HashMap<String, String> hm, ConcurrentHashMap<String, String> chm) {
|
|
||||||
m.get("foo").toString();
|
|
||||||
hm.get("foo").toString();
|
|
||||||
chm.get("foo").toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testMapRemoveBad(
|
|
||||||
Map<String, String> m, HashMap<String, String> hm, ConcurrentHashMap<String, String> chm) {
|
|
||||||
m.remove("foo").toString();
|
|
||||||
hm.remove("foo").toString();
|
|
||||||
chm.remove("foo").toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable Object nullableField;
|
|
||||||
|
|
||||||
void FP_propagatesNonNullAfterComparisonFieldOkay(Object nonNullObject) {
|
|
||||||
if (nullableField == nonNullObject) {
|
|
||||||
nullableField.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FP_propagatesNonNullAfterComparisonParameterOkay(
|
|
||||||
@Nullable Object nullableParameter, Object nonNullParameter) {
|
|
||||||
if (nullableParameter == nonNullParameter) {
|
|
||||||
nullableParameter.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String customPreconditionsCheckNotNullOkay() {
|
|
||||||
MyPreconditions.checkNotNull(nullableField);
|
|
||||||
return nullableField.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
String customPreconditionsCheckStateOkay() {
|
|
||||||
MyPreconditions.checkState(nullableField != null);
|
|
||||||
return nullableField.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
String customPreconditionsCheckArgumentOkay(@Nullable Object arg) {
|
|
||||||
MyPreconditions.checkState(arg != null);
|
|
||||||
return arg.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
void nullMethodCallWithAlarmManager(AlarmManager manager, @Nullable PendingIntent intent) {
|
|
||||||
manager.cancel(intent);
|
|
||||||
}
|
|
||||||
|
|
||||||
String callingSeverSideNullableGetter(ServerSideDeserializer deserializer) {
|
|
||||||
return deserializer.nullableGetter().toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
interface AnotherI {
|
|
||||||
void withBooleanParameter(boolean test);
|
|
||||||
|
|
||||||
void withObjectParameter(Object object);
|
|
||||||
}
|
|
||||||
|
|
||||||
void withConjuction(@Nullable AnotherI i, boolean test1, boolean test2) {
|
|
||||||
i.withBooleanParameter(test1 && test2);
|
|
||||||
}
|
|
||||||
|
|
||||||
void withConditionalAssignemnt(
|
|
||||||
@Nullable AnotherI i, boolean test, Object object1, Object object2) {
|
|
||||||
i.withObjectParameter(test ? object1 : object2);
|
|
||||||
}
|
|
||||||
|
|
||||||
String assertGetOnMapOK(Map<Integer, Object> map, Integer key) {
|
|
||||||
return Assertions.assertGet(key, map).toString(); // No warning here
|
|
||||||
}
|
|
||||||
|
|
||||||
String assertGetOnListOK(List<Object> list, int index) {
|
|
||||||
return Assertions.assertGet(index, list).toString(); // No warning here
|
|
||||||
}
|
|
||||||
|
|
||||||
String guavaVerifyNotNullOK(@Nullable Object object) {
|
|
||||||
Verify.verifyNotNull(object);
|
|
||||||
return object.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
void nullabilityNotPreservedAfterAssignment() {
|
|
||||||
if (getNullable() != null) {
|
|
||||||
Object t = getNullable();
|
|
||||||
t.toString(); // Should not warn here
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void nullabilityStoredInBooleanFP() {
|
|
||||||
boolean isNotNull = getNullable() != null;
|
|
||||||
if (isNotNull) {
|
|
||||||
getNullable().toString(); // Should not warn here
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void testInAssignmentFP(@Nullable Object object) {
|
|
||||||
Object t;
|
|
||||||
while ((t = getNullable()) != null) {
|
|
||||||
t.toString(); // Should not warn here
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String testPathGetParent() {
|
|
||||||
return Paths.get("foo").getParent().toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
String testNotDetectingInvariantFP(@Nullable Object object1, @Nullable Object object2) {
|
|
||||||
if (object1 == null && object2 == null) {
|
|
||||||
return "both null";
|
|
||||||
}
|
|
||||||
return object1 == null ? object2.toString() : "null";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,195 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package codetoanalyze.java.nullsafe_gradual;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public class ParameterNotNullable {
|
|
||||||
|
|
||||||
boolean field = false;
|
|
||||||
|
|
||||||
ParameterNotNullable() {
|
|
||||||
testPrimitive(field);
|
|
||||||
}
|
|
||||||
|
|
||||||
void testPrimitive(boolean f) {}
|
|
||||||
|
|
||||||
void test(String s) {
|
|
||||||
int n = s.length();
|
|
||||||
}
|
|
||||||
|
|
||||||
void testN(@Nullable String s) {
|
|
||||||
int n = s != null ? s.length() : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void callNull() {
|
|
||||||
String s = null;
|
|
||||||
test(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("ERADICATE_PARAMETER_NOT_NULLABLE")
|
|
||||||
void callNullSuppressed() {
|
|
||||||
String s = null;
|
|
||||||
test(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
void callNullable(@Nullable String s) {
|
|
||||||
test(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
void callNullOK() {
|
|
||||||
String s = null;
|
|
||||||
testN(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
void callNullableOK(@Nullable String s) {
|
|
||||||
testN(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ParameterNotNullable(@Nullable String s) {}
|
|
||||||
|
|
||||||
class Builder {
|
|
||||||
ParameterNotNullable getEradicateParameterNotNullable() {
|
|
||||||
return new ParameterNotNullable(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public @Nullable String testSystemGetPropertyArgument() {
|
|
||||||
String s = System.getProperty(null);
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
String testSystemGetenvBad() {
|
|
||||||
return System.getenv(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
static @Nullable URL testClassGetResourceArgument(Class cls) {
|
|
||||||
return cls.getResource(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
void threeParameters(String s1, String s2, String s3) {}
|
|
||||||
|
|
||||||
void testThreeParameters() {
|
|
||||||
String s = "";
|
|
||||||
threeParameters(null, s, s);
|
|
||||||
threeParameters(s, null, s);
|
|
||||||
threeParameters(s, s, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
class ConstructorCall {
|
|
||||||
ConstructorCall(int x, String s) {}
|
|
||||||
|
|
||||||
ConstructorCall() {
|
|
||||||
this(3, ""); // OK
|
|
||||||
}
|
|
||||||
|
|
||||||
ConstructorCall(int x) {
|
|
||||||
this(3, null); // NPE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void indirectSignatureLookupOk(SomeClass c) {
|
|
||||||
c.acceptsNullableParameter(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
void doesNotAcceptNullableFirstParameter(Object object, boolean test) {}
|
|
||||||
|
|
||||||
void callWithNullableFirstParameter(boolean t1, boolean t2) {
|
|
||||||
doesNotAcceptNullableFirstParameter(null, t1 && t2);
|
|
||||||
}
|
|
||||||
|
|
||||||
void callWithConditionalAssignment(Object object, boolean test) {
|
|
||||||
doesNotAcceptNullableFirstParameter(test ? object : null, test);
|
|
||||||
}
|
|
||||||
|
|
||||||
void testImmutableListOfnotNullArguments() {
|
|
||||||
|
|
||||||
Object notNull = new Object();
|
|
||||||
|
|
||||||
ImmutableList.of(null);
|
|
||||||
ImmutableList.of(null, null);
|
|
||||||
ImmutableList.of(notNull, notNull);
|
|
||||||
ImmutableList.of(notNull, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
void testImmutableListCopyOfNotNullArguments() {
|
|
||||||
|
|
||||||
Iterable nullIterable = null;
|
|
||||||
Iterator nullIterator = null;
|
|
||||||
Collection nullCollection = null;
|
|
||||||
|
|
||||||
ImmutableList.copyOf(nullIterable);
|
|
||||||
ImmutableList.copyOf(nullIterator);
|
|
||||||
ImmutableList.copyOf(nullCollection);
|
|
||||||
}
|
|
||||||
|
|
||||||
void testImmutableListSortedCopyOfNotNullArguments() {
|
|
||||||
ImmutableList.sortedCopyOf(null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
void testImmutableSetOfnotNullArguments() {
|
|
||||||
|
|
||||||
Object notNull = new Object();
|
|
||||||
|
|
||||||
ImmutableSet.of(null);
|
|
||||||
ImmutableSet.of(null, null);
|
|
||||||
ImmutableSet.of(notNull, notNull);
|
|
||||||
ImmutableSet.of(notNull, null);
|
|
||||||
ImmutableSet.of(notNull, null, notNull, null, notNull);
|
|
||||||
}
|
|
||||||
|
|
||||||
void testImmutableSetCopyOfNotNullArguments() {
|
|
||||||
|
|
||||||
Iterable nullIterable = null;
|
|
||||||
Iterator nullIterator = null;
|
|
||||||
Collection nullCollection = null;
|
|
||||||
|
|
||||||
ImmutableSet.copyOf(nullIterable);
|
|
||||||
ImmutableSet.copyOf(nullIterator);
|
|
||||||
ImmutableSet.copyOf(nullCollection);
|
|
||||||
}
|
|
||||||
|
|
||||||
void testImmutableMapOfnotNullArguments() {
|
|
||||||
|
|
||||||
Object notNull = new Object();
|
|
||||||
|
|
||||||
ImmutableMap.of(null, null);
|
|
||||||
ImmutableMap.of(notNull, notNull);
|
|
||||||
ImmutableMap.of(notNull, null, notNull, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
void testImmutableMapCopyOfNotNullArguments() {
|
|
||||||
|
|
||||||
Iterable nullIterable = null;
|
|
||||||
Map nullMap = null;
|
|
||||||
|
|
||||||
ImmutableMap.copyOf(nullIterable);
|
|
||||||
ImmutableMap.copyOf(nullMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
void testParsingNullStringToNumber() {
|
|
||||||
String ns = null;
|
|
||||||
long l = Long.parseLong(ns);
|
|
||||||
int i = Integer.parseInt(ns);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
interface SomeInterface {
|
|
||||||
void acceptsNullableParameter(@Nullable Object object);
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class SomeClass implements SomeInterface {}
|
|
@ -1,30 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
public class Redundant {
|
|
||||||
|
|
||||||
void bad() {
|
|
||||||
String s = "123";
|
|
||||||
if (s != null) {
|
|
||||||
int n = s.length();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void maythrow() throws java.io.IOException {}
|
|
||||||
|
|
||||||
void good() throws java.io.IOException {
|
|
||||||
String s = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
maythrow();
|
|
||||||
s = "123";
|
|
||||||
} finally {
|
|
||||||
if (s != null) { // this is not redundant
|
|
||||||
int n = s.length();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,231 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package codetoanalyze.java.nullsafe_gradual;
|
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public class ReturnNotNullable {
|
|
||||||
|
|
||||||
void returnvoid() {
|
|
||||||
// No warning here.
|
|
||||||
}
|
|
||||||
|
|
||||||
Void returnVoid() {
|
|
||||||
// This is OK too.
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------
|
|
||||||
// Converting different things to not annotated types.
|
|
||||||
// By default, (not annotated type is treated as non nullable).
|
|
||||||
|
|
||||||
String nullToNotAnnotatedIsBad() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
String nullableToNotAnnotatedIsBad(@Nullable String s) {
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
String notAnnotatedToNotAnnotatedIsOK(String s) {
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
String nonNullToNotAnnotatedIsOK(@Nonnull String s) {
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
String constantToNotAnnotatedIsOK() {
|
|
||||||
return "abc";
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------
|
|
||||||
// Converting different things to @Nonnull.
|
|
||||||
// (Should be the same as converting to not annotated).
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
String nullToNonnullIsBad() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
String nullableToNonnullIsBad(@Nullable String s) {
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
String notAnnotatedToNonnullIsOK(String s) {
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
String nonNullToNonnullIsOK(@Nonnull String s) {
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
String constantToNonNullIsOK() {
|
|
||||||
return "abc";
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------
|
|
||||||
// Converting different things to @Nullable.
|
|
||||||
// This is either
|
|
||||||
// 1. OK when inferred and annotated return types are both nullable, or
|
|
||||||
// 2. Leads to ERADICATE_RETURN_OVER_ANNOTATED when inferred return type
|
|
||||||
// is not nullable, but function is still annotated with @Nullable.
|
|
||||||
// This often happens when the API author decides to return @Nullable
|
|
||||||
// (anticipating future change) even though the current implementation returns non-null.
|
|
||||||
// Because of this the warning is currently turned off by default and is recommended
|
|
||||||
// to use only in specific scenarious, like code migrations.
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
String nullToNullableIsOK() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
String nullableToNullableIsOK(@Nullable String s) {
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
String notAnnotatedNullableIsOverannotated(String s) {
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
String nonNullToNullableIsOverannotated(@Nonnull String s) {
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
String constantToNullableIsOverannotated() {
|
|
||||||
return "abc";
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------
|
|
||||||
|
|
||||||
String throwException(@Nullable Exception e, boolean bad) throws Exception {
|
|
||||||
if (bad) {
|
|
||||||
throw (e); // no ERADICATE_RETURN_NOT_NULLABLE should be reported
|
|
||||||
}
|
|
||||||
return "OK";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
String redundantEq() {
|
|
||||||
String s = constantToNonNullIsOK();
|
|
||||||
int n = s == null ? 0 : s.length();
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
String redundantNeq() {
|
|
||||||
String s = constantToNonNullIsOK();
|
|
||||||
int n = s != null ? 0 : s.length();
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
BufferedReader nn(BufferedReader br) {
|
|
||||||
return br;
|
|
||||||
}
|
|
||||||
|
|
||||||
void tryWithResources(String path) {
|
|
||||||
try (BufferedReader br = nn(new BufferedReader(new FileReader(path)))) {
|
|
||||||
} // no condition redundant should be reported on this line
|
|
||||||
catch (IOException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Object tryWithResourcesReturnNullable(String path) throws IOException {
|
|
||||||
try (BufferedReader br = nn(new BufferedReader(new FileReader(path)))) {
|
|
||||||
return nullToNullableIsOK();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Check that orNull is modelled and RETURN_OVER_ANNOTATED is not returned.
|
|
||||||
*/
|
|
||||||
@Nullable
|
|
||||||
String testOptional(Optional<String> os) {
|
|
||||||
return os.orNull();
|
|
||||||
}
|
|
||||||
|
|
||||||
class E extends Exception {}
|
|
||||||
|
|
||||||
String return_null_in_catch() {
|
|
||||||
try {
|
|
||||||
throw new E();
|
|
||||||
} catch (E e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String return_null_in_catch_after_throw() {
|
|
||||||
try {
|
|
||||||
try {
|
|
||||||
throw new E();
|
|
||||||
} catch (E e) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
} catch (E e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
URL getResourceNullable(Class cls, String name) {
|
|
||||||
return cls.getResource(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SomeAnnotationEndingWithNullable
|
|
||||||
Object ensureWeDontConfuseSuchAnnotationsWithNullable() {
|
|
||||||
// No warnings expected
|
|
||||||
return new Object();
|
|
||||||
}
|
|
||||||
|
|
||||||
void testSomeAnnotationEndingWithNullable() {
|
|
||||||
// No warnings expected
|
|
||||||
ensureWeDontConfuseSuchAnnotationsWithNullable().toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
static class ConditionalAssignment {
|
|
||||||
@Nullable Object f1;
|
|
||||||
|
|
||||||
static Object test(boolean b) {
|
|
||||||
ConditionalAssignment x = new ConditionalAssignment();
|
|
||||||
if (b) {
|
|
||||||
x.f1 = new Object();
|
|
||||||
}
|
|
||||||
return x.f1; // can be null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Stream<Object> methodUsesLambda(Stream<Object> stream) {
|
|
||||||
return stream.map(x -> null); // Intentionaly not reporting here
|
|
||||||
}
|
|
||||||
|
|
||||||
Object $generatedReturnsNullOk() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
int field;
|
|
||||||
|
|
||||||
int returnsZero() {
|
|
||||||
field = 0;
|
|
||||||
return field;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
package codetoanalyze.java.nullsafe_gradual;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
@GeneratedGraphQL
|
|
||||||
public interface ServerSideDeserializer {
|
|
||||||
|
|
||||||
public @Nullable Object nullableGetter();
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package codetoanalyze.java.nullsafe_gradual;
|
|
||||||
|
|
||||||
// Test annotation to ensure Infer does not confuse it with @Nullable
|
|
||||||
@interface SomeAnnotationEndingWithNullable {}
|
|
@ -1,28 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package codetoanalyze.java.nullsafe_gradual;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
@Retention(RetentionPolicy.CLASS)
|
|
||||||
@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD})
|
|
||||||
@interface SuppressFieldNotInitialized {}
|
|
||||||
|
|
||||||
public class SuppressedFieldNotInitializedExample {
|
|
||||||
|
|
||||||
@SuppressLint("eradicate-field-not-initialized")
|
|
||||||
String iKnowBetter;
|
|
||||||
|
|
||||||
@SuppressFieldNotInitialized String annotationSuppressed;
|
|
||||||
|
|
||||||
SuppressedFieldNotInitializedExample() {}
|
|
||||||
}
|
|
@ -1,127 +0,0 @@
|
|||||||
codetoanalyze/java/nullsafe-gradual/ActivityFieldNotInitialized.java, codetoanalyze.java.nullsafe_gradual.ActivityFieldNotInitialized$BadActivityWithOnCreate.<init>(codetoanalyze.java.nullsafe_gradual.ActivityFieldNotInitialized), 0, ERADICATE_FIELD_NOT_INITIALIZED, no_bucket, WARNING, [Field `ActivityFieldNotInitialized$BadActivityWithOnCreate.field` is not initialized in the constructor and is not declared `@Nullable`]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/CustomAnnotations.java, codetoanalyze.java.nullsafe_gradual.CustomAnnotations$TestModeledTrueOnNull.testIsEmptyOrNullBad(java.lang.String):void, 2, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [The value of `string` in the call to `contains(...)` is nullable and is not locally checked for null. (Origin: method parameter string)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/CustomAnnotations.java, codetoanalyze.java.nullsafe_gradual.CustomAnnotations$TestPropagatesNullable.m12Bad1():void, 1, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [The value of `m12(...)` in the call to `length()` is nullable and is not locally checked for null. (Origin: call to m12(...) at line 114)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/CustomAnnotations.java, codetoanalyze.java.nullsafe_gradual.CustomAnnotations$TestPropagatesNullable.m12Bad2():void, 1, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [The value of `m12(...)` in the call to `length()` is nullable and is not locally checked for null. (Origin: call to m12(...) at line 118)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/CustomAnnotations.java, codetoanalyze.java.nullsafe_gradual.CustomAnnotations$TestPropagatesNullable.m2Bad():void, 1, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [The value of `m2(...)` in the call to `length()` is nullable and is not locally checked for null. (Origin: call to m2(...) at line 101)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/CustomAnnotations.java, codetoanalyze.java.nullsafe_gradual.CustomAnnotations$TestPropagatesNullable.mBad():void, 1, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [The value of `m(...)` in the call to `length()` is nullable and is not locally checked for null. (Origin: call to m(...) at line 79)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/CustomAnnotations.java, codetoanalyze.java.nullsafe_gradual.CustomAnnotations$TestTextUtilsIsEmpty.myTextUtilsIsEmpty(java.lang.CharSequence):void, 2, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [The value of `s` in the call to `toString()` is nullable and is not locally checked for null. (Origin: method parameter s)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/CustomAnnotations.java, codetoanalyze.java.nullsafe_gradual.CustomAnnotations$TestTextUtilsIsEmpty.myTextUtilsNotIsNotEmpty(java.lang.CharSequence):void, 2, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [The value of `s` in the call to `toString()` is nullable and is not locally checked for null. (Origin: method parameter s)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/CustomAnnotations.java, codetoanalyze.java.nullsafe_gradual.CustomAnnotations$TestTextUtilsIsEmpty.textUtilsIsEmpty(java.lang.CharSequence):void, 1, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`TextUtils.isEmpty(...)` needs a non-null value in parameter 1 but argument `s` can be null. (Origin: method parameter s)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/CustomAnnotations.java, codetoanalyze.java.nullsafe_gradual.CustomAnnotations$TestTextUtilsIsEmpty.textUtilsIsEmpty(java.lang.CharSequence):void, 2, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [The value of `s` in the call to `toString()` is nullable and is not locally checked for null. (Origin: method parameter s)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/CustomAnnotations.java, codetoanalyze.java.nullsafe_gradual.CustomAnnotations$TestTextUtilsIsEmpty.textUtilsNotIsEmpty(java.lang.CharSequence):void, 1, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`TextUtils.isEmpty(...)` needs a non-null value in parameter 1 but argument `s` can be null. (Origin: method parameter s)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/FieldNotInitialized.java, codetoanalyze.java.nullsafe_gradual.FieldNotInitialized$ConditionalFieldInit.<init>(codetoanalyze.java.nullsafe_gradual.FieldNotInitialized), 0, ERADICATE_FIELD_NOT_INITIALIZED, no_bucket, WARNING, [Field `FieldNotInitialized$ConditionalFieldInit.o1` is not initialized in the constructor and is not declared `@Nullable`]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/FieldNotInitialized.java, codetoanalyze.java.nullsafe_gradual.FieldNotInitialized$InitCircular.<init>(codetoanalyze.java.nullsafe_gradual.FieldNotInitialized), 0, ERADICATE_FIELD_NOT_INITIALIZED, no_bucket, WARNING, [Field `FieldNotInitialized$InitCircular.s` is not initialized in the constructor and is not declared `@Nullable`]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/FieldNotInitialized.java, codetoanalyze.java.nullsafe_gradual.FieldNotInitialized$OnlyRead.<init>(codetoanalyze.java.nullsafe_gradual.FieldNotInitialized), 0, ERADICATE_FIELD_NOT_INITIALIZED, no_bucket, WARNING, [Field `FieldNotInitialized$OnlyRead.o` is not initialized in the constructor and is not declared `@Nullable`]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/FieldNotInitialized.java, codetoanalyze.java.nullsafe_gradual.FieldNotInitialized$OnlyReadIndirect.<init>(codetoanalyze.java.nullsafe_gradual.FieldNotInitialized), 0, ERADICATE_FIELD_NOT_INITIALIZED, no_bucket, WARNING, [Field `FieldNotInitialized$OnlyReadIndirect.o1` is not initialized in the constructor and is not declared `@Nullable`]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/FieldNotInitialized.java, codetoanalyze.java.nullsafe_gradual.FieldNotInitialized$Swap.<init>(codetoanalyze.java.nullsafe_gradual.FieldNotInitialized), 0, ERADICATE_FIELD_NOT_INITIALIZED, no_bucket, WARNING, [Field `FieldNotInitialized$Swap.o1` is not initialized in the constructor and is not declared `@Nullable`]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/FieldNotInitialized.java, codetoanalyze.java.nullsafe_gradual.FieldNotInitialized$WriteItself.<init>(codetoanalyze.java.nullsafe_gradual.FieldNotInitialized), 0, ERADICATE_FIELD_NOT_INITIALIZED, no_bucket, WARNING, [Field `FieldNotInitialized$WriteItself.o` is not initialized in the constructor and is not declared `@Nullable`]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/FieldNotInitialized.java, codetoanalyze.java.nullsafe_gradual.FieldNotInitialized.<init>(), 0, ERADICATE_FIELD_NOT_INITIALIZED, no_bucket, WARNING, [Field `FieldNotInitialized.a` is not initialized in the constructor and is not declared `@Nullable`]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/FieldNotNullable.java, codetoanalyze.java.nullsafe_gradual.FieldNotNullable.<init>(java.lang.Integer), -25, ERADICATE_FIELD_NOT_NULLABLE, no_bucket, WARNING, [Field `FieldNotNullable.static_s` can be null but is not declared `@Nullable`. (Origin: null constant at line 44)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/FieldNotNullable.java, codetoanalyze.java.nullsafe_gradual.FieldNotNullable.<init>(java.lang.String), -2, ERADICATE_FIELD_NOT_NULLABLE, no_bucket, WARNING, [Field `FieldNotNullable.static_s` can be null but is not declared `@Nullable`. (Origin: null constant at line 44)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/FieldNotNullable.java, codetoanalyze.java.nullsafe_gradual.FieldNotNullable.setYNull():void, 1, ERADICATE_FIELD_NOT_NULLABLE, no_bucket, WARNING, [Field `FieldNotNullable.y` can be null but is not declared `@Nullable`. (Origin: null constant at line 62)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/FieldNotNullable.java, codetoanalyze.java.nullsafe_gradual.FieldNotNullable.setYNullable(java.lang.String):void, 1, ERADICATE_FIELD_NOT_NULLABLE, no_bucket, WARNING, [Field `FieldNotNullable.y` can be null but is not declared `@Nullable`. (Origin: method parameter s)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/FieldNotNullable.java, codetoanalyze.java.nullsafe_gradual.FragmentExample.<init>(), 0, ERADICATE_FIELD_NOT_INITIALIZED, no_bucket, WARNING, [Field `FragmentExample.view` is not initialized in the constructor and is not declared `@Nullable`]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/FieldNotNullable.java, codetoanalyze.java.nullsafe_gradual.NestedFieldAccess$TestFunctionsIdempotent.FlatBAD1(codetoanalyze.java.nullsafe_gradual.NestedFieldAccess$TestFunctionsIdempotent):void, 2, ERADICATE_FIELD_NOT_NULLABLE, no_bucket, WARNING, [Field `NestedFieldAccess$TestFunctionsIdempotent.dontAssignNull` can be null but is not declared `@Nullable`. (Origin: call to getS(...) at line 258)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/FieldNotNullable.java, codetoanalyze.java.nullsafe_gradual.NestedFieldAccess$TestFunctionsIdempotent.FlatBAD2(codetoanalyze.java.nullsafe_gradual.NestedFieldAccess$TestFunctionsIdempotent):void, 2, ERADICATE_FIELD_NOT_NULLABLE, no_bucket, WARNING, [Field `NestedFieldAccess$TestFunctionsIdempotent.dontAssignNull` can be null but is not declared `@Nullable`. (Origin: call to getS(...) at line 264)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/FieldNotNullable.java, codetoanalyze.java.nullsafe_gradual.NestedFieldAccess$TestFunctionsIdempotent.NestedBAD1():void, 2, ERADICATE_FIELD_NOT_NULLABLE, no_bucket, WARNING, [Field `NestedFieldAccess$TestFunctionsIdempotent.dontAssignNull` can be null but is not declared `@Nullable`. (Origin: call to getS(...) at line 282)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/FieldNotNullable.java, codetoanalyze.java.nullsafe_gradual.NestedFieldAccess$TestFunctionsIdempotent.NestedBAD2():void, 2, ERADICATE_FIELD_NOT_NULLABLE, no_bucket, WARNING, [Field `NestedFieldAccess$TestFunctionsIdempotent.dontAssignNull` can be null but is not declared `@Nullable`. (Origin: call to getS(...) at line 288)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/FieldNotNullable.java, codetoanalyze.java.nullsafe_gradual.NestedFieldAccess$TestFunctionsIdempotent.NestedBAD3():void, 2, ERADICATE_FIELD_NOT_NULLABLE, no_bucket, WARNING, [Field `NestedFieldAccess$TestFunctionsIdempotent.dontAssignNull` can be null but is not declared `@Nullable`. (Origin: call to getS(...) at line 294)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/FieldNotNullable.java, codetoanalyze.java.nullsafe_gradual.NestedFieldAccess$TestPut.putNull(java.util.Map,java.lang.String):void, 2, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`Map.put(...)` needs a non-null value in parameter 2 but argument `null` can be null. (Origin: null constant at line 332)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/FieldNotNullable.java, codetoanalyze.java.nullsafe_gradual.NestedFieldAccess$TestPut.putNull(java.util.Map,java.lang.String):void, 3, ERADICATE_FIELD_NOT_NULLABLE, no_bucket, WARNING, [Field `NestedFieldAccess$TestPut.dontAssignNull` can be null but is not declared `@Nullable`. (Origin: null constant at line 332)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/FieldNotNullable.java, codetoanalyze.java.nullsafe_gradual.TestInitializerBuilder.build():codetoanalyze.java.nullsafe_gradual.TestInitializer, 2, ERADICATE_CONDITION_REDUNDANT, no_bucket, WARNING, [The condition TestInitializerBuilder.required1 is always true according to the existing annotations.]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/FieldNotNullable.java, codetoanalyze.java.nullsafe_gradual.TestInitializerBuilder.build():codetoanalyze.java.nullsafe_gradual.TestInitializer, 2, ERADICATE_CONDITION_REDUNDANT, no_bucket, WARNING, [The condition TestInitializerBuilder.required2 is always true according to the existing annotations.]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/InconsistentSubclassAnnotation.java, codetoanalyze.java.nullsafe_gradual.ExtendsExternalLibrary.externalMethod2(java.lang.Object):void, 0, ERADICATE_INCONSISTENT_SUBCLASS_PARAMETER_ANNOTATION, no_bucket, WARNING, [First parameter `object` of method `ExtendsExternalLibrary.externalMethod2(...)` is not `@Nullable` but is declared `@Nullable`in the parent class method `SomeExternalClass.externalMethod2(...)`.]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/InconsistentSubclassAnnotation.java, codetoanalyze.java.nullsafe_gradual.InconsistentSubclassAnnotation.implementInAnotherFile(java.lang.String):java.lang.String, 0, ERADICATE_INCONSISTENT_SUBCLASS_PARAMETER_ANNOTATION, no_bucket, WARNING, [First parameter `s` of method `InconsistentSubclassAnnotation.implementInAnotherFile(...)` is not `@Nullable` but is declared `@Nullable`in the parent class method `InconsistentSubclassAnnotationInterface.implementInAnotherFile(...)`.]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/InconsistentSubclassAnnotation.java, codetoanalyze.java.nullsafe_gradual.InconsistentSubclassAnnotation.overloadedMethod():java.lang.Object, 0, ERADICATE_INCONSISTENT_SUBCLASS_RETURN_ANNOTATION, no_bucket, WARNING, [Method `InconsistentSubclassAnnotation.overloadedMethod()` is annotated with `@Nullable` but overrides unannotated method `InconsistentSubclassAnnotationInterface.overloadedMethod()`.]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/InconsistentSubclassAnnotation.java, codetoanalyze.java.nullsafe_gradual.Sub.overloadingMethodLookupFP(java.lang.Object):java.lang.String, 0, ERADICATE_INCONSISTENT_SUBCLASS_RETURN_ANNOTATION, no_bucket, WARNING, [Method `Sub.overloadingMethodLookupFP(...)` is annotated with `@Nullable` but overrides unannotated method `Super.overloadingMethodLookupFP(...)`.]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/InconsistentSubclassAnnotation.java, codetoanalyze.java.nullsafe_gradual.SubclassExample$B.foo():codetoanalyze.java.nullsafe_gradual.SubclassExample$T, 0, ERADICATE_INCONSISTENT_SUBCLASS_RETURN_ANNOTATION, no_bucket, WARNING, [Method `SubclassExample$B.foo()` is annotated with `@Nullable` but overrides unannotated method `SubclassExample$A.foo()`.]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/InconsistentSubclassAnnotation.java, codetoanalyze.java.nullsafe_gradual.SubclassExample$C.baz():codetoanalyze.java.nullsafe_gradual.SubclassExample$T, 0, ERADICATE_INCONSISTENT_SUBCLASS_RETURN_ANNOTATION, no_bucket, WARNING, [Method `SubclassExample$C.baz()` is annotated with `@Nullable` but overrides unannotated method `SubclassExample$I.baz()`.]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/InconsistentSubclassAnnotation.java, codetoanalyze.java.nullsafe_gradual.SubclassExample$D.deref(codetoanalyze.java.nullsafe_gradual.SubclassExample$T):void, 0, ERADICATE_INCONSISTENT_SUBCLASS_PARAMETER_ANNOTATION, no_bucket, WARNING, [First parameter `t` of method `SubclassExample$D.deref(...)` is not `@Nullable` but is declared `@Nullable`in the parent class method `SubclassExample$A.deref(...)`.]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/LibraryCalls.java, codetoanalyze.java.nullsafe_gradual.LibraryCalls.badAtomicReferenceDereference(java.util.concurrent.atomic.AtomicReference):java.lang.String, 1, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [The value of `ref.get()` in the call to `toString()` is nullable and is not locally checked for null. (Origin: call to get() modelled in modelTables.ml at line 35)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/LibraryCalls.java, codetoanalyze.java.nullsafe_gradual.LibraryCalls.badPhantomReferenceDereference(java.lang.ref.PhantomReference):java.lang.String, 1, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [The value of `ref.get()` in the call to `toString()` is nullable and is not locally checked for null. (Origin: call to get() modelled in modelTables.ml at line 27)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/LibraryCalls.java, codetoanalyze.java.nullsafe_gradual.LibraryCalls.badReferenceDereference(java.lang.ref.Reference):java.lang.String, 1, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [The value of `ref.get()` in the call to `toString()` is nullable and is not locally checked for null. (Origin: call to get() modelled in modelTables.ml at line 19)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/LibraryCalls.java, codetoanalyze.java.nullsafe_gradual.LibraryCalls.badSoftReferenceDereference(java.lang.ref.SoftReference):java.lang.String, 1, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [The value of `ref.get()` in the call to `toString()` is nullable and is not locally checked for null. (Origin: call to get() modelled in modelTables.ml at line 31)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/LibraryCalls.java, codetoanalyze.java.nullsafe_gradual.LibraryCalls.badWeakReferenceDereference(java.lang.ref.WeakReference):java.lang.String, 1, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [The value of `ref.get()` in the call to `toString()` is nullable and is not locally checked for null. (Origin: call to get() modelled in modelTables.ml at line 23)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/NullFieldAccess.java, codetoanalyze.java.nullsafe_gradual.NullFieldAccess.arrayAccess():java.lang.Object, 1, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [Object `NullFieldAccess.objects` is nullable and is not locally checked for null when accessing element at index `0`. (Origin: field NullFieldAccess.objects at line 56)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/NullFieldAccess.java, codetoanalyze.java.nullsafe_gradual.NullFieldAccess.arrayLength():int, 1, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [Object `NullFieldAccess.objects` is nullable and is not locally checked for null when accessing field `length`. (Origin: field NullFieldAccess.objects at line 52)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/NullFieldAccess.java, codetoanalyze.java.nullsafe_gradual.NullFieldAccess.useInterface(codetoanalyze.java.nullsafe_gradual.NullFieldAccess$I):int, 2, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [Object `c` is nullable and is not locally checked for null when accessing field `NullFieldAccess$C.n`. (Origin: field NullFieldAccess$I.c at line 45)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/NullFieldAccess.java, codetoanalyze.java.nullsafe_gradual.NullFieldAccess.useX():int, 2, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [Object `c` is nullable and is not locally checked for null when accessing field `NullFieldAccess$C.n`. (Origin: field NullFieldAccess.x at line 30)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/NullFieldAccess.java, codetoanalyze.java.nullsafe_gradual.NullFieldAccess.useZ():int, 2, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [Object `c` is nullable and is not locally checked for null when accessing field `NullFieldAccess$C.n`. (Origin: field NullFieldAccess.z at line 40)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/NullMethodCall.java, codetoanalyze.java.nullsafe_gradual.NullMethodCall$Inner.outerField():int, 2, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [The value of `s` in the call to `length()` is nullable and is not locally checked for null. (Origin: field NullMethodCall.fld at line 69)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/NullMethodCall.java, codetoanalyze.java.nullsafe_gradual.NullMethodCall$Inner.outerPrivateField():int, 2, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [The value of `s` in the call to `length()` is nullable and is not locally checked for null. (Origin: field NullMethodCall.pfld at line 80)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/NullMethodCall.java, codetoanalyze.java.nullsafe_gradual.NullMethodCall.FP_propagatesNonNullAfterComparisonFieldOkay(java.lang.Object):void, 2, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [The value of `NullMethodCall.nullableField` in the call to `toString()` is nullable and is not locally checked for null. (Origin: field NullMethodCall.nullableField at line 275)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/NullMethodCall.java, codetoanalyze.java.nullsafe_gradual.NullMethodCall.FP_propagatesNonNullAfterComparisonParameterOkay(java.lang.Object,java.lang.Object):void, 3, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [The value of `nullableParameter` in the call to `toString()` is nullable and is not locally checked for null. (Origin: method parameter nullableParameter)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/NullMethodCall.java, codetoanalyze.java.nullsafe_gradual.NullMethodCall.callOnNull():void, 2, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [The value of `s` in the call to `length()` is nullable and is not locally checked for null. (Origin: null constant at line 25)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/NullMethodCall.java, codetoanalyze.java.nullsafe_gradual.NullMethodCall.callingSeverSideNullableGetter(codetoanalyze.java.nullsafe_gradual.ServerSideDeserializer):java.lang.String, 1, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, ERROR, [The value of `deserializer.nullableGetter()` in the call to `toString()` is nullable and is not locally checked for null. (Origin: call to nullableGetter() at line 307)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/NullMethodCall.java, codetoanalyze.java.nullsafe_gradual.NullMethodCall.nullMethodCallWithAlarmManager(android.app.AlarmManager,android.app.PendingIntent):void, 1, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`AlarmManager.cancel(...)` needs a non-null value in parameter 1 but argument `intent` can be null. (Origin: method parameter intent)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/NullMethodCall.java, codetoanalyze.java.nullsafe_gradual.NullMethodCall.nullabilityNotPreservedAfterAssignment():void, 3, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [The value of `t` in the call to `toString()` is nullable and is not locally checked for null. (Origin: call to getNullable() at line 340)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/NullMethodCall.java, codetoanalyze.java.nullsafe_gradual.NullMethodCall.nullabilityStoredInBooleanFP():void, 3, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [The value of `getNullable()` in the call to `toString()` is nullable and is not locally checked for null. (Origin: call to getNullable() at line 346)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/NullMethodCall.java, codetoanalyze.java.nullsafe_gradual.NullMethodCall.testExceptionPerInstruction(int):void, 6, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [The value of `s` in the call to `length()` is nullable and is not locally checked for null. (Origin: null constant at line 181)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/NullMethodCall.java, codetoanalyze.java.nullsafe_gradual.NullMethodCall.testFieldAssignmentIfThenElse(java.lang.String):void, 2, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [The value of `s` in the call to `length()` is nullable and is not locally checked for null. (Origin: null constant at line 172)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/NullMethodCall.java, codetoanalyze.java.nullsafe_gradual.NullMethodCall.testInAssignmentFP(java.lang.Object):void, 3, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [The value of `t` in the call to `toString()` is nullable and is not locally checked for null. (Origin: call to getNullable() at line 354)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/NullMethodCall.java, codetoanalyze.java.nullsafe_gradual.NullMethodCall.testMapGetBad(java.util.Map,java.util.HashMap,java.util.concurrent.ConcurrentHashMap):void, 2, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [The value of `m.get(...)` in the call to `toString()` is nullable and is not locally checked for null. (Origin: call to get(...) modelled in modelTables.ml at line 260)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/NullMethodCall.java, codetoanalyze.java.nullsafe_gradual.NullMethodCall.testMapGetBad(java.util.Map,java.util.HashMap,java.util.concurrent.ConcurrentHashMap):void, 3, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [The value of `hm.get(...)` in the call to `toString()` is nullable and is not locally checked for null. (Origin: call to get(...) modelled in modelTables.ml at line 261)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/NullMethodCall.java, codetoanalyze.java.nullsafe_gradual.NullMethodCall.testMapGetBad(java.util.Map,java.util.HashMap,java.util.concurrent.ConcurrentHashMap):void, 4, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [The value of `chm.get(...)` in the call to `toString()` is nullable and is not locally checked for null. (Origin: call to get(...) modelled in modelTables.ml at line 262)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/NullMethodCall.java, codetoanalyze.java.nullsafe_gradual.NullMethodCall.testMapRemoveBad(java.util.Map,java.util.HashMap,java.util.concurrent.ConcurrentHashMap):void, 2, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [The value of `m.remove(...)` in the call to `toString()` is nullable and is not locally checked for null. (Origin: call to remove(...) modelled in modelTables.ml at line 267)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/NullMethodCall.java, codetoanalyze.java.nullsafe_gradual.NullMethodCall.testMapRemoveBad(java.util.Map,java.util.HashMap,java.util.concurrent.ConcurrentHashMap):void, 3, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [The value of `hm.remove(...)` in the call to `toString()` is nullable and is not locally checked for null. (Origin: call to remove(...) modelled in modelTables.ml at line 268)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/NullMethodCall.java, codetoanalyze.java.nullsafe_gradual.NullMethodCall.testMapRemoveBad(java.util.Map,java.util.HashMap,java.util.concurrent.ConcurrentHashMap):void, 4, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [The value of `chm.remove(...)` in the call to `toString()` is nullable and is not locally checked for null. (Origin: call to remove(...) modelled in modelTables.ml at line 269)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/NullMethodCall.java, codetoanalyze.java.nullsafe_gradual.NullMethodCall.testNotDetectingInvariantFP(java.lang.Object,java.lang.Object):java.lang.String, 4, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [The value of `object2` in the call to `toString()` is nullable and is not locally checked for null. (Origin: method parameter object2)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/NullMethodCall.java, codetoanalyze.java.nullsafe_gradual.NullMethodCall.testPathGetParent():java.lang.String, 1, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [The value of `get(...).getParent()` in the call to `toString()` is nullable and is not locally checked for null. (Origin: call to getParent() modelled in modelTables.ml at line 360)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/NullMethodCall.java, codetoanalyze.java.nullsafe_gradual.NullMethodCall.testSystemGetPropertyReturn():void, 2, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [The value of `s` in the call to `length()` is nullable and is not locally checked for null. (Origin: call to getProperty(...) modelled in modelTables.ml at line 235)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/NullMethodCall.java, codetoanalyze.java.nullsafe_gradual.NullMethodCall.testSystemGetenvBad():int, 2, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [The value of `envValue` in the call to `length()` is nullable and is not locally checked for null. (Origin: call to getenv(...) modelled in modelTables.ml at line 240)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/NullMethodCall.java, codetoanalyze.java.nullsafe_gradual.NullMethodCall.withConditionalAssignemnt(codetoanalyze.java.nullsafe_gradual.NullMethodCall$AnotherI,boolean,java.lang.Object,java.lang.Object):void, 2, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [The value of `i` in the call to `withObjectParameter(...)` is nullable and is not locally checked for null. (Origin: method parameter i)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/NullMethodCall.java, codetoanalyze.java.nullsafe_gradual.NullMethodCall.withConjuction(codetoanalyze.java.nullsafe_gradual.NullMethodCall$AnotherI,boolean,boolean):void, 1, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [The value of `i` in the call to `withBooleanParameter(...)` is nullable and is not locally checked for null. (Origin: method parameter i)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ParameterNotNullable.java, codetoanalyze.java.nullsafe_gradual.ParameterNotNullable$ConstructorCall.<init>(codetoanalyze.java.nullsafe_gradual.ParameterNotNullable,int), 1, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`ParameterNotNullable$ConstructorCall(...)` needs a non-null value in parameter 2 but argument `null` can be null. (Origin: null constant at line 101)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ParameterNotNullable.java, codetoanalyze.java.nullsafe_gradual.ParameterNotNullable.callNull():void, 2, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`ParameterNotNullable.test(...)` needs a non-null value in parameter 1 but argument `s` can be null. (Origin: null constant at line 39)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ParameterNotNullable.java, codetoanalyze.java.nullsafe_gradual.ParameterNotNullable.callNullable(java.lang.String):void, 1, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`ParameterNotNullable.test(...)` needs a non-null value in parameter 1 but argument `s` can be null. (Origin: method parameter s)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ParameterNotNullable.java, codetoanalyze.java.nullsafe_gradual.ParameterNotNullable.callWithConditionalAssignment(java.lang.Object,boolean):void, 1, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`ParameterNotNullable.doesNotAcceptNullableFirstParameter(...)` needs a non-null value in parameter 1 but argument `object` can be null. (Origin: null constant at line 116)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ParameterNotNullable.java, codetoanalyze.java.nullsafe_gradual.ParameterNotNullable.callWithNullableFirstParameter(boolean,boolean):void, 1, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`ParameterNotNullable.doesNotAcceptNullableFirstParameter(...)` needs a non-null value in parameter 1 but argument `formal parameter object` can be null. (Origin: null constant at line 112)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ParameterNotNullable.java, codetoanalyze.java.nullsafe_gradual.ParameterNotNullable.testClassGetResourceArgument(java.lang.Class):java.net.URL, 1, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`Class.getResource(...)` needs a non-null value in parameter 1 but argument `null` can be null. (Origin: null constant at line 81)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ParameterNotNullable.java, codetoanalyze.java.nullsafe_gradual.ParameterNotNullable.testImmutableListCopyOfNotNullArguments():void, 6, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`ImmutableList.copyOf(...)` needs a non-null value in parameter 1 but argument `nullIterable` can be null. (Origin: null constant at line 131)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ParameterNotNullable.java, codetoanalyze.java.nullsafe_gradual.ParameterNotNullable.testImmutableListCopyOfNotNullArguments():void, 7, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`ImmutableList.copyOf(...)` needs a non-null value in parameter 1 but argument `nullIterator` can be null. (Origin: null constant at line 132)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ParameterNotNullable.java, codetoanalyze.java.nullsafe_gradual.ParameterNotNullable.testImmutableListCopyOfNotNullArguments():void, 8, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`ImmutableList.copyOf(...)` needs a non-null value in parameter 1 but argument `nullCollection` can be null. (Origin: null constant at line 133)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ParameterNotNullable.java, codetoanalyze.java.nullsafe_gradual.ParameterNotNullable.testImmutableListOfnotNullArguments():void, 4, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`ImmutableList.of(...)` needs a non-null value in parameter 1 but argument `null` can be null. (Origin: null constant at line 123)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ParameterNotNullable.java, codetoanalyze.java.nullsafe_gradual.ParameterNotNullable.testImmutableListOfnotNullArguments():void, 5, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`ImmutableList.of(...)` needs a non-null value in parameter 1 but argument `null` can be null. (Origin: null constant at line 124)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ParameterNotNullable.java, codetoanalyze.java.nullsafe_gradual.ParameterNotNullable.testImmutableListOfnotNullArguments():void, 5, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`ImmutableList.of(...)` needs a non-null value in parameter 2 but argument `null` can be null. (Origin: null constant at line 124)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ParameterNotNullable.java, codetoanalyze.java.nullsafe_gradual.ParameterNotNullable.testImmutableListOfnotNullArguments():void, 7, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`ImmutableList.of(...)` needs a non-null value in parameter 2 but argument `null` can be null. (Origin: null constant at line 126)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ParameterNotNullable.java, codetoanalyze.java.nullsafe_gradual.ParameterNotNullable.testImmutableListSortedCopyOfNotNullArguments():void, 1, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`ImmutableList.sortedCopyOf(...)` needs a non-null value in parameter 1 but argument `null` can be null. (Origin: null constant at line 141)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ParameterNotNullable.java, codetoanalyze.java.nullsafe_gradual.ParameterNotNullable.testImmutableListSortedCopyOfNotNullArguments():void, 1, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`ImmutableList.sortedCopyOf(...)` needs a non-null value in parameter 2 but argument `null` can be null. (Origin: null constant at line 141)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ParameterNotNullable.java, codetoanalyze.java.nullsafe_gradual.ParameterNotNullable.testImmutableMapCopyOfNotNullArguments():void, 5, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`ImmutableMap.copyOf(...)` needs a non-null value in parameter 1 but argument `nullIterable` can be null. (Origin: null constant at line 177)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ParameterNotNullable.java, codetoanalyze.java.nullsafe_gradual.ParameterNotNullable.testImmutableMapCopyOfNotNullArguments():void, 6, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`ImmutableMap.copyOf(...)` needs a non-null value in parameter 1 but argument `nullMap` can be null. (Origin: null constant at line 178)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ParameterNotNullable.java, codetoanalyze.java.nullsafe_gradual.ParameterNotNullable.testImmutableMapOfnotNullArguments():void, 4, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`ImmutableMap.of(...)` needs a non-null value in parameter 1 but argument `null` can be null. (Origin: null constant at line 170)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ParameterNotNullable.java, codetoanalyze.java.nullsafe_gradual.ParameterNotNullable.testImmutableMapOfnotNullArguments():void, 4, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`ImmutableMap.of(...)` needs a non-null value in parameter 2 but argument `null` can be null. (Origin: null constant at line 170)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ParameterNotNullable.java, codetoanalyze.java.nullsafe_gradual.ParameterNotNullable.testImmutableMapOfnotNullArguments():void, 6, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`ImmutableMap.of(...)` needs a non-null value in parameter 2 but argument `null` can be null. (Origin: null constant at line 172)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ParameterNotNullable.java, codetoanalyze.java.nullsafe_gradual.ParameterNotNullable.testImmutableMapOfnotNullArguments():void, 6, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`ImmutableMap.of(...)` needs a non-null value in parameter 4 but argument `null` can be null. (Origin: null constant at line 172)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ParameterNotNullable.java, codetoanalyze.java.nullsafe_gradual.ParameterNotNullable.testImmutableSetCopyOfNotNullArguments():void, 6, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`ImmutableSet.copyOf(...)` needs a non-null value in parameter 1 but argument `nullIterable` can be null. (Origin: null constant at line 157)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ParameterNotNullable.java, codetoanalyze.java.nullsafe_gradual.ParameterNotNullable.testImmutableSetCopyOfNotNullArguments():void, 7, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`ImmutableSet.copyOf(...)` needs a non-null value in parameter 1 but argument `nullIterator` can be null. (Origin: null constant at line 158)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ParameterNotNullable.java, codetoanalyze.java.nullsafe_gradual.ParameterNotNullable.testImmutableSetCopyOfNotNullArguments():void, 8, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`ImmutableSet.copyOf(...)` needs a non-null value in parameter 1 but argument `nullCollection` can be null. (Origin: null constant at line 159)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ParameterNotNullable.java, codetoanalyze.java.nullsafe_gradual.ParameterNotNullable.testImmutableSetOfnotNullArguments():void, 4, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`ImmutableSet.of(...)` needs a non-null value in parameter 1 but argument `null` can be null. (Origin: null constant at line 148)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ParameterNotNullable.java, codetoanalyze.java.nullsafe_gradual.ParameterNotNullable.testImmutableSetOfnotNullArguments():void, 5, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`ImmutableSet.of(...)` needs a non-null value in parameter 1 but argument `null` can be null. (Origin: null constant at line 149)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ParameterNotNullable.java, codetoanalyze.java.nullsafe_gradual.ParameterNotNullable.testImmutableSetOfnotNullArguments():void, 5, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`ImmutableSet.of(...)` needs a non-null value in parameter 2 but argument `null` can be null. (Origin: null constant at line 149)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ParameterNotNullable.java, codetoanalyze.java.nullsafe_gradual.ParameterNotNullable.testImmutableSetOfnotNullArguments():void, 7, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`ImmutableSet.of(...)` needs a non-null value in parameter 2 but argument `null` can be null. (Origin: null constant at line 151)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ParameterNotNullable.java, codetoanalyze.java.nullsafe_gradual.ParameterNotNullable.testImmutableSetOfnotNullArguments():void, 8, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`ImmutableSet.of(...)` needs a non-null value in parameter 2 but argument `null` can be null. (Origin: null constant at line 152)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ParameterNotNullable.java, codetoanalyze.java.nullsafe_gradual.ParameterNotNullable.testImmutableSetOfnotNullArguments():void, 8, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`ImmutableSet.of(...)` needs a non-null value in parameter 4 but argument `null` can be null. (Origin: null constant at line 152)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ParameterNotNullable.java, codetoanalyze.java.nullsafe_gradual.ParameterNotNullable.testParsingNullStringToNumber():void, 2, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`Long.parseLong(...)` needs a non-null value in parameter 1 but argument `ns` can be null. (Origin: null constant at line 185)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ParameterNotNullable.java, codetoanalyze.java.nullsafe_gradual.ParameterNotNullable.testParsingNullStringToNumber():void, 3, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`Integer.parseInt(...)` needs a non-null value in parameter 1 but argument `ns` can be null. (Origin: null constant at line 185)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ParameterNotNullable.java, codetoanalyze.java.nullsafe_gradual.ParameterNotNullable.testSystemGetPropertyArgument():java.lang.String, 1, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`System.getProperty(...)` needs a non-null value in parameter 1 but argument `null` can be null. (Origin: null constant at line 71)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ParameterNotNullable.java, codetoanalyze.java.nullsafe_gradual.ParameterNotNullable.testSystemGetenvBad():java.lang.String, 1, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`System.getenv(...)` needs a non-null value in parameter 1 but argument `null` can be null. (Origin: null constant at line 77)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ParameterNotNullable.java, codetoanalyze.java.nullsafe_gradual.ParameterNotNullable.testThreeParameters():void, 2, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`ParameterNotNullable.threeParameters(...)` needs a non-null value in parameter 1 but argument `null` can be null. (Origin: null constant at line 88)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ParameterNotNullable.java, codetoanalyze.java.nullsafe_gradual.ParameterNotNullable.testThreeParameters():void, 3, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`ParameterNotNullable.threeParameters(...)` needs a non-null value in parameter 2 but argument `null` can be null. (Origin: null constant at line 89)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ParameterNotNullable.java, codetoanalyze.java.nullsafe_gradual.ParameterNotNullable.testThreeParameters():void, 4, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`ParameterNotNullable.threeParameters(...)` needs a non-null value in parameter 3 but argument `null` can be null. (Origin: null constant at line 90)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/Redundant.java, Redundant.bad():void, 2, ERADICATE_CONDITION_REDUNDANT, no_bucket, WARNING, [The condition s is always true according to the existing annotations.]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ReturnNotNullable.java, codetoanalyze.java.nullsafe_gradual.ReturnNotNullable$ConditionalAssignment.test(boolean):java.lang.Object, 0, ERADICATE_RETURN_NOT_NULLABLE, no_bucket, WARNING, [Method `test(...)` may return null but it is not annotated with `@Nullable`. (Origin: field ReturnNotNullable$ConditionalAssignment.f1 at line 213)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ReturnNotNullable.java, codetoanalyze.java.nullsafe_gradual.ReturnNotNullable.constantToNullableIsOverannotated():java.lang.String, 0, ERADICATE_RETURN_OVER_ANNOTATED, no_bucket, WARNING, [Method `constantToNullableIsOverannotated()` is annotated with `@Nullable` but never returns null.]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ReturnNotNullable.java, codetoanalyze.java.nullsafe_gradual.ReturnNotNullable.getResourceNullable(java.lang.Class,java.lang.String):java.net.URL, 0, ERADICATE_RETURN_NOT_NULLABLE, no_bucket, WARNING, [Method `getResourceNullable(...)` may return null but it is not annotated with `@Nullable`. (Origin: call to getResource(...) modelled in modelTables.ml at line 191)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ReturnNotNullable.java, codetoanalyze.java.nullsafe_gradual.ReturnNotNullable.nonNullToNullableIsOverannotated(java.lang.String):java.lang.String, 0, ERADICATE_RETURN_OVER_ANNOTATED, no_bucket, WARNING, [Method `nonNullToNullableIsOverannotated(...)` is annotated with `@Nullable` but never returns null.]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ReturnNotNullable.java, codetoanalyze.java.nullsafe_gradual.ReturnNotNullable.notAnnotatedNullableIsOverannotated(java.lang.String):java.lang.String, 0, ERADICATE_RETURN_OVER_ANNOTATED, no_bucket, WARNING, [Method `notAnnotatedNullableIsOverannotated(...)` is annotated with `@Nullable` but never returns null.]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ReturnNotNullable.java, codetoanalyze.java.nullsafe_gradual.ReturnNotNullable.nullToNonnullIsBad():java.lang.String, 0, ERADICATE_RETURN_NOT_NULLABLE, no_bucket, WARNING, [Method `nullToNonnullIsBad()` may return null but it is not annotated with `@Nullable`. (Origin: null constant at line 60)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ReturnNotNullable.java, codetoanalyze.java.nullsafe_gradual.ReturnNotNullable.nullToNotAnnotatedIsBad():java.lang.String, 0, ERADICATE_RETURN_NOT_NULLABLE, no_bucket, WARNING, [Method `nullToNotAnnotatedIsBad()` may return null but it is not annotated with `@Nullable`. (Origin: null constant at line 35)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ReturnNotNullable.java, codetoanalyze.java.nullsafe_gradual.ReturnNotNullable.nullableToNonnullIsBad(java.lang.String):java.lang.String, 0, ERADICATE_RETURN_NOT_NULLABLE, no_bucket, WARNING, [Method `nullableToNonnullIsBad(...)` may return null but it is not annotated with `@Nullable`. (Origin: method parameter s)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ReturnNotNullable.java, codetoanalyze.java.nullsafe_gradual.ReturnNotNullable.nullableToNotAnnotatedIsBad(java.lang.String):java.lang.String, 0, ERADICATE_RETURN_NOT_NULLABLE, no_bucket, WARNING, [Method `nullableToNotAnnotatedIsBad(...)` may return null but it is not annotated with `@Nullable`. (Origin: method parameter s)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ReturnNotNullable.java, codetoanalyze.java.nullsafe_gradual.ReturnNotNullable.redundantEq():java.lang.String, 0, ERADICATE_RETURN_OVER_ANNOTATED, no_bucket, WARNING, [Method `redundantEq()` is annotated with `@Nullable` but never returns null.]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ReturnNotNullable.java, codetoanalyze.java.nullsafe_gradual.ReturnNotNullable.redundantEq():java.lang.String, 2, ERADICATE_CONDITION_REDUNDANT_NONNULL, no_bucket, WARNING, [The condition s is always false according to the existing annotations.]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ReturnNotNullable.java, codetoanalyze.java.nullsafe_gradual.ReturnNotNullable.redundantNeq():java.lang.String, 0, ERADICATE_RETURN_OVER_ANNOTATED, no_bucket, WARNING, [Method `redundantNeq()` is annotated with `@Nullable` but never returns null.]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ReturnNotNullable.java, codetoanalyze.java.nullsafe_gradual.ReturnNotNullable.redundantNeq():java.lang.String, 2, ERADICATE_CONDITION_REDUNDANT_NONNULL, no_bucket, WARNING, [The condition s is always true according to the existing annotations.]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ReturnNotNullable.java, codetoanalyze.java.nullsafe_gradual.ReturnNotNullable.return_null_in_catch():java.lang.String, 0, ERADICATE_RETURN_NOT_NULLABLE, no_bucket, WARNING, [Method `return_null_in_catch()` may return null but it is not annotated with `@Nullable`. (Origin: null constant at line 174)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ReturnNotNullable.java, codetoanalyze.java.nullsafe_gradual.ReturnNotNullable.return_null_in_catch_after_throw():java.lang.String, 0, ERADICATE_RETURN_NOT_NULLABLE, no_bucket, WARNING, [Method `return_null_in_catch_after_throw()` may return null but it is not annotated with `@Nullable`. (Origin: null constant at line 186)]
|
|
||||||
codetoanalyze/java/nullsafe-gradual/ReturnNotNullable.java, codetoanalyze.java.nullsafe_gradual.ReturnNotNullable.tryWithResourcesReturnNullable(java.lang.String):java.lang.Object, 0, ERADICATE_RETURN_NOT_NULLABLE, no_bucket, WARNING, [Method `tryWithResourcesReturnNullable(...)` may return null but it is not annotated with `@Nullable`. (Origin: call to nullToNullableIsOK() at line 156)]
|
|
Loading…
Reference in new issue