VS 2005 introduced internal static analysis tools. This helps you to write secure and quality code.
Visual Studio 2008 has new Code Analysis features:
- Code Metrics - This gives you the ability to dig deep to find those un-maintainable and complex hotspots. Code Metrics will ship with five metrics - Cyclomatic Complexity, Depth of Inheritance, Class Coupling, Lines of Code and Maintainability Index.
- Analysis improvements:
- Support for analyzing anonymous methods and lambda expressions
- Reduced noise in existing analysis and the ability to skip over tool generated code
- New analysis, including additional rules around security, globalization, maintainability and spelling.
To generate code metrics, simply do the following:In Solution Explorer, right-click on your solution/project and choose Generate Code Metrics
After generation you'll get the Code Metrics Results window and a tooltip on every column that explain the result. The Maintainability Index column includes a maintainability indicator light that changes based on the maintainability of the code. Green indicates good maintainability, yellow indicates moderate maintainability, and red indicates poor maintainability.