Menu

How I Extended a Refaster Rule in Picnic's error-prone-support (and Recovered a PR GitHub Broke)
📰

How I Extended a Refaster Rule in Picnic's error-prone-support (and Recovered a PR GitHub Broke)

DEV Community: java·VINAYAK GOTE·12 days ago
#MazObSPg
#devtojava#devto#dev#code#error
Reading 0:00
15s threshold

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.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.