|
|
|
|
|
by JnRouvignac
4035 days ago
|
|
I am the author of AutoRefactor.
If you only need multi-catch refactorings and have never seen the other pieces of code, then you are the luckiest Java developer I have heard off. You are probably working on a green field project with a small team of exceptionally talented people. For people not in that case, chances are they are inheriting a very large code base originally written with Java 1.4 or (shudder) even earlier. They are working with some people that never manage to get the simplest indentations right, let alone the code patterns you saw. The size and age of the code base made for numerous failed attempts at running checks type. Finally, the team is so big that no human can review all the code changes pre or post commit. Believe me, this exist and I think this is probably most of the code written. Concerning the not null case, I agree this one is very subjective. I hesitated a lot before adding it. It is not as broad as what you think it is. It is only touching if statements when the then and else clauses are similar. Say
if (o == null) return null; else return o.toString();
I am arguing that the cognitive load is less important when the if statement is inverted. i.e.
if (o != null) return o.toString(); else return null;
Or with ternary operator:
return o != null ? o.toString() : null; You can disagree and then not run this particular rule. |
|
I suppose I'm willing to accept that I've been lucky though, and god help anyone whose code has the sorts of problems I wrote off as being unacceptable.