Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add models for Apache StringUtils isEmpty methods #264

Merged
merged 2 commits into from Dec 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions gradle/dependencies.gradle
Expand Up @@ -67,6 +67,8 @@ def test = [
// freeze at 2.5.5 since it's not supported afterward
cfCompatQual : "org.checkerframework:checker-compat-qual:2.5.5",
rxjava2 : "io.reactivex.rxjava2:rxjava:2.1.2",
commonsLang3 : "org.apache.commons:commons-lang3:3.8.1",
commonsLang : "commons-lang:commons-lang:2.6",
]

ext.deps = [
Expand Down
2 changes: 2 additions & 0 deletions nullaway/build.gradle
Expand Up @@ -54,6 +54,8 @@ dependencies {
testCompile deps.test.inferAnnotations
testCompile deps.apt.javaxInject
testCompile deps.test.rxjava2
testCompile deps.test.commonsLang
testCompile deps.test.commonsLang3
}

javadoc {
Expand Down
Expand Up @@ -294,6 +294,11 @@ private static class DefaultLibraryModels implements LibraryModels {
.put(methodRef(Strings.class, "isNullOrEmpty(java.lang.String)"), 0)
.put(methodRef(Objects.class, "isNull(java.lang.Object)"), 0)
.put(methodRef("android.text.TextUtils", "isEmpty(java.lang.CharSequence)"), 0)
.put(methodRef("org.apache.commons.lang.StringUtils", "isEmpty(java.lang.String)"), 0)
.put(
methodRef(
"org.apache.commons.lang3.StringUtils", "isEmpty(java.lang.CharSequence)"),
0)
.build();

private static final ImmutableSet<MethodRef> NULLABLE_RETURNS =
Expand Down
Expand Up @@ -308,4 +308,17 @@ static void androidStuff() {
s.hashCode();
}
}

static void apacheCommonsStuff() {
String s = null;
if (!org.apache.commons.lang.StringUtils.isEmpty(s)) {
// no warning due to isEmpty check
s.hashCode();
}
String t = null;
if (!org.apache.commons.lang3.StringUtils.isEmpty(t)) {
// no warning due to isEmpty check
t.hashCode();
}
}
}