将SonarDelphi(一款具有 100 多种代码分析规则的 Delphi 静态分析器)引入 Delphi IDE
动态分析一个或多个文件,缩短反馈循环,这样您就可以在签入之前发现并解决问题
检测到的问题及其描述和理由以内联方式显示在 IDE 中
通过右键单击即可自动快速修复常见问题
两种分析模式:
独立 - 完全在本地运行分析
无需外部服务器或其他工具
应用常用的 Delphi 规则的默认规则集,或从 SonarDelphi 规则的完整列表中选择所需的编码样式
已连接 - 连接到 SonarQube 实例,允许
从服务器配置的质量配置文件中获取活动规则和配置
抑制过去分析中已解决的问题
服务器 SonarDelphi 版本的使用情况
支持读取标准sonar-project.properties文件,提供额外配置
Visual Studio Code 配套扩展,可用于在 VS Code 本身中运行分析并显示结果
[![Build](https://github.com/integrated-application-development/delphilint/actions/workflows/build.yml/badge.svg)](https://github.com/integrated-application-development/delphilint/actions/workflows/build.yml) [![Format](https://github.com/integrated-application-development/delphilint/actions/workflows/format.yml/badge.svg)](https://github.com/integrated-application-development/delphilint/actions/workflows/format.yml)
DelphiLint is an IDE package for RAD Studio that provides on-the-fly code analysis and linting, powered by
[SonarDelphi](https://github.com/integrated-application-development/sonar-delphi).
## Features
* Brings [SonarDelphi](https://github.com/integrated-application-development/sonar-delphi),
a static analyzer for Delphi with 100+ code analysis rules, to the Delphi IDE
* Analyze one or more files on-the-fly, shortening the feedback loop so you can pick up and fix problems before they're even checked in
* Detected issues, along with descriptions and rationale, displayed inline in the IDE
* Automated quick fixes for common issues, available via right click
* Two analysis modes:
* Standalone - run analyses entirely locally
* No external servers or other tools required
* Apply a default ruleset of commonly accepted Delphi rules, or pick and choose your desired coding style from
the full list of SonarDelphi rules
* Connected - connect to a SonarQube instance, allowing for
* Fetching of active rules and configuration from the server's configured quality profiles
* Suppression of issues that have been resolved in past analyses
* Usage of the server's version of SonarDelphi
* Support for reading standard `sonar-project.properties` files, providing additional configuration
* A Visual Studio Code companion extension that can be used to run analyses and show results in VS Code itself
## Installation
System requirements:
* Microsoft Edge 79.0.309+
* [Delphi 11+](https://www.embarcadero.com/products/delphi)
* [Java 11+](https://adoptium.net/temurin/releases/?package=jre&version=17)
Installation steps:
1. Download the packaged zip for your Delphi version from [the latest release](https://github.com/integrated-application-development/delphilint/releases/latest), or [build from source](#building-from-source).
2. Unzip the folder and run the included `install.bat` script.
3. Done!
> [!NOTE]
> Using the precompiled BPLs in different minor versions from which they were compiled can cause compatibility problems in some circumstances. If you encounter issues, please [build from source](#building-from-source).
### Installing the VS Code companion
1. Download the .vsix extension file from [the latest release](https://github.com/integrated-application-development/delphilint/releases/latest),
or [build from source](#building-the-vs-code-companion).
2. Run `code --install-extension ` to install the extension.
> [!IMPORTANT]
> For the companion to work, a DelphiLint installation of the same version must be installed.
>
> The VS Code companion is **not** required for the Delphi IDE plugin to function.
## Usage
To analyze a file:
1. Open a Delphi project in the IDE.
2. Open the Delphi source file you want to analyze.
3. Click the `DelphiLint > Analyze This File` menu option.
It's as easy as that! The DelphiLint window will then pop up, showing the current state of analysis and any issues
that are raised. Please note that when the file has a lot of imports the analysis could take thirty seconds or so.
* To **analyze all files that are open in the IDE**, use `DelphiLint > Analyze All Open Files`.
* To **clear a file of its analysis history**, use `DelphiLint > Clear Active File`.
* To **apply quick fixes for an issue**, right click the issue range in the editor window or the issue item in the
DelphiLint window, then select the quick fix. (Note that not all issues may have quick fixes available.)
For more information:
* See [Configuration](docs/CONFIGURATION.md) for details on project configuration settings.
* See the [FAQ](docs/FAQ.md) for answers to common questions and problems.
## Gallery
| ![](docs/images/multi_file_issues.gif) | ![](docs/images/gallery-code-view-dark.png) |
| ----- | ----- |
| ![](docs/images/gallery-code-view-light.png) | ![](docs/images/fix_issues.gif) |
| ![](docs/images/gallery-quick-fix.png) | ![](docs/images/gallery-code-view-mountain-mist.png) |
## Building from source
Prerequisites:
* [Delphi 11+](https://www.embarcadero.com/products/delphi)
* [JDK 11+](https://adoptium.net/temurin/releases/?package=jdk&version=17)
* [Maven 3.5+](https://maven.apache.org/)
* [npm](https://www.npmjs.com/)
* Microsoft Edge 79.0.309+
* PowerShell execution policy set to `Unrestricted` (see [MSDN](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_scripts?view=powershell-7.4#how-to-run-a-script))
To build DelphiLint, use `scripts/build.ps1`:
* `scripts/build.ps1 280` to build for Delphi 11 Alexandria
* `scripts/build.ps1 290` to build for Delphi 12 Athens
This creates a `target/DelphiLint--` folder containing all built artifacts.
> [!NOTE]
> `build.ps1` looks for a Delphi installation in the default location for the given version.
> If your installation is elsewhere, supply the location as part of the version parameter, e.g.
> `scripts/build.ps1 280=/my/custom/location`.
## Contributing
DelphiLint is open for contributions - please read the [contributing guide](docs/CONTRIBUTING.md) for more information.
## License
Licensed under the [GNU Lesser General Public License, Version 3.0](http://www.gnu.org/licenses/lgpl.txt).