Hari
Hari

Reputation: 103

Enforce java 8 conventions using checkStyle

I'm looking to enforce some best practices for Java 8 using checkStyle, some examples include:

  1. Don't nest optionals
  2. Limit lambdas to x lines if it's in the middle of stream transformations
  3. General warning against parallel stream

Based on my research, I can see that checkStyle supports java 8, but nothing specific to enforcing standards on features.

Is this something that's available?

Thanks for your help.

Upvotes: 6

Views: 573

Answers (1)

Brandon McKenzie
Brandon McKenzie

Reputation: 1685

If checkstyle supports it out of the box, it'll be listed among the standard checks that checkstyle comes with (I didn't see any when I glanced over it, unfortunately). If it's not in that list, I would then start looking at third party checkstyle libraries (such as SevNTU Checkstyle, Checkstyle Addons, and CS-Contrib among them) to see if you can find checks that satisfy your needs. If you are still unable to find anything, you might have to implement the checks yourself. If you do, you might want to consider contributing them to the community, winning the eternal gratitude of checkstyle users around the world.

Upvotes: 3

Related Questions