Clone Detective

I read an InfoWorld article by Paul Krill entitled “Cloned Code Finder Offered For Visual Studio”. It announced a web based product from Microsoft called the Clone Detective. This is a tool that works with Visual Studio. If analyzes C# source code, and locates duplicate code. It has been released under the Apache 2.0 license. That means the software is free to use. It also means that you can use it in other open source projects as well as in proprietary projects.

There is a plan to release future Clone Detective versions that work with other popular languages such as C++ and Visual Basic. There is also a plan to add “fuzzy clone detection” to the tool in the future. This will allow you to locate code that is not an exact cut and paste, but close to it.

It is too bad that this product only analyzes C# right now. Almost all the code on my current project is written in C++. It is a huge legacy project around 15 years old. Some of the code was well thought out and designed well. However there are a lot of places where changes were hacked in. So I know we have a load of code that was cut and pasted. It would be nice to refactor a lot of that code to make a cleaner code base. It is possible to do this manually. However it would be nice to use a tool to analyze the code and at least find the places where we have duplicate code.

I might write up some dummy projects using C# just to give Clone Detective a spin. Of course I will use poor practices while coding up this sample app. And I will cut and paste galore. However I will make a few changes in the code copies and see how well the detective can, well, detect.