Native mode
By default, Qodana runs its linters using Docker based on Linux images. In specific cases, you have to deal with private packages or run Qodana on the operating systems that provide incomplete support for Docker.
To overcome this, Qodana supports native mode for all linters except Qodana Community for .NET and Qodana for C/C++. You can run native mode on Linux, macOS, and Microsoft Windows.
In this case, Qodana reuses its execution environment, which lets you execute Qodana in exactly the same environment as you use for building the projects, use the correct operating system, have access to all repository credentials, and resolve dependencies.
note
Native mode is currently in Early Access, which means it may not be reliable, may not work as intended, and may contain errors.
note
Native mode is incompatible with Docker containers of Qodana, which means that you run Qodana either as a Docker container or in native mode.
In your operating system, save the QODANA_TOKEN
environment variable containing the Qodana Cloud project token.
If you wish to run Qodana using a command line, then install Qodana CLI on the machine where you will run it.
Starting from version 2023.3 of Qodana, the sanity inspection will report in case the qodana.yaml
file containing the bootstrap
key is missing in your project directory. You can disable this inspection using the --disable-sanity
option, or add this inspection to a baseline.
In addition to general steps, make sure that you have a proper version of the .NET SDK and all required dependencies installed on your machine.
Build the project before inspecting it using Qodana. You can do it by using the bootstrap
key of the qodana.yaml
file. The project building and artifact packaging stages should occur before Qodana or simultaneously with it. Because running Qodana may affect the project state and its files, it is advised to avoid reusing the same directory in your build pipelines any further.
You can also provide Qodana a pre-built project, or specify the build steps in your CI/CD pipeline. To remove warnings related to project building, in your repository create the empty qodana.yaml
file.
note
Native mode is incompatible with several Docker image-related options like
-l, --linter
,-e, --env
, and-v, --volume
.
note
We recommend running the Qodana for .NET linter in native mode on the same machine where you build a project because this can guarantee that Qodana has access to private NuGet feeds.
You can enable native mode by using the ide
option in the qodana.yaml
file:
ide: <linter>
This table contains the list of <linter>
values:
Linter name | Linter code |
---|---|
| |
| |
| |
| |
| |
| |
| |
|
This configuration tells Qodana to download and employ the required JetBrains IDE binary file while running the Qodana for .NET linter.
Below are the examples showing how you can run Qodana in native mode:
Make sure that the
QODANA_TOKEN
variable is defined in the environment and refers to a proper project token. If necessary, you can define it:$QODANA_TOKEN=<cloud-project-token>
If you have already enabled native mode using the
qodana.yaml
file, use this command:$qodana scan
You can also run Qodana without configuring the
qodana.yaml
file:$qodana scan \ --ide <linter>
If you have already enabled native mode using the qodana.yaml
file, you can use a basic configuration sample from the GitHub Actions section.
To run Qodana without configuring the qodana.yaml
file, in your GitHub repository navigate to a workflow configuration file and specify the --ide,<linter>
option:
name: Qodana
on:
workflow_dispatch:
pull_request:
push:
branches:
- master
- 'releases/*'
jobs:
qodana:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
checks: write
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }} # to check out the actual pull request commit, not the merge commit
fetch-depth: 0 # a full history is required for pull request analysis
- name: 'Qodana Scan'
uses: JetBrains/qodana-action@v2024.3
with:
args: --ide,<linter>
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
Thanks for your feedback!