Null pointer exception due to workingTreeIterator being null for git ignored files.
If there is a file that is already committed and later becomes a part of .gitignore, this file creates a null pointer exception in spotless when used with ratchetFrom.
This happens because workingTreeIterator evaluates to null (here) for these files.
This is an exceptional case so maybe by adding a null check, we will ignore these files?
Steps to recreate the bug(example repo)
- I created a file
Wow.jsinside a packageuseless(commit) - In a later commit I gitignored this package (names useless) (commit).
- Now even though the package is git ignored the file
Wow.javawill always be there as it was already committed and will create problems for spotless when used withratchetFrom. - Now if I add spotless it to the project,
spotlessCheckfails with a null pointer exception due to this file. (commit)
Technical Details
- Gradle Version:
Gradle 6.1.1 - Spotless version:
5.12.4 - Os:
macOS Big Sur 11.2.2 - Test project: here