Introduction

This slice calculates a "Key Performance Indicator in File" (METRIC.KPIIF) score by applying predefined weighted rule profiles to a given development project. The weighted rule profiles allow you to define custom sets of rules and apply weights to each rule individually. When this slice is invoked, it counts the number of rule violations for each file in the project; for each rule, it multiplies the violation count by the specified rule weight in the profile. If a rule does not have a defined weight in the profile, the count for that rule is not gathered. The sum of the weighted counts is divided by the logical lines of code (METRIC.NOLLOCIF) in the given file to yield a Key Performance Indicator in File score.

Requirements

  • DTP Enterprise Pack 5.3.2.
  • Parasoft DTP 5.3.2.
  • The code analysis tool must be configured to report the Number of Logical Lines in Files metric (METRIC.NOLLOCIF) to the DTP. The tool must also be configured with the correct filter and build ID. See DTP Concepts for additional information about filter and builds, as well as the DTP Engine documentation for information on how to configure these settings.

Added Components

Four example profiles (described below) are added when the Key Performance Indicator in File slice is installed.

Installation

See Downloading and Installing Artifacts.

Configuration

The slice uses the KPI model profile type to calculate a Key Performance Indicator in File score. The profile is determined from the “profile” query parameter sent in the widget request. Several example profiles are installed with the slice and can be viewed in the Model Profile tab.

See Working with Model Profiles for additional information.

The filter ID is passed by the widget as a query parameter. It determines which DTP filter the profile should be computed against. The following example profiles are installed with the distribution to ease the configuration of the model profiles:

All RulesThis profile is a simple mapping of all the Jtest DTP Engine Static Analysis rules mapped with a weight equal to 100/severity (e.g., severity 1 violations are weighted a value of 100, severity 2 violations are weighted a value of 50, and so on.)
Recommended RulesThis profile is a simple mapping of the Jtest DTP Engine Static Analysis rules that are active in the Recommended Rules test configuration. The weights are mapped in the same fashion as the All Rules profile.
Flow AnalysisThis profile is a simple mapping of the Jtest DTP Engine Static Analysis rules that are active in the Flow Analysis test configuration. The weights are mapped in the same fashion as the All Rules profile.
Security This profile is a simple mapping of the Jtest DTP Engine Static Analysis rules that are active in the Security test configuration. The weights are mapped in the same fashion as the All Rules profile.

Invoking the Calculation

The KPI slice is a long running slice. It will only be computed when invoked by a third-party, ideally as part of a nightly job.

  1. Click on the service category on the Services tab and drill down to the endpoint.
  2. Copy the endpoint and send a REST request to it with the required parameters. The following table describes the required parameters:

filterIdThe filter id for the project that the calculations will be performed on.
profileProfile name with the rules and weights to use for the calculations.
buildIdThe build id for which the calculations will be performed on. If you would prefer to use the latest unlocked build that has violations data and metrics calculated, you can use latestBuild as the value of this parameter. If no build id is provided, this parameter defaults to latestBuild.

Example Invocation

You could run the following command to invoke the slice and run the calculation:

curl "http://localhost:8321/slices/a37fbfb6.59b87?filterId=71&profile=All%20Rules&buildId=latestBuild"

If successful, you will receive a response such as the following:

{"success":{"title":"Key Performance Indicator in File","message":"Calculation has successfully started for filter 'demo' using profile 'All Rules'."}}

Use HTTP(S)-compliance Parameters


When adding your parameters, be sure to properly encode the string parameter values if they contain spaces, +, /, or any other characters that are not allowed in the HTTP(S) protocol.

The following parameter, for example, is not allowed and will prevent the artifact from functioning correctly: buildId=c++test. The encoded parameter would be buildId=C%2D%2Dtest.

You can use an encoding tool (e.g., http://www.url-encode-decode.com) to help you properly encode parameters to be compliant with the standard.


Viewing the Data in DTP

After computation has completed and the KPI metric has been reported back to DTP, you can add a Metrics widget to your DTP dashboard and choose Key Performance Indicator from the Metric drop-down menu. See Adding Widgets for additional information.

The widget will display the metric according to your specifications.

Click on the widget to view details in the Metrics Explorer.






  • No labels