Command line code review reference

This topic describes the parameters that you must specify to run a code review analysis from a command line interface.

Purpose

The parameters for a command line code review application specify the scope of the analysis, the location of the source code, the rules to apply, and the location of the analysis results. The application can also write analysis results to stdout.

The instruction to run the code review command line application has the following syntax

Eclipse executable file:

<path to Eclipse executable>eclipse -data <path to Java source files> -application com.ibm.xtools.analysis.commandline.AnalyzeApplication -rulefile <path to rules file> -directory or -projects <path to Java source code> or <comma-separated list of project names> -exportdirectory <path to results directory> <optional parameters>

Java™ launcher:

<path to Java executable>java -cp path to Eclipse startup.jar org.eclipse.core.launcher.Main-data <path to Java source files> -application com.ibm.xtools.analysis.commandline.AnalyzeApplication -rulefile <path to rules file> -directory or -projects <path to Java source code> or <comma-separated list of project names> -exportdirectory <path to results directory> <optional parameters>
Note: Enclose with quotation marks any paths that contain spaces. For example: "C:\Program Files\IBM\SDP70\startup.jar".

Parameters

Option Classification Parameter
-data Mandatory Fully qualified path to Java source files

This can be the path to an existing Eclipse workspace, or the location of a temporary workspace.

-application Mandatory com.ibm.xtools.analysis.commandline.AnalyzeApplication

This is the identifier of the Eclipse command line analysis application.

-rulefile Mandatory Fully qualified path to a rule file
-projects Mandatory (if the source code is part of an existing Eclipse workspace project) Comma-separated list of project names

If you do not specify a workspace project, the code review runs on all the projects in the workspace.

-exportdirectory Mandatory Fully qualified path to a directory that will contain the analysis results
-verbose Optional Takes no parameter and writes all results to stdout
-directory Mandatory (if the source code is not in an existing Eclipse workspace) Fully qualified path to source folder of a Java project.

Use this option to analyze Java source code that is not already open in an Eclipse workspace. In this case, it is more efficient to run the analysis on a new workspace that you can specify with the -data option.

The -data option creates a temporary project, called com.ibm.xtools.analysis.commandline.temp, and creates a source directory that links to the directory that you specify with the -directory option..

-includeFile Optional Fully qualified path to a text file that lists source code files to include in the analysis

This option provides fine control over the source code files in the location that you specify with the -directory option. The text file must contain a line-separated list of source code files to include in the analysis. The paths that you list in the text file must be relative to the source folder and must not be fully qualified paths.

-excludeFile Optional Fully qualified path to a text file that lists source code files to exclude from the analysis

This option provides fine control over the source code files in the location you specify with the -directory option. The text file must contain a line-separated list of source code files to exclude from the analysis. The paths that you list in the text file must be relative to the source folder and must not be fully qualified paths.

Sample

The following sample instruction runs a code review analysis using the Java launcher:
c:\ibmj9_50\jre\bin\java.exe -cp C:\progra~1\IBM\SDP70\startup.jar org.eclipse.core.launcher.Main
-data "C:\Documents and Settings\default user\IBM\rationalsdp7.0\workspace-rsa-en"
-application com.ibm.xtools.analysis.commandline.AnalyzeApplication
-rulefile c:\temp\commlinecoderev.dat -projects hello.world1 -exportdirectory c:\temp
-verbose

Feedback