25.6. CodeIssue

25.6.1. Overview

The Code Issue sensor data type is designed for representation of data concerning problems found by static analysis tools such as Checkstyle or FindBugs.

Table 25.5, “CodeIssue SDT attributes” documents the CodeIssue SDT attributes.

Table 25.5. CodeIssue SDT attributes

AttributeDescription
tstampThe UTC time at which this data was collected.
toolA string indicating the tool that collected this data, such as "Checkstyle".
runTimeAn identification tag that can be used in analysis to combine measurements that were taken after one complete execution of the static analysis tool. Typically, this value is the UTC time (converted to milliseconds) the code issue was found. This time may differ from tstamp.
fileThe absolute path to the source file from which code issue was collected. The file name extension is used to determine the source language type.
typeThe type of code issue. This can be used to identify the rule that discovered this code issue.

In addition to the above required fields for all CodeIssue data, there are a number of "optional but common" attributes that can appear on the property map. These are documented in Table 25.6, “CodeIssue SDT "optional but common" properties” so that static analysis tool sensor writers can produce CodeIssue sensor data that can be processed by the built-in analyses and reduction functions.

Table 25.6. CodeIssue SDT "optional but common" properties

PropertyDescription
lineThe line number of the code that the tool generated a code issue for.
severitySeverity level or severity type of the issue generated.
messageMessage from the tool describing the reason the issue was created.

25.6.2. Applications of the CodeIssue SDT

The Checkstyle tool automates the process of checking Java code to ensure it adheres to a coding standards and generates a list of code standard violations. A sensor for Checkstyle represents this data as CodeIssue entries.

The PMD tool automates the process of checking Java code for potential problems. For example, possible bugs, dead code, suboptimal code, overcomplicated expressions, and duplicated code. A sensor for PMD represents this data as CodeIssue entries.

The FindBugs tool automates the process of checking Java code for potential problems based on the concept of bug patterns. A sensor for FindBugs represents this data as CodeIssue entries.

Once collected, CodeIssue data can be used to track trends in problematic code associated with a system as it is developed.