This tutorial demonstrates the basic steps of creating ConQAT analyses. In a step by step fashion, the analysis described in the first tutorial (Part 1: Running An Analysis) is created. All files from this tutorial are included in the ConQAT examples. See Part 1 of the Getting Started Tutorial for details on how to import the examples project.

Step 1: Create a new analysis file in ConQAT

Choose a project in which you want to create the analysis file (block). You may use the conqat-examples project or create a new project in Eclipse.

Select the project and open the New Wizard (either using the context menu on the project into which you want to place the block, or using menu File->New->Block. Select the project in which you want to create the new block in and press Next. In the next wizard page, enter LinesOfCode as Block Name and press Finish. The new block will be created and opened in the block editor. On the right hand side, the ConQAT Library shows a list of available blocks and processor for building quality analysis. ConQAT blocks and processors are organized in so-called bundles, which can be seen in the library view.

Block Editor

To build a quality analysis, you can drag processors and blocks from the ConQAT Library view onto the editor pane. A double-click on a processor opens the Properties view on the lower left of the workbench where you can set the processor’s parameters.

Step 2: Building an Analysis for Counting Lines of Code

We will now create an analysis block that counts the lines of code of the JUnit project. (The source code of JUnit is included in the ConQAT examples.) The basic processing steps for this analysis are as follows:

  • Load JUnit source code
  • Compute lines of code
  • Write result into report

Choose the block TokenFileScope from the ConQAT Library which is located in the sourcecode bundle. You may choose to enter the name in the filter text field on the top of the view to quickly navigate to the block in the libary. Drag the block onto the editor pane. Then select the newly added block to see its parameters in the Properties view.

Block Parameters

Enter the parameter values as in the following screenshot:

Block Parameter Values

Now add a LOCAnalyzer processor from the resource bundle by dragging it from the library. Connect the result output of the TokenFileScope (the right output port on the bottom of the block) to the input of the LOCAnalyzer by clicking on the output and dragging the line to the input port. Next, add a TableLayouter processor from the html_presentation bundle. Connect the output of the LOCAnalyzer to the input port named input of the TableLayouter. You can identify the name of a port by hovering over it. A tooltip showing the name will appear. During connecting the port, the name of the port will be shown on the info bar in the lower left of the workbench.

Connecting Ports

Parameters of blocks and processors have attributes. Select the TableLayouter processor and enter LOC for the attribute name of the parameter info in the Properties view.

TableLayouter Properties

Finally add an HTMLPresentation block from the html_presentation bundle. Drag the output of the TableLayouter onto the middle of the HTMLPresentation block and release the mouse button. A small popup will appear. Select the parameter result : ref. For the parameter output.dir of the HTMLPresentation enter the the path to the conqat-examples project followed by /output/lines-of-code. This is the directory the HTML output will be written to.

Step 3: Creating a Run Configuration

To run the analysis, we will now create a ConQAT Run Configuration. Right-click on the file LinesOfCode.cqb in the Package Explorer and select New->Run Config. Press Next and then finish to accept the default values for location and name of the run configuration. The new configuration is opened and as there are no parameters that need to be supplied, it can be instantly executed by clicking on Launch ConQAT Analysis.

Step 4: Extending the Analysis

The analysis we built measure the lines of code for each individual files but does not aggregate the values. We will now add a processor that aggregates the LOC values along the directory structure.

Add a SumAggregator processor from the commons bundle. If you drop the aggregator onto the connecting line between the LOCAnalyzer and the TableLayouter, the input and output of the aggregator will be automatically wired with the existing processors. You only have to set the value for the parameter read.key of the SumAggregator to LoC (You can use the autocompletion feature in the text field by pressing CTRL-SPACE).

If you now execute the analysis again, you will notice the aggregated LOC values in the output.

This concludes the tutorial Getting Started - Part 2: Building an Analysis