Qodana 2024.1 Help

Structural search

Structural search is a powerful and flexible mechanism built into JetBrains IDEs. It employs search templates to let you inspect the codebase taking into account its semantics. You can create your own search templates and use them as Qodana inspections.

How it works

As an example, consider this search template:


It lets you detect the System.out.println() Java statement. To make it detect the statements with hardcoded text like System.out.println("Hardcoded text!"), the template should take the modifiers described below:






Accepts zero or one value.



Searching for the println method.



Any text enclosed in quote characters.

This procedure explains how to use this search template for inspecting your codebase using Qodana.

  1. Using the Structural Search dialog of IntelliJ IDEA, create the template:

    Search template
  2. Convert the template to inspection as described on the Work with structural search and replace page of the IntelliJ IDEA documentation portal. For example, it can be saved as Hardcoded-print.

  3. Use Settings | Editor | Inspections to enable the inspection in the Structural search group of inspections. For more details, see the Configure profiles page.

    Enabling inspection
  4. In the Inspections section of the Settings dialog, export the updated profile.

  5. In the project root directory, create the qodana.yaml file and specify the path to the profile location in it:

    profile: path: path/to/the/profile/file
  6. Inspect your code using Qodana:

    docker run \ -v <project-directory>:/data/project/ \ -e QODANA_TOKEN="<cloud-project-token>" \ jetbrains/qodana-jvm
  7. You can observe the problems detected by the structural search inspection under the Structural search category in the Qodana report.

    Observing the Structural Search inspection results
Last modified: 17 May 2024