Generic Issue Data
SonarCloud supports a generic format for importing issues generated by external analysis tools, like linters. This feature can help you integrate a tool that is not directly supported by SonarCloud by having your custom CI task convert the output of the unsupported tool to this generic format, which can then be imported into SonarCloud.
External issues have two important limitations:
- They cannot be managed within SonarCloud; for instance, there is no ability to mark them as False Positive.
- The activation of the rules that raise these issues cannot be managed within SonarCloud. External rules are not visible on the Rules page or reflected in any Quality Profile.
External issues and the rules that raise them must be managed in the configuration of your external tool.
Import
The analysis parameter sonar.externalIssuesReportPaths
accepts a comma-delimited list of paths to reports.
Each report must contain, at top-level, an array of Issue
objects named issues
.
Issue fields:
engineId
- stringruleId
- stringprimaryLocation
- Location objecttype
- string. One of BUG, VULNERABILITY, CODE_SMELLseverity
- string. One of BLOCKER, CRITICAL, MAJOR, MINOR, INFOeffortMinutes
- integer, optional. Defaults to 0secondaryLocations
- array of Location objects, optional
Location fields:
message
- stringfilePath
- stringtextRange
- TextRange object, optional for secondary locations only
TextRange fields:
startLine
- integer. 1-indexedendLine
- integer, optional. 1-indexedstartColumn
- integer, optional. 0-indexedendColumn
- integer, optional. 0-indexed
Example
Here is an example of the expected format:
{ "issues": [
{
"engineId": "test",
"ruleId": "rule1",
"severity":"BLOCKER",
"type":"CODE_SMELL",
"primaryLocation": {
"message": "fully-fleshed issue",
"filePath": "sources/A.java",
"textRange": {
"startLine": 30,
"endLine": 30,
"startColumn": 9,
"endColumn": 14
}
},
"effortMinutes": 90,
"secondaryLocations": [
{
"message": "cross-file 2ndary location",
"filePath": "sources/B.java",
"textRange": {
"startLine": 10,
"endLine": 10,
"startColumn": 6,
"endColumn": 38
}
}
]
},
{
"engineId": "test",
"ruleId": "rule2",
"severity": "INFO",
"type": "BUG",
"primaryLocation": {
"message": "minimal issue raised at file level",
"filePath": "sources/Measure.java"
}
}
]}