Integrate Simian in Hudson CI-server
How to integrate Simian duplicate-code detection into Hudson CI, configure C# file exclusions and thresholds, generate XML reports, and prevent code duplication findings from breaking the build..
Steps to integrate simian
add simian to VCS
(in our case folder./trunk/build/simian)add build step to your Hudson job
(Execute Windows batch command)use following two commands
.\trunk\build\Simian\bin\simian-2.2.24.exe -formatter=xml:.\trunk\bin\Simian.Result.xml -excludes=**/*.Test/**/*.cs -excludes=**/*.DbFrame/**/*.cs -excludes=**/*.DbLayout/**/*.cs -excludes=**/*.Designer.cs -excludes=**/XServer1\_8.cs -threshold=10 **/*.cs EXIT 0
Explanation
For better visibility and understanding I have split the first call (simian) over several lines. Needless to say that you must contract all parameters and arguments of the simian call in one line.
Parameter –formatter
specifies the output format as well as location and name of the result file
Parameter –excludes
allows excluding specific files
**/*.Test/**/*.cs
all of our unit test projects names ends with .Test so this argument excludes all cs-files which are located beneath a folder (inclusive subdirectories!) which name ends with .Test**/*.DbFrame/**/*.csand**/*.DbLayout/**/*.cs
do not think about this! – these brownfield projects are so dirty, that code duplication is the smallest problem**/*.Designer.cs
because the Designer-files often contains similar constructs they are a typically candidates for duplicate code lines – this we should not respect**/XServer1_8.cs
this file contains several auto generated proxy classes for web services – also not interesting for us
Parameter -threshold
sets a threshold how many lines must be duplicated to be considered as a problem for the result file
last Parameter (**/*.cs)
scans all .cs-file beneath the current working folder
EXIT command
Especially in brownfield projects you have the situation that programmers copied a lot of code lines. And if simian will find only one the variable %ErrorLevel% is 1 which indicates for Hudson, that something went wrong and you get a red build break.
So it could make sense to return 0 every time and look sometimes to the Hudson dashboard.