Start FreeLog in
SonarQube Cloud | Enriching your analysis | Generic issue data

Generic issue data

On this page

SonarQube Cloud 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 SonarQube Cloud by having your custom CI task convert the output of the unsupported tool to this generic format, which can then be imported into SonarQube Cloud.

External issues have the limitation that the activation of the rules that raise these issues cannot be managed within SonarQube Cloud. 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

You can set up the import of the report files by defining the analysis parameter  sonar.externalIssuesReportPaths on the CI/CD host with the list of import directories or files. This parameter accepts a comma-delimited list of paths (a file path definition is either relative to the  sonar.projectBaseDir  property, which is by default the directory from which the analysis was started, or absolute).

Each report must contain, at top-level, an array of Rule objects named rules and an array of Issue objects named issues. The report fields for each object type are listed below. For information about the Clean Code attribute, software quality, impact and severity, see Clean Code.

Rule fields: Rule fields:

  • id - string
  • name - string
  • description - string, optional
  • engineId - string. Identifier of the external analyzer that provides the rule.
  • cleanCodeAttribute - string e.g., CONVENTIONAL, CLEAR, DISTINCT, LAWFUL (for more information, see here)
  • impacts - list of Impact objects, consisting  a software quality and severity level to which the rule's clean code attribute contributes, for example, MAINTAINABILITY and HIGH.

Issue fields:

  • engineId - string
  • ruleId - string
  • primaryLocation - Location object
  • effortMinutes - integer, optional. Defaults to 0
  • secondaryLocations - array of Location objects, optional

Location fields:

  • message - string
  • filePath - string
  • textRange - TextRange object, for secondary locations 

TextRange fields:

  • startLine - integer. 1-indexed
  • endLine - integer, optional. 1-indexed
  • startColumn - integer, optional. 0-indexed. Note: startColumn must not be specified for empty lines
  • endColumn - integer, optional. 0-indexed

Example

Here is an example of the expected format:

{
  "rules": [
    {
      "id": "rule1",
      "name": "just_some_rule_name",
      "description": "just_some_description",
      "engineId": "test",
      "cleanCodeAttribute": "FORMATTED",
      "impacts": [
        {
          "softwareQuality": "MAINTAINABILITY",
          "severity": "HIGH"
        },
        {
          "softwareQuality": "SECURITY",
          "severity": "LOW"
        }
      ]
    },
    {
      "id": "rule2",
      "name": "just_some_other_rule_name",
      "description": "just_some_description",
      "engineId": "test2",
      "cleanCodeAttribute": "IDENTIFIABLE",
      "impacts": [
        {
          "softwareQuality": "RELIABILITY",
          "severity": "LOW"
        }
      ]
    }
  ],
  "issues": [
    {
      "ruleId": "rule1",
      "effortMinutes": 40,
      "primaryLocation": {
        "message": "fix the issue here",
        "filePath": "file1.js",
        "textRange": {
          "startLine": 1,
          "startColumn": 2,
          "endLine": 3,
          "endColumn": 4
        }
      }
    },
    {
      "ruleId": "rule1",
      "primaryLocation": {
        "message": "fix the bug here",
        "filePath": "file2.js",
        "textRange": {
          "startLine": 3
        }
      }
    },
    {
      "ruleId": "rule1",
      "primaryLocation": {
        "message": "fix the bug here",
        "filePath": "file3.js"
      }
    },
    {
      "ruleId": "rule1",
      "primaryLocation": {
        "message": "fix the bug here",
        "filePath": "file3.js"
      },
      "secondaryLocations": [
        {
          "message": "fix the bug here",
          "filePath": "file1.js",
          "textRange": {
            "startLine": 1
          }
        },
        {
          "filePath": "file2.js",
          "textRange": {
            "startLine": 2
          }
        }
      ]
    },
    {
      "ruleId": "rule2",
      "effortMinutes": 40,
      "primaryLocation": {
        "message": "fix the bug here",
        "filePath": "file3.js"
      },
      "secondaryLocations": [
        {
          "message": "fix the bug here",
          "filePath": "file1.js",
          "textRange": {
            "startLine": 1
          }
        },
        {
          "filePath": "file2.js",
          "textRange": {
            "startLine": 2
          }
        }
      ]
    }
  ]
}

Was this page helpful?

© 2008-2024 SonarSource SA. All rights reserved. SONAR, SONARSOURCE, SONARQUBE, and CLEAN AS YOU CODE are trademarks of SonarSource SA.

Creative Commons License