7.2. Who Benefits from Static Analysis?

Who will benefit from static analysis depends on what kind of data is gathered and the tools used. Choosing who should see what data is, I believe, an instrumental part of using such tools. Again, the biggest risk to introducing these tools is information overload, so making sure that the right level of information gets to the right people is an important part of their use.

Some metrics such as cyclomatic complexity can be useful to every developer. CC metrics can be distributed to your whole team. Every coder can benefit from understanding where code may be too complicated so that it can be simplified either right away or as time allows. If you are following a red/green/refactor style of Test-Driven Development (TDD), running a CC report after making your tests pass can point to the best places for refactoring. Correlating cyclomatic complexity with code coverage is a great way to target your unit-testing efforts.

For some of the more obscure metrics, however, such a wide distribution may not be a good idea. Trying to get every member of your team to understand the difference between afferent and efferent coupling, and training them to know what to do about either of them may be more trouble than it is worth. The more widely you distribute those kinds of metrics, the more likely that developers will start coding to the metrics, or changing code just to make the numbers change without a proper understanding of why or what they are doing. ...

Get Code Leader: Using People, Tools, and Processes to Build Successful Software now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.