IntelliJ IDEA 2020.2 Help

Resolving Problems

If an inspection has detected a problem in your code, you can quickly apply a fix in the editor. Place the caret at the highlighted piece of code and press Alt+Enter.

For some inspections, you can open a preview by pressing Ctrl+Shift+I (View | Quick Definition).

Applying a quick-fix in the editor

If you have invoked inspections manually, you can examine the results in the Inspection Results tool window that opens automatically after the analysis is finished. All detected problems are listed in the left part of the tool window. Click a problem to display inspection details on the right.

Apply a quick-fix

  • To fix a problem, use the Intention action button (Apply a quick-fix). You can also press Alt+Enter or select a suitable fix from the popup menu .

Inspection results tool window

Automatically apply quick-fixes

You can streamline the process by automatically applying quick-fixes from your inspection profile to the selected scope without examining and applying each separate fix individually.

  1. From the main menu, select Analyze | Code Cleanup.

  2. In the Specify Code Cleanup Scope dialog, select the scope to which you want to apply a profile.

  3. Select the inspection profile from the Profiles list, or click the Browse button to configure a new profile. You can also click the Browse button to view all fixes that will be applied.

  4. Click OK to launch the cleanup.

IntelliJ IDEA performs code analysis and automatically applies quick-fixes from the selected inspection profile to all detected issues.

Alternatively, you can place the caret at an error in the source code that corresponds to a quick-fix, click the red bulb the quick-fix icon (suggested quick-fix) that appears on the left, and select Code Cleanup from the menu. Code cleanup will be performed for the current file with the current inspection profile.

Apply quick-fixes when committing changes to VCS

You can clean up your code in files before they are committed to a VCS. In this case, the current inspection profile will be applied.

  1. From the main menu, select VCS | Commit Changes.

  2. In the Commit Changes dialog, select the files that you want to commit, and select the Cleanup checkbox in the Before Commit area.

Export results

  1. In the Inspection Results tool window, click the Export button.

  2. Select the format in which you want to save the report (HTML or XML) and the target directory, and click Save.

Last modified: 22 September 2020