Qodana 2022.3 Help

Baseline

Baseline is a snapshot of the codebase problems taken at a specific Qodana run and contained in the qodana.sarif.json file.

Using the baseline feature, you can compare your current code with its baseline state and see new, unchanged, and resolved problems.

How it works

If you run Qodana without a baseline, you will be able to see the problems detected at a current run.

Running Qodana without baseline

In this case, you can only see the number of problems and their description, without classification to new and existing problems.

To improve the situation, you can add problems to the baseline, download the qodana.sarif.json file, and put it to your project directory as explained in the Baseline section. Once done, this file becomes a basis for comparing with subsequent code states. You can run the baseline with the following CLI command:

docker run ... jetbrains/qodana-<linter> \ --baseline <path-to-qodana.sarif.json>

The baseline feature divides problems into these groups:

  • Unchanged are the problems added to a baseline and remaining unchanged since then.

  • New are the problems that arise in addition to the baseline problems.

  • Absent are the baseline problems that were resolved since the baseline was created.

This image explains how everything works.

Enabling the baseline
  1. The first Qodana run detected two problems in the codebase.

  2. To create a baseline for your project, download the qodana.sarif.json file and save it to your project directory as shown in the Baseline section. Starting from this moment, these two problems are identified by Qodana as baseline problems.

  3. A subsequent Qodana run detected three problems. Fortunately, this time Qodana identifies one of them as new and marks it respectively. The other two are the baseline problems; they are already reflected in the baseline report and marked as unchanged.

  4. After one baseline problem is resolved, you decided to run Qodana again. This time, the report will contain three problems. The new problem is the problem that was detected in the previous run and still remains new. There is also one unchanged problem that has not changed its status. Finally, the first baseline problem was resolved and now is marked as absent.

    To include absent problems into the report, you need to run Qodana with the --baseline-include-absent option:

    docker run ... jetbrains/qodana-<linter> \ --baseline <path-to-qodana.sarif.json> \ --baseline-include-absent

As you can see, new problems do not change the status across Qodana runs. To transform them to unchanged, you need to update your baseline.

Updating the baseline
  1. Download the qodana.sarif.json file again and save it to your project directory.

  2. Run Qodana again to see the change in the problem status.

Last modified: 17 April 2023