Qodana 2024.2 Help

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.

Before you start

General steps for all linters

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 the 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.

Qodana for .NET

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, we recommend that you avoid reusing the same directory in your build pipelines any further.

You can also provide Qodana with a pre-built project, or specify the build steps in your CI/CD pipeline. In this case, in your repository create the empty qodana.yaml file to eliminate warnings related to project building.

How it works

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:

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:

  1. 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>
  2. 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.2 with: args: --ide,<linter> env: QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
Last modified: 25 September 2024