[java] New rule ReturnEmptyCollectionRatherThanNull#3382
Merged
Conversation
- Deprecate the old ReturnEmptyArrayRatherThanNull, and supersede it with a new rule that contmplates not only arrays, but all members of the Java Collection Framework (Maps, Lists, Sets and even the legacy Vector and Hashtable).
Generated by 🚫 Danger |
jsotuyod
commented
Jul 10, 2021
Add reference to Effective Java
oowekyala
reviewed
Jul 11, 2021
Comment on lines
+30
to
+32
| The following Java rules are deprecated and removed from the quickstart ruleset, | ||
| as the new rule {% rule java/errorprone.xml/ReturnEmptyCollectionRatherThanNull %} supersedes it: | ||
| * {% rule java/errorprone.xml/ReturnEmptyArrayRatherThanNull %} |
Member
There was a problem hiding this comment.
Suggested change
| The following Java rules are deprecated and removed from the quickstart ruleset, | |
| as the new rule {% rule java/errorprone.xml/ReturnEmptyCollectionRatherThanNull %} supersedes it: | |
| * {% rule java/errorprone.xml/ReturnEmptyArrayRatherThanNull %} | |
| The rule {% rule java/errorprone.xml/ReturnEmptyArrayRatherThanNull %} is deprecated and removed from the quickstart ruleset, | |
| as the new rule {% rule java/errorprone.xml/ReturnEmptyCollectionRatherThanNull %} supersedes it. |
adangel
approved these changes
Jul 16, 2021
adangel
left a comment
Member
There was a problem hiding this comment.
Thanks!
I'll do the little fixups when merging
adangel
added a commit
that referenced
this pull request
Jul 16, 2021
adangel
added a commit
that referenced
this pull request
Jul 16, 2021
[java] New rule ReturnEmptyCollectionRatherThanNull #3382
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe the PR
Create a new
ReturnEmptyCollectionRatherThanNullto supersede the oldReturnEmptyArrayRatherThanNull.The same principle applies not only to arrays, but to all collections (
java.util.Collectionseven providing easy no-alloc methods to return empty maps, lists and sets).I doubted if this should more generally look at any
java.lang.Iterable, but I felt that was stretching it too much (and it would not on it's own consider maps).Ready?
./mvnw clean verifypasses (checked automatically by github actions)