Simian

From HaFrWiki42
Jump to navigation Jump to search

Red Hill Consulting is an Australian owned software development and consulting company specialized in Java/J2EE and Ruby on Rails. With a strong focus on agile methodologies, domain modelling, business rules, testing and software quality.

Overview

Simian (Similarity Analyser) identifies duplication in Java, C#, C, C++, COBOL, Ruby, JSP, ASP, HTML, XML, Visual Basic, Groovy source code and even plain text files. In fact, simian can be used on any human readable files such as ini files, deployment descriptors, you name it.

Installation

Extract the TAR file into a directory on your harddisk.

This method allows you to execute Simian from the command line, shell scripts, batch files, etc. scanning a directory for all files matching a pattern. The general form for the Java version is:

   java -jar simian.jar [options] [files]

And for the .NET version is:

   simian.exe [options] [files]

Examples

For example, to find all java files in all sub-directories of the current directory:

   "**/*.java"

To find all java files in the current directory and set the threshold to 3:

   -threshold=3 "*.java"

To find all C# files in the current directory:

   "*.cs"

To find all C and header in all sub-directories of the current directory:

   **/*.c **/*.h

To find all java files in two different directories:

   "/csharp-source/*.cs" "/java-source/*.java"

To find all java files in all sub-directories, excluding Test classes:

   -includes=**/*.java -excludes=**/*Test.java

To find multiple files in all sub directories:

   -includes=**/*.sql -includes=**/*.hdr

To find all java files in the current directory and ignore numbers:

   -ignoreNumbers "*.java"

To find all java files and display the results in xml format:

   -formatter=xml "*.rb"

To find all ruby files and sends the results in emacs compatible format to a file:

   -formatter=emacs:c:\temp\simian.log "*.rb"

To read configuration from a file (where each line of the file specifies at most one of any of the valid command-line arguments):

   -config=simian.config

Ant task

This method allows you to integrate Simian with the Ant, a java based build tool. Somewhere in your build.xml file, define the task:

   <taskdef resource="simiantask.properties" classpath="simian.jar"/>

And finally, create a target to run the checker. For all defaults:

   <simian>
       <fileset dir="./main" includes="**/*.java"/>
   </simian>

To exclude test classes if they exists in the same tree as the source:

   <simian threshold="6">
       <fileset dir="./main" includes="**/*.java" excludes="**/*Test.java"/>
   </simian>

To change the minimum number of lines that is considered a match:

   <simian threshold="6">
       <fileset dir="./main" includes="**/*.java"/>
   </simian>

To force the language used for processing:

   <simian language="java">
       <fileset dir="./main" includes="**/*.*"/>
   </simian>

To have the build fail one or more matches are found:

   <simian failOnDuplication="true">
       <fileset dir="./main" includes="**/*.java"/>
   </simian>

To set a build property if one or more matches are found:

   <simian failureProperty="test.failure">
       <fileset dir="./main" includes="**/*.java"/>
   </simian>

By default, Simian outputs plain text using the default Ant logger. You can override this by using the nested formatter element. The formatter takes a type (either "plain"; "xml"; "emacs"; "vs"; or "yml") and an optional filename (toFile). For example, to send output to a file:

   <simian>
       <formatter type="plain" toFile="simian-log.txt"/>
   </simian>

To produce XML output:

   <simian>
       <formatter type="xml" toFile="simian-log.xml"/>
   </simian>

You may specify any number of formatter elements allowing you to produce both XML and plain text output if necessary.

See also

top

Reference

top