Simian: A tool for Detecting Similar Code

Simian is a code similarity analyser that can be used to identify duplication in “…any human readable files…”. Simian runs natively in any .NET 1.1 or higher supported environment and on any Java 1.4 or higher virtual machine.

Howard van Rooijen shows how to integrate Simian into Visual Studio here Detecting duplicate code with Simian and also how to make it more usuable here MonkeyWrangler – Making Simian more usable in Visual Studio

To incorporate it into your NAnt automated build scripts, create a simian target:

<property name=”Exec.Simian” value=”C:\BuildTools\simian-2.2.8\bin\simian-2.2.8.exe”/>

<target name=”runSimian” description=”Runs Simian to find duplicate code”>

<exec program=”{Exec.Simian}"></span>        <span style="color:blue;"><</span><span style="color:maroon;">arg</span><span style="color:fuchsia;"> </span><span style="color:red;">value</span><span style="color:blue;">="-recurse={project.root}\*.cs”/>

<arg value=”-formatter=xml:${build.outputfolder}\simian.xml”/>

</exec>

</target>

The latest version of CruiseControl.Net already contains the necessary .XSL formatter to display the results in the CC.Net dashboard, just point it to the simian.xml output file.