Chapter 19

Code Analysis, Code Metrics, and Code Clone Analysis

What's In This Chapter?

  • Enabling and running code analysis in Visual Studio 2012
  • Correcting code analysis rule violations
  • Understanding code metrics and how to use them
  • Using Code Clone Analysis to find similar code fragments in your code base

Wrox.com Code Downloads for this Chapter

The wrox.com code downloads for this chapter are found at www.wrox.com/remtitle.cgi?isbn=1118314081 on the Download Code tab. The files are in the Chapter 19 download folder and individually named as shown throughout this chapter.

This chapter describes the code analysis, code metric, and code clone analysis features included with the Visual Studio 2012 Premium and Ultimate editions. These tools can quickly and easily inspect your code to find common mistakes, make suggestions for improvements, and even indicate violations of standards.

The discussion begins by examining the origins of the Static Code Analysis tool. You find out about Microsoft's .NET “Design Guidelines for Class Library Developers” and how it is related to the tools. You also take a brief look at what is new with these tools in Visual Studio 2012.

Then you do a bit of exploration into the code analysis itself and how to take advantage of its full integration with Visual Studio 2012. This includes enabling static code analysis review for your projects, selecting rules to apply, and working with the results of the analysis.

However, using the IDE is not always an option, ...

Get Professional Application Lifecycle Management with Visual Studio 2012 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.