Walking a Fine Line Between Correctness and Absurdity

One of the issues for this sprint was improving my code's correctness. I installed and used the Eclipse plugins FindBugs, PMD, and CheckStyle. While these did point out some very valid issues, including not properly closing database resources, doing really bad things in an override of equals, etc., they also pointed out some things that completely flummoxed me. The biggest example is that apparently in Java one can declare virtually anything as final, including method parameters.

I had known that methods and classes could be declared final though I had never used such functionality (nor had it explained or recommended either during my Bachelors degree or during my Masters degree, despite MANY Java-centric classes), but parameters was a new one. Some claim parameters should be declared final, while others say it clutters code for very little benefit. Additionally if you do, in fact, reassign a value to a parameter, the very same tools will mark it as an error. So there's quite a lot of debate as to whether this practice adds to or detracts from code clarity.

Additionally, at PMD flagged every use of System.out.println as an error (without telling me what else I should possibly be using for classes that were command line tools) and my use of Allman style for curly brackets (opening brackets go on their own line) was flagged as a warning by CheckStyle. Some things I had done, following dozens of examples I found online, were flagged (e.g. overriding javax.servlet.http.HttpServlet.doGet, which Tomcat's documentation says you might want to do). That one is pretty inexplicable and google yields no helpful info as to why it was flagged.

In the end practically every line of code was flagged for something or other, and if I followed all the advice given, it would probably take days to rewrite everything for very little actual benefit, not to mention contradicting reputable examples, in some cases. So while I paid attention to the highly ranked issues, I ended up having to ignore the vast majority without even really looking at them; it would take too long even to look through each and evaluate it individually.

My experience does make me question the helpfulness of PMD and CheckStyle, in particular. FindBugs is extremely easy to tweak and tell it to ignore certain types of violations, but I found virtually all of FindBugs' flags to be genuine issues, so I set it to check for everything anyway. CheckStyle I couldn't find ways to configure in a reasonable amount of time (I at least wanted it stop flagging every accursed opening curly bracket), and I would have had to turn off nearly everything anyhow. PMD was more easily configurable, but I still would've had to turn off so much it hardly seemed worth the effort.

So I finally decided where to draw the line: with FindBugs. Going beyond that ventures too far into the realms of absurdity.  I suspect there's valuable info hidden inside all the insane numbers of warnings in PMD and CheckStyle, but with limited time on my hands, I just don't have time to sift through the nonsense.

Comments

Popular posts from this blog

Git. The WHAT and WHY Edition.

"Does it get easier?" Yes, but Also No...

How to Land Your First Dev Job: Develop Yourself, Market Yourself