This is post 4 in my open source series. After Zalando Logbook and the Adyen Java library, this one is about Picnic's error-prone-support , and it has a twist: the PR I opened got stuck in a broken state on GitHub, and I had to recreate it.
What is error-prone-support?
error-prone-support is an open source project from Picnic. It extends Google's Error Prone with extra bug checks and Refaster rules . A Refaster rule says "this code pattern should be rewritten like this", and it can fix it automatically across a codebase.
What I worked on
The project already had a rule called RequireNonNullExpression . I extended it to cover this pattern:
// Before: Optional.of() throws a NullPointerException if value is null, // so the Optional can never be empty. The orElse() part is dead code. String result = Optional . of ( value ). orElse ( fallback );
// After: says exactly what the code really does String result = requireNonNull ( value );
Enter fullscreen mode
Exit fullscreen mode
The idea is simple.…