I like static code analysis.
I like how it reminds me how I can improve the code by applying certain refactoring patterns.
I like how it tells me how I can clean the code by using a new language feature I might not be aware of.
I like how it enforces a certain style and conventions on a codebase changed by several developers.
However, I have grown a special distate for static code analysis that’s run way too eagerly!
What do I mean by that? I do not like it when it’s run as I type the code. Done that way, it prevents me from finishing my thoughts. Many times I’m trying out ways to implement something, and I don’t like static analysis bugging me about things that aren’t important at that point in time. Treating those as errors make things even worse as the IDE shows red squigglies and distracts me.
I don’t like static analysis even when I compile the code. Why not? Because it gets in my way as I go through the Red-Green-Refactor process.
Static code analysis should run when we push the code to the central repository. At that point, check-in policies could block the commit if there are violations to the rules. Such analysis run any time before that is a productivity killer.