Rawr Code Clone Analysis–Part 0
- by Dylan Smith
Code Clone Analysis is a cool new feature in Visual Studio 11 (vNext). It analyzes all the code in your solution and attempts to identify blocks of code that are similar, and thus candidates for refactoring to eliminate the duplication. The power lies in the fact that the blocks of code don't need to be identical for Code Clone to identify them, it will report Exact, Strong, Medium and Weak matches indicating how similar the blocks of code in question are.
People that know me know that I'm anal enthusiastic about both writing clean code, and taking old crappy code and making it suck less. So the possibilities for this feature have me pretty excited if it works well - and thats a big if that I'm hoping to explore over the next few blog posts.
I'm going to grab the Rawr source code from CodePlex (a World Of Warcraft gear calculator engine program), run Code Clone Analysis against it, then go through the results one-by-one and refactor where appropriate blogging along the way. My goals with this blog series are twofold:
Evaluate and demonstrate Code Clone Analysis
Provide some concrete examples of refactoring code to eliminate duplication and improve the code-base
Here are the initial results:
Code Clone Analysis has found:
129 Exact Matches
201 Strong Matches
300 Medium Matches
193 Weak Matches
Also indicated is that there was a total of 45,181 potentially duplicated lines of code that could be eliminated through refactoring. Considering the entire solution only has 109,763 lines of code, if true, the duplicates lines of code number is pretty significant.
In the next post we’ll start examining some of the individual results and determine if they really do indicate a potential refactoring.