CLion 2020.3 Help

Enable/disable and suppress inspections

Some inspections may report problems that you currently do not want to see. In this case, you can disable or suppress them.

When you disable an inspection, you turn it off. It means that the code analysis engine stops searching project files for the problem that this inspection is designed to detect. Note that when you disable an inspection, you disable it in the current inspection profile; it remains enabled in other profiles.

Disable inspections

Disable an inspection in the settings

  1. In the Settings/Preferences dialog Ctrl+Alt+S, select Editor | Inspections.

  2. Locate the inspection you want to disable, and clear the checkbox next to it.

    Enable inspection

  3. Apply the changes and close the dialog.

Disable an inspection in the editor

  1. Place the caret at the highlighted line and press Alt+Enter (or click the Intention action icon to use the intention action).

  2. Click the arrow next to the inspection you want to disable, and select Disable inspection.

    Disable an inspection in the editor

Disable an inspection in the Results tool window

  1. In the Inspection Results tool window (after running code analysis), right-click the inspection you want to disable and select Disable inspection.

  2. Click the Filter resolved items icon to hide the disabled inspection alerts.

Suppress inspections

When you suppress an inspection, the code analysis engine doesn't highlight the problem found by this inspection in the specific piece of code (file, statement, function, or line).

Suppress an inspection in the editor

  1. Place the caret at the highlighted line and press Alt+Enter (or click the Intention action icon to use the intention action).

  2. Click the arrow next to the inspection you want to suppress, and select the necessary suppress action.

    Suppress inspection in the editor

You can also suppress inspections from the Results tool window.

For C/C++ code, CLion uses the #pragma clang diagnostic to suppress inspections. For example, when you suppress one of the Clang-Tidy inspections, modernize-avoid-bind, for a selected function, the following code appears above and below the declaration:

Suppressing an inspection for a function

Clang-Tidy inspections have the additional Suppress for line option, which adds the // NOLINT comment, forcing Clang-Tidy to ignore the current line:

Suppressing an inspection for a lilne

To re-enable a suppressed inspection, delete the #pragma lines or // NOLINT comments.

Change the highlighting level for a file

  • By default, CLion highlights all detected code problems. Hover the mouse over the widget in top-right corner of the editor and select another level from the Highlight list:

    • None: turn highlighting off.

    • Syntax: highlight syntax problems only.

    • All Problems: (default) highlight syntax problems and problems found by inspections.

    Changing highlighting level for a file
  • You can also change the highlighting level from the main menu. Select Code | Configure Current File Analysis or press Ctrl+Alt+Shift+H.

Last modified: 02 April 2021