> For the complete documentation index, see [llms.txt](https://docs.sonarsource.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sonarsource.com/sonarqube-cloud/discovering-sonarcloud/analysis-process-overview/analysis-process.md).

# SonarQube analysis process

This page explains how SonarQube Cloud integrates with your CI pipeline and the main analysis steps.

## Integration into your CI pipeline <a href="#integration-into-ci-pipeline" id="integration-into-ci-pipeline"></a>

Integrating SonarQube into your CI pipeline brings powerful code review capabilities to your projects. Key features include main branch analysis, pull request analysis, and multiple branch analysis, ensuring comprehensive code quality checks at every stage of development.

The following steps outline the integration of the SonarQube analysis into your continuous integration (CI) pipeline for code analysis:

1. **Code commit**: A developer pushes code changes on a branch to the remote repository.
2. **Pipeline trigger**: A CI pipeline is initiated for the specific branch. This is often accomplished using webhooks, which are triggered by events in the Source Control Management (SCM) system, or through monitoring by a CI/CD tool like Jenkins.
3. **Code checkout**: The pipeline clones the remote repository, checking out the relevant branch to the local CI/CD host, thereby copying both the code and the SCM metadata.
4. **Code build** (if necessary): For compiled programming languages, the code is built by the pipeline.
5. **Code analysis**: The appropriate SonarScanner is executed by the pipeline to analyze the code.
6. **Results submission**: The SonarScanner transmits the analysis results to SonarQube for computation.
7. **Quality Gate check** (optional): SonarQube sends the result of the Quality Gate computation back to the CI pipeline.
8. **Pipeline continuation**: The pipeline either proceeds (if the Quality Gate passes) or stops (if the Quality Gate fails).

<figure><img src="broken://spaces/KXW79zfYFiA8incTvwZK/files/QpyaKjZj1SUEujjmAotH" alt="An overview of the SonarQube Server analysis process."><figcaption></figcaption></figure>

## Scanner engine and analyzers download at analysis time <a href="#scanner-engine-and-analyzers-download" id="scanner-engine-and-analyzers-download"></a>

A SonarScanner is a scanner bootstrapper that downloads the scanner engine and language analyzers from SonarQube at analysis time. This way:

* It ensures that the scanner engine and analyzer versions are compatible with SonarQube.
* Only the analyzers necessary to analyze the detected languages are downloaded.

The figure below shows a simplified view of the download process of the scanner engine and language analyzers. For each analysis run:

1. The CI or build pipeline starts the SonarScanner.
2. The SonarScanner connects to SonarQube to retrieve the scanner engine version to be used. It checks the scanner cache for the scanner engine version. If it does not find it, it downloads it from SonarQube and stores it in the cache.
3. The scanner engine scans the code to identify the different languages used in the project to be analyzed.
4. The scanner engine checks the scanner cache for the required language analyzers. If it does not find them, it downloads them from SonarQube and stores them in the cache.

<figure><img src="broken://spaces/KXW79zfYFiA8incTvwZK/files/oJthldzyS4ZLw8V3dhNi" alt="The SonarScanner downloads the Scanner engine which downloads the language analyzers"><figcaption></figcaption></figure>

## Issue identification and assignment by SonarQube <a href="#identification-and-assignment" id="identification-and-assignment"></a>

For each code file:

1. SonarQube Cloud checks if the file has been renamed.
2. SonarQube Cloud determines:
   * Whether an issue found during the current analysis is new or existed previously.
   * If an issue found during the previous analysis has been fixed.
3. For each new issue:
   * SonarQube Cloud determines and sets the issue date: the line’s last commit date when SCM data is available, or the analysis date otherwise. See [Issue date and backdating](#issue-backdating) for more information.
   * SonarQube Cloud tries to automatically assign the issue to an appropriate SonarQube Cloud user.

### Method used to identify if an issue is new <a href="#new-issue-identification-method" id="new-issue-identification-method"></a>

SonarQube Cloud uses the following algorithm to determine whether an issue is new or existed previously:

* For each issue found in the file from the previous analysis, it compares it to each issue found in this file during the current analysis:
  * If there is no match then it considers the issue as Fixed.
  * If there is a match and the issue status is Fixed in the previous analysis then it reopens the issue.
* For each issue found in the file during the current analysis, if there is no matching issue in the file from the previous analysis then it is considered new.

This algorithm relies on the issue’s line hash. The line hash is calculated based on the content of the first line the issue is reported on, excluding the white spaces.

The following diagram shows the comparison process between two issues. Each question compares an issue from the current analysis with an issue from the previous analysis.

```mermaid
%%{init: {'theme': 'base', 'themeVariables': {'primaryColor': '#F1F6FC', 'primaryBorderColor': '#126ED3', 'primaryTextColor': '#0A0A0A', 'lineColor': '#126ED3', 'secondaryColor': '#F4F6F8', 'tertiaryColor': '#F4F6F8', 'clusterBkg': '#F4F6F8', 'clusterBorder': '#D4D4D4', 'edgeLabelBackground': '#FFFFFF', 'fontSize': '13px'}, 'flowchart': {'nodeSpacing': 25, 'rankSpacing': 30}}}%%
flowchart LR
    START(["Start"])
    RULE{"Same rule?"}
    HASH{"Same line hash?"}
    LINE{"Same line?"}
    MOVED{"Code block moved<br>within the file?"}
    INBLOCK{"Same line<br>inside the block?"}
    MESSAGE{"Same issue<br>message?"}
    MATCH(["Match"])
    NOMATCH(["No match"])
    START --> RULE
    RULE -->|"Yes"| HASH
    RULE -->|"No"| NOMATCH
    HASH -->|"Yes"| MATCH
    HASH -->|"No"| LINE
    LINE -->|"Yes"| MESSAGE
    LINE -->|"No"| MOVED
    MOVED -->|"Yes"| INBLOCK
    MOVED -->|"No"| NOMATCH
    INBLOCK -->|"Yes"| MESSAGE
    INBLOCK -->|"No"| NOMATCH
    MESSAGE -->|"Yes"| MATCH
    MESSAGE -->|"No"| NOMATCH
    classDef neutral fill:#F4F6F8,stroke:#D4D4D4,color:#0A0A0A
    classDef event fill:#FFFFFF,stroke:#D4D4D4,color:#0A0A0A
    classDef subject fill:#FFFFFF,stroke:#126ED3,color:#0A0A0A
    class RULE,HASH,LINE,MOVED,INBLOCK,MESSAGE neutral
    class START,NOMATCH event
    class MATCH subject
```

* If the issue is on the same rule, with the same line hash (but not necessarily with the same message) : MATCH
* If the issue is on the same rule, on the same line number with the same message (but not necessarily with the same line hash): MATCH
* If the issue is on the same rule but the detected block moved inside the file, then if the issue is on the same line within the moved block, and has the same message: MATCH

### Issue date and backdating <a href="#issue-backdating" id="issue-backdating"></a>

SonarQube Cloud determines an issue date for every new issue, that is, every issue that did not exist in the previous analysis. This date decides whether the issue is reported on new code or on old code (overall code). See [Quality standards and new code](https://docs.sonarsource.com/sonarqube-cloud/standards/about-new-code.md) for more information.

When SCM data is available for the line the issue is raised on, SonarQube Cloud always sets the issue date to that line’s last commit date, rather than to the analysis date:

* If you changed the line, its commit date is recent, so the issue still counts as new code.
* If you did not change the line, its commit date predates the new code period, so the issue appears in overall code.

This keeps new code trustworthy: activating a rule or changing a rule parameter, a new analyzer version, or a change in the analysis context such as compiler, dependency, framework, or environment can still raise issues on untouched code, but those issues stay out of new code.

For SonarQube Cloud to get reliable commit dates, we recommend a full-depth checkout of your repository. See [Checked-out code](https://docs.sonarsource.com/sonarqube-cloud/analyzing-source-code/scanners/scanner-environment/verifying-code-checkout-step.md) for more information.

When no SCM data is available for the line, SonarQube Cloud uses the analysis date as the issue date, so the issue appears on new code.

### Automatic issue assignment <a href="#automatic-issue-assignment" id="automatic-issue-assignment"></a>

SonarQube automatically assigns an issue during analysis to the last committer on the issue line - called issue author - if the author can be correlated to a SonarQube user.

Login and email correlations between SCM account and SonarQube user are made automatically. For example, if the user commits with their email address and that email address is part of their SonarQube user profile, then new issues raised on lines where the user was the last committer will be automatically assigned to the user.

{% hint style="info" %}

* Currently, issues on any level above a file, for example, issues reported at a directory or project level, cannot be automatically assigned.
* If the SCM login associated with an issue is longer than 255 characters including the characters for an issue author, the author will be left blank.
  {% endhint %}

## Issue triaging

An issue can have one of the following statuses:

* **Open**: initial value after the first analysis. A user can reopen an **Accepted**, **False positive**, or **Confirmed** issue.
* **Confirmed**: set by an authorized user to confirm that the issue is valid. A confirmed issue still impacts the quality gate.
* **Accepted**: set by an authorized user if they decide to fix the issue later or not fix the issue. SonarQube ignores **Accepted** issues in the ratings of the code but displays the number of **Accepted** issues in the various analysis snapshots.
* **False positive:** set by an authorized user if the analysis is mistaken. SonarQube ignores **False positive** issues in the quality reports and the ratings of the code.
* **Fixed**: set by SonarQube after a subsequent analysis if the previously open issue has been fixed in the code (is no longer being detected). You cannot select **Fixed** in the SonarQube Cloud UI. SonarQube purges **Fixed** issues after 30 days.

{% hint style="info" %}
If users tend to mark a lot of issues as **False positive**, it means that some coding rules are not appropriate for the project. In that case, rules can be deactivated in quality profiles or the analysis scope of the project can be adjusted to exclude files. See [Editing a quality profile](https://docs.sonarsource.com/sonarqube-cloud/standards/managing-quality-profiles/editing-a-custom-quality-profile.md) and [Analysis scope](https://docs.sonarsource.com/sonarqube-cloud/managing-your-projects/project-analysis/setting-analysis-scope.md) for more information.
{% endhint %}

The following diagram shows the issue life cycle. Solid arrows are status changes a user makes. Dashed arrows are status changes SonarQube Cloud makes automatically.

```mermaid
%%{init: {'theme': 'base', 'themeVariables': {'primaryColor': '#F1F6FC', 'primaryBorderColor': '#126ED3', 'primaryTextColor': '#0A0A0A', 'lineColor': '#126ED3', 'secondaryColor': '#F4F6F8', 'tertiaryColor': '#F4F6F8', 'clusterBkg': '#F4F6F8', 'clusterBorder': '#D4D4D4', 'edgeLabelBackground': '#FFFFFF', 'fontSize': '12px'}, 'themeCSS': '.edgeLabel, .edgeLabel * { font-size: 11px !important; }'}}%%
flowchart TD
    NEW["SonarQube Cloud detects a new issue"]
    OPEN(["Open"])
    CONFIRMED(["Confirmed"])
    ACCEPTED(["Accepted"])
    FP(["False positive"])
    FIXED(["Fixed"])
    NEW -.-> OPEN
    OPEN -->|"Confirm"| CONFIRMED
    OPEN -->|"Accept"| ACCEPTED
    OPEN -->|"False positive"| FP
    CONFIRMED -->|"Accept"| ACCEPTED
    CONFIRMED -->|"False positive"| FP
    OPEN -.->|"No longer detected"| FIXED
    CONFIRMED -.->|"No longer detected"| FIXED
    ACCEPTED -.->|"No longer detected"| FIXED
    FP -.->|"No longer detected"| FIXED
    CONFIRMED -->|"Open"| OPEN
    ACCEPTED -->|"Open"| OPEN
    FP -->|"Open"| OPEN
    classDef neutral fill:#F4F6F8,stroke:#D4D4D4,color:#0A0A0A
    classDef event fill:#FFFFFF,stroke:#D4D4D4,color:#0A0A0A
    class NEW event
    class OPEN,CONFIRMED,ACCEPTED,FP,FIXED neutral
```

If a later analysis detects a **Fixed** issue again, SonarQube Cloud reopens it with the status it had before.

## Related pages

* [Basic principles of SonarQube analysis](https://docs.sonarsource.com/sonarqube-cloud/discovering-sonarcloud/analysis-process-overview/basic-principles.md)
* [DevOps platforms](https://docs.sonarsource.com/sonarqube-cloud/discovering-sonarcloud/integration-with-devops-platforms.md)
* [Integrations](https://docs.sonarsource.com/sonarqube-cloud/discovering-sonarcloud/integrations.md)

## Related online learning

* <i class="fa-desktop">:desktop:</i> [SonarQube analysis: From local scans to CI/CD automation](https://www.sonarsource.com/learn/course/core-concepts/f16bd24c-2a61-490d-9040-0e90039d14c0/sonarqube-analysis-from-local-scans-to-cicd-automation)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.sonarsource.com/sonarqube-cloud/discovering-sonarcloud/analysis-process-overview/analysis-process.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
