if(obj == null && obj.isValid())
I'd have approximately 960 dollars per project.
Why would you encounter this (often)? It seems to me that this code would never evaluate to true.
> if (obj != null && obj.isValid()) { }
Which is semantically correct due to the fail-fast evaluate of AND, it does require a double check since it's strange from a logic point of view. This is one the reasons that brace languages are hard to optimize since you can't commute things that ought to commute.
If the two checks were independent (pure functions), it's not difficult for a compiler to determine that given enough program visibility.
This check is obviously erroneous, and found via SCA. I was saying "if I had a dollar for every time I found this [via SCA] I'd have a lot of money."
Why do you think you are encountering this particular mistake so often? Is it something about your projects, your organization, your colleagues, or Java itself?
I think it had a lasting effect on my personal coding habits. But every once in a while, I will use the tools on my new code and it still finds things. I would probably benefit from being more persistent in using these tools.
[1]: This assumes that the issues caught be your static analysis tool are valid concerns, which in my experience, they tend to be.
[2]: Some static analysis tools that I've used with Ruby are reek, roodi, flay, and flog. Reek and roodi report code smells. Flay reports structural similarities (opportunities for refactoring). And flog estimates the complexity of your methods.