-
Notifications
You must be signed in to change notification settings - Fork 459
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
No longer be lenient with FormatterSteps returning null.
- Loading branch information
Showing
1 changed file
with
2 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
08673f2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nedtwigg I wonder if I could have your opinion on whether we should allow users to create
FormatterStep
s that return null strings.IMO it doesn't really make sense to allow this, as null doesn't mean anything in this context AFAICT. The way I see it, a null return-value may (1) indicate bug(s) in user FormatterSteps, and (2) be rather error-prone for us, in case we forget that
FormatterStep
s can return null and we don't write Spotless's code defensively enough.However, I wanted to hear your thoughts on this, as I think I may have missed some good reasons for allowing FormatterSteps to return
@Nullable
strings in the first place.08673f2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason for allowing null return values is this issue:
#46
08673f2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I admit I'm still not sure why
null
is allowed as a valid return value in this case. Is it because Groovy closures themselves returnnull
if they don't return any other value?08673f2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, they return null. Not a big deal to ask people to return the argument, but also not a big deal to handle null cleanly. I opted to allow null because I had never seen a bug in spotless caused by accidental null return, but I had a usecase in front of me that benefitted from it.
08673f2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, that sounds pretty reasonable to me! I've got a local commit that reverts this one, so I'll start pushing now. :)