Custom YAML profiles
Starting from version 2023.1, you can create and configure Qodana profiles using YAML. Qodana also provides several improvements related to profile configuration, such as:
Support for file paths and scopes
Support for inspection parameters
Profile relationship, so profiles can be extended and included
This sample shows how you can fine-tune Qodana for your needs.
This sample consists of several nodes:
Section | Description |
---|---|
The profile that will serve as a basis for your profile configuration | |
Name of the inspection profile | |
Include an existing file-based profile into your profile | |
Inspection groups that need to included or excluded in your profile | |
List of changes applied for |
baseProfile
The baseProfile
block lets you specify the profile that will serve as a basis for your profile configuration. It can accept the following values:
| Description |
---|---|
| The default profile taken from the JetBrains IDE |
| The profile is basically similar to |
| The default Qodana profile, a subset of the |
| The default Qodana profile implementing the default profiles of JetBrains IDEs |
| Severities and parameters of inspections are taken from |
If this parameter is missing, Qodana will employ the Project Default
profile, so all settings applied in your custom profile will override such settings contained in Project Default
.
name
Arbitrary name for your profile.
groups
The groups
block is a list of user-defined groups. Here, you can combine inspection categories and single inspections, and then configure their usage in the inspections
block.
Each group definition can include or exclude other groups or single inspections.
You can use the exclamation mark character (!
) to negate a group or a category. For example, you can exclude a specific category usage in a group that will be included.
Here is the sample containing the EnabledInspections
group defined by a user:
This sample contains the following properties:
Property | Description |
---|---|
ID of the group | |
List of included and excluded inspections in this group | |
List of included and excluded groups in this group |
groups.groupId
Unique group identifier.
In case two groups are defined under the same groupId
, the latest group met in the file will be employed. This rule also works for all included files because the settings contained in the included files are considered prior to the settings laid out in the current file.
groups.inspections
The list of inspections included in the group.
groups.groups
The list of group IDs with possible exclamation mark character (!
):
Here, groups
lists several values:
| Description |
---|---|
| Include all inspections. Besides that, you can also use |
| Name of the inspection category in the |
| Name of the existing user-defined group, or a group from an included profile |
| Negate the existing |
| Include or exclude inspections by a certain severity level. Because the severity value is taken from the |
By default, Qodana supports the following severity levels inherited from the JetBrains IDEs that you can use while configuring your profile:
Error
Warning
Weak Warning
inspections
Using inspections
, you can:
Enable or disable a specific group or an inspection
Define the order of applying these settings
Define the paths or scopes to be ignored by the specific group or the inspection
Change severity levels of the specific group or the inspection
This sample contains several properties:
Property | Description |
---|---|
| The ID of the group from the |
| The ID of the inspection |
| Severity level that will be assigned to a group of inspections or a single inspection. For example, you can specify |
| List of paths using the glob patterns and scopes that will be ignored during inspection |
| Specify whether the group or the inspection is enabled in the profile. Accepts either |
include
Contains the list of relative paths to included profiles.
The include
block is not related to baseProfile
. If baseProfile
contains no values, it is set to Default
.
To overview the default profile, in the JetBrains IDE navigate to Settings | Editor | Inspections and select the Default
profile in the Profile drop-down selector.
File contents are included in the order of appearance, thus becoming part of your profile. This means that the settings of the included files are used prior to the settings specified in your custom profile.
Example
Suppose, you have the foo.yaml
and bar.yaml
profiles.
The foo.yaml
profile enables the Inspection1
, Inspection2
and Inspection3
inspections:
The bar.yaml
profile disables the Inspection1
inspection:
You can include these two files in the custom profile and disable Inspection2
:
In this case, the effective profile configuration read by Qodana will look like this:
Configuration examples
Here you can find several examples of profile configuration. The Set up a profile section explains how to run your profile while inspecting code.
Exclude an inspection
This sample shows how you can exclude the PhpDeprecationInspection
inspection from the Qodana for PHP linter:
Alternatively, you can exclude the PhpDeprecationInspection
inspection using groups
:
Exclude paths
You can use the ignore
block to ignore specific scopes and paths while inspecting your code.
In the sample below, the vendor/**
value employs glob patterns for ignoring the contents of the vendor
directory contained in your project root.
The scope definition scope#file:*.js:testData//*
ignores all files with the .js
extension recursively contained in the testData/
directory.
Create a profile from scratch
Using baseProfile
, this configuration defines the empty profile, and then it includes only the Java/Data flow
inspection group from the Qodana for JVM linter.
As an alternative to baseProfile
, you can use ALL
in the groups
property:
Override the existing profile
You can exclude inspection categories from the qodana.starter
profile that are not related to the Qodana for .NET linter.
Filter by severity
This sample includes all inspections with the WEAK WARNING
severity level while inspecting Java code:
You can also apply severity level to a specific inspection: