Skip to content

Commit

Permalink
Add library model for Apache Commons CollectionUtils.isNotEmpty (#932) (
Browse files Browse the repository at this point in the history
#1062)

Thank you for contributing to NullAway!

Please note that once you click "Create Pull Request" you will be asked
to sign our [Uber Contributor License
Agreement](https://cla-assistant.io/uber/NullAway) via [CLA
assistant](https://cla-assistant.io/).

Before pressing the "Create Pull Request" button, please provide the
following:

- [ ] Added library model for Apache Commons CollectionUtils.isNotEmpty

  - [ ] related to issue #932 

- [ ] `void apacheCollectionsCollectionUtilsIsNotEmpty()` and `void
apacheCollectionsCollectionUtilsIsNotEmpty()` tests have been added to
`FrameworkTests.java`
  • Loading branch information
pochopsp authored Oct 28, 2024
1 parent d6b7fa3 commit 8f4b928
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,16 @@ private static class DefaultLibraryModels implements LibraryModels {
.put(methodRef("spark.utils.StringUtils", "isNotBlank(java.lang.CharSequence)"), 0)
.put(methodRef("spark.utils.StringUtils", "hasLength(java.lang.String)"), 0)
.put(methodRef("spark.utils.StringUtils", "hasLength(java.lang.CharSequence)"), 0)
.put(
methodRef(
"org.apache.commons.collections.CollectionUtils",
"isNotEmpty(java.util.Collection)"),
0)
.put(
methodRef(
"org.apache.commons.collections4.CollectionUtils",
"isNotEmpty(java.util.Collection<?>)"),
0)
.put(
methodRef("org.apache.commons.lang.StringUtils", "isNotEmpty(java.lang.String)"), 0)
.put(
Expand Down
36 changes: 36 additions & 0 deletions nullaway/src/test/java/com/uber/nullaway/FrameworkTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,42 @@ public void apacheValidateStringValidIndex() {
.doTest();
}

@Test
public void apacheCollectionsCollectionUtilsIsNotEmpty() {
defaultCompilationHelper
.addSourceLines(
"Foo.java",
"package com.uber;",
"import org.apache.commons.collections.CollectionUtils;",
"import org.jetbrains.annotations.Nullable;",
"import java.util.List;",
"public class Foo {",
" public void bar(@Nullable List<String> s) {",
" if(CollectionUtils.isNotEmpty(s))",
" s.get(0);",
" }",
"}")
.doTest();
}

@Test
public void apacheCollections4CollectionUtilsIsNotEmpty() {
defaultCompilationHelper
.addSourceLines(
"Foo.java",
"package com.uber;",
"import org.apache.commons.collections4.CollectionUtils;",
"import org.jetbrains.annotations.Nullable;",
"import java.util.List;",
"public class Foo {",
" public void bar(@Nullable List<String> s) {",
" if(CollectionUtils.isNotEmpty(s))",
" s.get(0);",
" }",
"}")
.doTest();
}

@Test
public void filesIsDirectory() {
defaultCompilationHelper
Expand Down

0 comments on commit 8f4b928

Please sign in to comment.