CLion 2018.3 Help

Enable/Disable and Suppress Inspections

If you think that some inspections report about the problems that you are not interested in, you can disable such inspections. Note that when you disable an inspection, it is disabled in the current inspection profile; in all other profiles, it remains enabled.

There are several ways to disable/enable inspections:

Disable or enable an inspection

  1. In the Settings/Preferences | Editor | Inspections dialog (Ctrl+Alt+S), find the desired inspection, by expanding the grouping nodes or using the search field.

  2. Use the checkbox next to the inspection to disable or enable it.

    cl enable inspection

  3. Apply the changes and close the dialog box.

Disable an inspection for highlighted issue in the editor

  • When you disable inspections this way, they are disabled for the current inspection profile.

  • To re-enable inspections disabled this way, use the main procedure described above.

  1. Set the caret at a highlighted issue.

  2. Click the bulb icon or press Alt+Enter to reveal the inspection alert and suggestion list.

  3. Select the inspection to be disabled, then click right arrow button or just press the right arrow key.

  4. On the submenu, click Disable <inspection name>.

Disable inspections from the Inspection results report

  • When you disable inspections this way, they are disabled for the inspection profile that was used for running inspections. You can see it in the header of the Inspection Results window's tab.

  • To re-enable inspections disabled this way, use the main procedure described above.

  1. In the Inspection Results Tool Window, right-click the inspection you want to disable.

  2. On the context menu, choose Disable inspection.

  3. Press the filter button icons general filter to hide the disabled inspection alerts.

Suppress inspections

For some reasons, you may want to partly disable a specific inspection, i.e. ignore some code issues while continuing to detect the other issues with this inspection.

For example, CLion considers some code to be "dead", and you can see that it is true. The inspection is helpful and you do not want to disable it. However, you may want to use this code later and do not want it to be highlighted in the editor or appear in the issue reports.

To do so, CLion allows you to suppress certain inspections for a specific statement, function/method, tag or file. You can do it either in the editor, using the suggestion list or in the Inspection Results tool window when analysing inspection results.

Let's summarize the difference between suppressing and disabling code inspections:

  • When suppressing an inspection, CLion inserts a special comment that tells the code analysis engine to ignore the issues found by this inspection in the specific piece of code.

  • When disabling an inspection, you just turn it off so the code analysis engine just ignores the code issues found by this inspection.

Some code inspections (e.g. those detecting errors) cannot be suppressed.

Suppress inspections in the editor

  1. Set the cursor to the highlighted code issue in the editor.

  2. Press Alt+Enter, or click the light bulb icon icons actions intentionBulb svg to expand the suggestion list.

  3. Depending on the issue, you will see either quick-fixes related to the inspection or the Inspection "<inspection name>" options item.

  4. Use the up/down arrow keys to select this item and then press the right arrow key or just click the right arrow rightArrowInMenu next to this item.

    Pressing the left arrow key, or Escape hides the suggestion list.

  5. In the inspection options list, select the desired suppress action. The inspection will be suppressed with special comments in the corresponding piece of code.

Suppress inspections from the Inspection Results tool window

  1. After running code analysis, select a code issue, for which you want to suppress the inspection, in the Inspection Results Tool Window.

  2. Click the button Suppress and choose the scope of sustension, or just right-click the selected inspection.

  3. Choose the desired suppress action. The inspection will be suppressed with special comments in the corresponding piece of code.

Last modified: 14 February 2019

See Also