IntelliJ IDEA 2024.3 Help

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.

Disable inspections

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.

Most inspections in IntelliJ IDEA can be disabled. However, some inspections will keep highlighting your code regardless of the settings. For example, syntax errors are always highlighted.

Disable an inspection in settings

  1. Press Ctrl+Alt+S to open settings and then select Editor | Inspections.

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

  3. Apply the changes and close the dialog.

You can quickly disable a triggered inspection directly in the editor.

Disable an inspection from 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 from the Problems tool window

  1. In the Inspection Results tab of the Problems tool window (appears once you run 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.

Re-enable inspections

  1. Press Ctrl+Alt+S to open settings and then select Editor | Inspections.

    You can also press Ctrl+Alt+Shift+H and select Configure Inspections.

  2. Locate the disabled inspection in the list and select the checkbox next to it.

    Modified inspections are written in blue. You can also click the Filter Inspection button and select Show Only Modified Inspections to display only the inspections with changed settings.

  3. Click OK to apply the changes.

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 (class, method, field, or statement) . You can also suppress all inspections in the current class.

Most inspections in IntelliJ IDEA can be suppressed. However, some inspections do not have this option. For example, syntax errors are always highlighted in the editor regardless of the settings.

Suppress an inspection from 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 button next to the inspection you want to suppress and select the suppress action according to the required scope.

    Suppressing an inspection

Suppress an inspection from the Problems tool window

  • In the Inspection Results tab of the Problems tool window (appears once you run code analysis), right-click the inspection you want to suppress and select the necessary suppress action.

After you suppress an inspection, IntelliJ IDEA adds a new element before the selected symbol.

For example in Java, if you suppress an inspection for a class, a method, or a field, the IDE adds the @SuppressWarnings annotation. For statements, the //noinspection comment is added.

In other languages, the IDE adds other elements. For example, in PHP, IntelliJ IDEA adds the /** @noinspection */ comment. In Python, the # noinspection comment is added. In JavaScript, inspections are suppressed with the // noinspection comment.

Enable suppressed inspections

  • To re-enable a suppressed inspection, delete the annotation or the comment that the IDE has added before the selected symbol.

    A comment and annotation that indicate suppressed inspections in Java code

Disable highlighting, but keep the fix

Inspections have severities according to which they highlight code problems in the editor. You can quickly disable code highlighting for an inspection without opening the settings. In this case, the inspection remains enabled and provides a fix, but the severity changes to No highlighting (fix available).

  1. Place the caret at a code element highlighted by an inspection in the editor and press Alt+Enter.

    A list with available fixes and context actions opens. Locate the inspection fix that is marked with Intention action icon.

  2. Click the button next to the fix to open the inspection's options and select Disable highlighting, keep fix.

    Disable highlighting, keep the fix

The name of the inspection for which you are changing the severity is written above the inspection's options.

If you want to restore the highlighting, press Ctrl+Alt+S to open the IDE settings and select Editor | Inspections. Find the necessary inspection in the list and change its severity as you like. For more information, refer to Change inspection severity in all scopes.

Change the highlighting level for a file

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

    • None: turn highlighting off.

    • Syntax: highlight syntax problems only.

    • Essential: highlight only essential problems as you type and show all detected problems when the file is saved.

    • 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 | Analyze Code | Configure Current File Analysis or press Ctrl+Alt+Shift+H.

Last modified: 05 November 2024