
In a development life cycle, Code Reviews play an essential role to gauge the quality of a product.
There are multifold benefits of having a stringent code review in place:
- Finding defects at an earlier stage helps us in avoiding complexities post deployment.
- Complying with coding standards helps us to keep our Technical Debt in check.§
But how do we ensure that our review process is efficient? Apart from verifying the functionality, what are the other things a code reviewer needs to look for?
A developer might have made the correct functional changes, but he/she might have violated some fundamental design principles/coding standards.
This makes the role of a Code Reviewer critical. How do we ‘smell’ the various issues with the code?
What is a Code Smell
In simple terms, we can define it as bad practices or design flaws, which might require attention, either immediately or at a later point of time.
Building up Technical Debt is always a red flag and the earlier we identify and fix issues, the better it is.
Some of the common code smells are:
Long Method | Keeping our methods short and crisp, makes our |
Duplicate Code | CTRL-C and CTRL-V can be our enemy sometimes. |
Large Class | Ideally a class should have one responsibility. |
Dead Code | In the world of Source Control systems, |
Lack of Unit Tests | Having good code coverage gives us confidence that |
How to identify these Code Smells
In Visual Studio, we can identify Code Smells and take decisions to apply the required refactoring. And here comes ‘Code Metrics’ to our rescue.
Code Metrics is a tool which analyzes our project, measures the complexity and provides us better insight into the code.
The Code Metrics Results window is a one stop place which helps us understand how maintainable our code is.
To generate code metrics for our project, we can go to Analyze Menu, then Calculate Code Metrics

What does the Code Metrics Results show
Be it a developer or a reviewer, Code Metrics helps us identify the places in the code where rework is necessary. It provides us with 5 metrics:
- Maintainability Index: It indicates how easy it should be to understand & modify the code, in a scale of 0 to 100. High value means better maintainability.
- Cyclomatic Complexity: It indicates the number of possible routes through a unit of code. Less value means better maintainability.
- Depth of Inheritance: It indicates the length of inheritance hierarchy in the class. Less value means better maintainability.
- Class Coupling: It indicates the number of dependencies that an item has. Less value means better maintainability.
- Lines of Code: Lesser the lines of code in a method/class, more is the maintainability.

Identify Duplicate Code using Code Clone Analysis
To perform code clone analysis for our project, we can go to Analyze Menu, then Analyze Solution for Code Clones
The Code Clone Analyzer in Visual Studio helps us to search duplicate code in the entire project.
Thus to summarize, we can use Code Metrics to identify code smells or as a double check/safety net to ensure that we are complying with coding standards and not building up our technical debt.

Ashish SrivastavaPosted May 12, 2016, 4:52 AM
Good one
Asfend YarPosted Mar 5, 2016, 9:43 AM
good
Shashangka ShekharPosted Jan 28, 2016, 4:45 AM
Nice info Thanks... :)
Samir BeharaPosted Jan 27, 2016, 9:33 PM
Thanks all. Here is the link to my blog - http://dotnetvibes.com/
Santhakumar MunuswamyPosted Jan 27, 2016, 1:52 PM
Thanks for nice share
Debasis SahaPosted Jan 27, 2016, 9:07 AM
Good one..
Raja TPosted Jan 27, 2016, 8:04 AM
Nice, Thanks for sharing
Ankit BansalPosted Jan 27, 2016, 6:14 AM
Nice share..thanks..
Humayun Kabir MamunPosted Jan 27, 2016, 5:21 AM
Nice...
Muhammad Aqib ShehzadPosted Jan 27, 2016, 4:55 AM
nice dear