Skip to content

Commit

Permalink
Add models for Apache StringUtils isEmpty methods (#264)
Browse files Browse the repository at this point in the history
  • Loading branch information
msridhar committed Dec 4, 2018
1 parent f1a8751 commit fc406a1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
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 @@ -310,4 +310,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();
}
}
}

0 comments on commit fc406a1

Please sign in to comment.