> 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/analyzing-source-code/languages/delphi.md). Agents can also search and read this documentation through its [MCP server](https://docs.sonarsource.com/~gitbook/mcp).

# Delphi

Find issues in your Delphi code, track duplication, and import test results and coverage with SonarQube Cloud. Delphi analysis requires the Enterprise plan.

Delphi analysis is available only in the Enterprise plan. See the [Subscription plans](https://docs.sonarsource.com/sonarqube-cloud/administering-sonarcloud/managing-subscription/subscription-plans.md) page for details.

## Analysis overview

SonarQube Cloud analyzes Delphi code to find issues and track duplication, and it imports NUnit test results and DelphiCodeCoverage reports.

You can also use [Automatic analysis](https://docs.sonarsource.com/sonarqube-cloud/analyzing-source-code/automatic-analysis.md) to analyze your Delphi project directly from your repository, without installing a scanner.

## What you get

* Issues from the Delphi security, reliability, and maintainability rules enabled in your quality profile. The built-in Sonar way quality profiles include Delphi rules.
* Duplication measures for your Delphi files: duplicated lines and their percentage, duplicated blocks, and duplicated files.
* Test execution results imported from NUnit reports: the number of unit tests, skipped tests, failures, and test execution time.
* Test coverage data imported from DelphiCodeCoverage reports.

## Supported files and syntax

The Delphi analyzer analyzes `.pas`, `.dpk`, and `.dpr` files and supports parsing Delphi syntax up to Delphi 13.2 Florence.

## Language-specific properties

Discover and update the Delphi-specific properties in *Your project* > **Administration** > **General Settings** > **Languages** > **Delphi**.

For CI-based analysis, set them in your scanner configuration or on the scanner command line. See [Configuration overview](https://docs.sonarsource.com/sonarqube-cloud/analyzing-source-code/analysis-parameters/configuration-overview.md) for the order of precedence.

Set the toolchain and project options to match how you compile your project. The analyzer then evaluates conditional directives and resolves imported units the way your compiler does.

### Toolchain

| Property                       | Description                                                                                                                                                                                                                                                 | Default  |
| ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| `sonar.delphi.toolchain`       | Compiler that builds your project. Values are not case-sensitive. Accepted values: `DCC32`, `DCC64`, `DCCARM64EC`, `DCCOSX`, `DCCOSX64`, `DCCOSXARM64`, `DCCIOSARM`, `DCCIOSARM64`, `DCCIOS32`, `DCCIOSSIMARM64`, `DCCAARM`, `DCCAARM64`, and `DCCLINUX64`. | `DCC32`  |
| `sonar.delphi.compilerVersion` | Compiler version, either as a symbol of `VER` followed by two or three digits, such as `VER360`, or as a version number with one or two digits, a point, and one digit, such as `36.0`. The `VER` prefix is not case-sensitive.                             | `VER360` |

If the toolchain or compiler version is not valid, the analysis logs a warning and uses the default value.

### Project options

| Property                            | Description                                                                                                                                                                                                                                                                                                     | Default |
| ----------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| `sonar.delphi.searchPath`           | Comma-separated list of directories where the analyzer looks for include files and imported units. Each path is absolute or relative to the project base directory, and is searched recursively. The analysis skips a path that is not an existing directory or that is a file-system root, and logs a warning. | None    |
| `sonar.delphi.conditionalDefines`   | Comma-separated list of conditional symbols to treat as defined when evaluating conditional directives such as `{$IFDEF}`.                                                                                                                                                                                      | None    |
| `sonar.delphi.conditionalUndefines` | Comma-separated list of conditional symbols to treat as undefined when evaluating conditional directives.                                                                                                                                                                                                       | None    |
| `sonar.delphi.unitScopeNames`       | Comma-separated list of unit scope names used to resolve imports, such as `System,Winapi`. With the `Winapi` scope, an import of `Windows` resolves to `Winapi.Windows`. If several scoped units match the same import, the import stays unresolved.                                                            | None    |
| `sonar.delphi.unitAliases`          | Comma-separated list of unit aliases used to resolve imports, in `Alias=Unit` format, such as `Windows=Winapi.Windows`.                                                                                                                                                                                         | None    |

The analyzer takes toolchain and project options only from the properties you set here. It ignores the matching settings in your Delphi project files.

### Analysis scope

| Property                     | Description                                               | Default       |
| ---------------------------- | --------------------------------------------------------- | ------------- |
| `sonar.delphi.file.suffixes` | Comma-separated list of file suffixes analyzed as Delphi. | `pas,dpr,dpk` |

### Test and coverage

| Property                            | Description                                                                                                                                                                                                  | Default |
| ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------- |
| `sonar.delphi.nunit.reportPaths`    | Comma-separated list of NUnit XML report files, wildcard patterns, or directories that contain the reports. See [#importing-test-execution-reports](#importing-test-execution-reports "mention").            | None    |
| `sonar.delphi.coverage.reportPaths` | Comma-separated list of DelphiCodeCoverage XML report files, wildcard patterns, or directories that contain the reports. See [#importing-test-coverage-reports](#importing-test-coverage-reports "mention"). | None    |

File and directory paths are absolute or relative to the project base directory. Wildcard patterns are relative to the project base directory. The analyzer searches directories recursively for `.xml` files. If you set one of these properties and none of its paths matches a report file, the analysis raises a warning.

### Example

For CI-based analysis, the following `sonar-project.properties` configuration analyzes a 64-bit Windows project built with Delphi 12:

```properties
sonar.delphi.toolchain=DCC64
sonar.delphi.compilerVersion=VER360
sonar.delphi.searchPath=src,lib/include
sonar.delphi.conditionalDefines=RELEASE,USE_LOGGING
sonar.delphi.unitScopeNames=System,Winapi,Vcl
```

## Importing test execution reports

Set the multi-value `sonar.delphi.nunit.reportPaths` property to the paths of your generated NUnit test reports.

Generate the reports before running the scanner. For branch restrictions and general parameter guidance, see [Test execution parameters](https://docs.sonarsource.com/sonarqube-cloud/analyzing-source-code/test-coverage/test-execution-parameters.md).

## Importing test coverage reports

Set the multi-value `sonar.delphi.coverage.reportPaths` property to the paths of your generated [DelphiCodeCoverage](https://github.com/DelphiCodeCoverage/DelphiCodeCoverage) reports.

Generate the reports before running the scanner as part of your CI-based analysis. Automatic analysis does not import coverage reports. For general parameter guidance, see [Test coverage parameters](https://docs.sonarsource.com/sonarqube-cloud/analyzing-source-code/test-coverage/test-coverage-parameters.md).


---

# 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/analyzing-source-code/languages/delphi.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.
