4.6. Static Analysis Tools Generate No Errors

Any static analysis tools that run as part of the build should generate no errors/warnings. This one only applies if you are using such tools, but if you aren't, you probably should. Tools like FxCop (from Microsoft) or the static analysis tools of choice for your platform should generate no errors or warnings on the code you just finished. Static analysis tools (discussed further in Chapter 7, "Static Analysis") can be run as part of your build to detect problems with the code, such as excessive coupling, interface guideline violations, or other problems that can be detected by looking at your code while it isn't running.

If, for example, you are shipping a library that your customers will use to develop their own software, it is worth running a tool such as FxCop that checks to make sure that you are following best practices for naming your properties and methods, validating your input parameters, and for other aspects of the code that may affect the usability of your interface(s).

From an architectural perspective, you may want to run static analysis tools, such as NDepend from the NET world, which measures how loosely or tightly coupled your libraries are, how many dependencies your code has, or other design/architecture issues that may affect how easy (or not) it is to understand and maintain your code.

Other tools, such as Simian, check for code that is duplicated in more than one place, which may indicate a need for refactoring. ...

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

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.