Qodana 2023.1 Help

Inspect a monorepo project

A monorepo is a repository containing several projects, for example:

root/ backend/ frontend/ .git/

In this example, the backend/ folder contains a Java project, the frontend/ folder contains a JavaScript project, and the .git/ folder contains VCS-related information.

This section explains how to prepare the projects from this example monorepo so that Qodana can inspect them using either the Docker images or the Qodana Scan GitHub Action.

Prepare your project

Qodana provides several linters, and each linter can inspect a specific set of programming languages. Because there is no linter that can inspect Java and JavaScript at the same time, Qodana needs to be run twice over the repository, once for each project.

To configure Qodana for inspecting two projects, you need to create two separate qodana.yaml files. Qodana also expects qodana.yaml to be contained in the root folder. This means that before running Qodana on the project from the backend/ folder, that project's qodana.yaml file needs to be copied to the root folder. If you run Qodana using Docker, you can copy files using the bootstrap configuration option in qodana.yaml, for example:

bootstrap: cp qodana-backend.yaml qodana.yaml

When Qodana runs, it uses the .git/ folder for linking detected problems to the corresponding source code in a Git repository, and for exploring inspection reports from within your IDE.

The qodana-backend.sarif.json and qodana-frontend.sarif.json files can contain baseline data for the backend and frontend projects.

Here are the contents of the root/ folder:

root/ backend/ frontend/ .git/ qodana-backend.yaml qodana-backend.sarif.json qodana-frontend.yaml qodana-frontend.sarif.json

Run Qodana

After preparing the project, you can inspect your code using Docker or GitHub Actions.

Docker

You can inspect your monorepo in the root/ folder using either Docker or Qodana CLI.

docker run --rm \ -v "$PWD":/data/project/ \ jetbrains/qodana-jvm:latest-eap \ --source-directory backend \ --baseline qodana-backend.sarif.json
docker run --rm \ -v "$PWD":/data/project/ \ jetbrains/qodana-js:latest-eap \ --source-directory frontend \ --baseline qodana-frontend.sarif.json
qodana scan \ --linter jetbrains/qodana-jvm:latest-eap \ --source-directory backend \ --baseline qodana-backend.sarif.json
qodana scan \ --linter jetbrains/qodana-js:latest-eap \ --source-directory frontend \ --baseline qodana-frontend.sarif.json

GitHub Actions

You can use the Qodana Scan GitHub action for running Qodana on GitHub. Here is the GitHub action configuration for inspecting the monorepo:

name: Qodana on: workflow_dispatch: pull_request: push: jobs: qodana-backend: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: fetch-depth: 0 - name: 'Use qodana-backend config' run: cp qodana-backend.yaml qodana.yaml - name: 'Qodana Backend' uses: JetBrains/qodana-action@v2023.1.0 with: args: | --source-directory,backend, --baseline,qodana-backend.sarif.json artifact-name: qodana-backend qodana-frontend: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: fetch-depth: 0 - name: 'Use qodana-frontend config' run: cp qodana-frontend.yaml qodana.yaml - name: 'Qodana Frontend' uses: JetBrains/qodana-action@v2023.1.0 with: args: | --source-directory,frontend, --baseline,qodana-frontend.sarif.json artifact-name: qodana-frontend
Last modified: 24 April 2023