Background:
OpenJDK have released a style guide for local variable type inference.
I was looking for a checkstyle built in rule that addresses it but didn't found one.
What I'm trying to get is pretty simple but I'm not that familiar with writing custom Modules.
Example:
Allow:
- instance creation, it's clear what's being created
var something = new Anything(); // OK
- it's a literal, it's obvious what type it has
var something = "literal"; // OK
Violation:
- even with good naming, no clue what's the type
var something = anything.doAnything(); // Violation
- it improves readability to use var here
Anything<Foo<Bar>> something = new Anything<>(); // Violation
- not a big deal but just for consistency
String something = "literal"; // Violation
Question:
Is there any existing rule I can extend / tweak to get the above? Should I try writing my own rule? I assume RegExp can handle some cases but not all.