# Checked-out code

The SonarScanners run on code that is checked out from the repository. During the checkout of a working copy (clone) of the code from the project repository, we recommend using the full depth. Indeed, the so-retrieved SCM data enables various features such as:

* New Code detection:
  * On pull requests, not just the last commit but all the commits that are not on the target branch are considered. This requires a history long enough to find the common commit.
  * On long-living branches, the New Code definition can be set in different ways but a longer history is always better.
* Blame information display and automatic issue assignment based on the blame information.
* Issue backdating.

{% hint style="warning" %}
A full Git clone is required. If a shallow clone is found, the blame information retrieval will be skipped and the analysis may fail.
{% endhint %}

In addition, we recommend cloning all the branches of the repository to avoid reference errors during the checkout.

With Git, this means using `fetch-depth: 0`. This disables shallow clones and fetches all branches.

{% hint style="warning" %}

* Avoid any attempt at performing actions on the cloned repository to make sure the repository contains valid repository metadata (e.g. the .git folders have not been removed).
* The code in the cloned repository matches the code in the original repository (e.g no code is added to the branch on the cloned repository before analysis).
  {% endhint %}

## Related pages

[SCM integration](/sonarqube-community-build/analyzing-source-code/scm-integration.md)\
[Issue management solution](/sonarqube-community-build/user-guide/issues/solution-overview.md#issue-backdating-new-issues-raised-on-old-code)


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sonarsource.com/sonarqube-community-build/analyzing-source-code/scanners/scanner-environment/verifying-code-checkout-step.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
