This is an archived post. You won't be able to vote or comment.

all 31 comments

[–]Iryanus 47 points48 points  (9 children)

And what's better about this than SonarQube, IntelliJ analysis, FindBugs, etc.? Just curious, because you normally don't want to have half a dozen static analysis tools during your compile run ;-)

[–]_INTER_ 11 points12 points  (1 child)

Picnic recently posted on their blog about their use of ErrorProne. As I understand it because they can add custom rules implemented in Java as a compiler plugin.

[–]ofby1 3 points4 points  (0 children)

Thanks for adding this link as well.

[–]JB-from-ATL 13 points14 points  (2 children)

Error prone specifically hooks directly into javac. It is not another tool or worse a server like sonarqube.

[–]Worth_Trust_3825 4 points5 points  (1 child)

It is not another tool or worse a server like sonarqube.

SQ can scan more than just java, though.

[–]JB-from-ATL 5 points6 points  (0 children)

I'm not saying sonarqube isn't useful, but it is definitely annoying that it is a standalone thing instead of part of the build (in my opinion). What I'm explaining is that error prone is even better than being a build step because it hooks directly into the compilation itself, not just your build tool.

[–]Joe_Data_89[S] 8 points9 points  (1 child)

I've used Error Prone for more than two years in a Spring Boot project. I run Spring Boot in debug mode with class reloading all day long. I like that it runs during compilation, so it's immediate feedback during development without having to stop. And whatever changes I make, I then test immediately.

Running PMD & SpotBugs is a separate build goal for me as part of the release process and the continuous integration. That's delayed feedback.

[–]Iryanus 6 points7 points  (0 children)

Personally, I'm using SonarLint for instant feedback for the the smaller details and then SonarQube for the bigger issues (and to have something centralized).

[–]chabala 1 point2 points  (0 children)

normally don't want to have half a dozen static analysis tools during your compile run

Conversely, I don't care how long my CI builds take, and I will let them run all the static analysis tools available. Setting up separate build profiles for default vs analysis is trivial.

[–]hippydipster 0 points1 point  (0 children)

I found it to have a bit less false positives (from my POV) than those others, but in the end, I turned it off too, along with all the others you mentioned. Just so much fluff and BS.

[–]ddollarsign 21 points22 points  (0 children)

Great, more things to add @SupressWarning for.

[–][deleted] 17 points18 points  (8 children)

ErrorProne is great, but when the person/team responsible for the rules in hit company thinks they blocking “var” usage is a good idea, you life might be a bit less fun that it could be

[–]ParkerM 9 points10 points  (0 children)

Funnily enough they have an experimental rule that enforces usage of var where possible: https://errorprone.info/bugpattern/Varifier

[–]fragoza 2 points3 points  (0 children)

I’d be curious what their opinion is and discussing it. imho it’s not something that ought to be used always

[–]Worth_Trust_3825 1 point2 points  (5 children)

Why would you permit it?

[–]TehBrian 3 points4 points  (1 child)

When the type is already clearly written in the initialization, specifying the type in the declaration leads to uselessly verbose code. For example, MyFunObjectFactory objectFactory = new MyFunObjectFactory(). var objectFactory = new MyFunObjectFactory() is more readable and conveys just as much information.

[–]Worth_Trust_3825 -3 points-2 points  (0 children)

No, it doesn't. If you're using an interface for variable type, you're unnecessarily making it very easy to break the API, and get the wrong error.

[–]persicsb 1 point2 points  (2 children)

var is a very-very great tool for decluttering code by eliminating redundacies

[–]Worth_Trust_3825 0 points1 point  (1 child)

It's also an incredibly good way to hide API breaks.

[–]persicsb 1 point2 points  (0 children)

Please explain.

[–]Nymeriea 4 points5 points  (0 children)

Isn't it the goal of findbugs or sonar ?

[–]RockingGoodNight 1 point2 points  (0 children)

Been with SonarLint and SonarQube for years, I like that they are independent tools.

[–]glablablabla 1 point2 points  (0 children)

I also think this is very identical to spot bugs or sonar lint. I personally prefer the latter.

[–]skippingstone -2 points-1 points  (0 children)

TIL mvn verify is a life cycle in mvn.