Get results and fix 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 ().
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 (Apply a quick-fix). You can also press Alt+Enter or select a suitable fix from the popup menu .
Batch-apply quick-fixes (code cleanup)
You can streamline the process by applying quick-fixes from your inspection profile to the selected scope without examining and applying each separate fix individually.
From the main menu, select.
In the Specify Code Cleanup Scope dialog, select the scope to which you want to apply a profile.
Select the inspection profile from the Profiles list, or click to configure a new profile. You can also click to view all fixes that will be applied.
Click OK to launch the cleanup.
IntelliJ IDEA performs code analysis and 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 (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.
The Specify Code Cleanup Scope dialog
|Whole project||Select this option if you want to perform code cleanup for the whole project.|
This option is only available for projects under version control.
Clean up the code in the files that have not yet been committed to a version control system. You can select a changelist of fix problems in all uncommitted files.
|File <file path>||Select this option to perform code cleanup for the file that is open in the editor or selected in the Project tool window.|
|Module <module name>|
Select this option to perform code cleanup for the module that is currently selected in the Project tool window.
This option is only available, when your project consists of several modules.
|Directory <directory path>||Clean up the code in the directory that is currently selected in the Project tool window.|
|Selected files||Clean up the code in the files selected in the Project tool window.|
|Custom scope||Select a scope custom scope. You can select one of the predefined scopes from the list, or click and define a new scope in the Scopes dialog that opens. For instructions on how to define a scope, refer to Scope language syntax reference.|
|Include test sources||Apply the code cleanup to test sources.|
Select an inspection profile. You can use a pre-defined profile from the list, or click and configure a new profile in the Inspections dialog that opens.
You can open the Inspections dialog to check which fixes will be applied to the selected scope when you run code cleanup.
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.
From the main menu, select.
In the Commit tool window Alt+0 , select the files that you want to commit, and select the Cleanup checkbox in the Before Commit area.
In the Inspection Results tool window, click .
Select the format in which you want to save the report (HTML or XML) and the target directory, and click Save.