Applying Quickfixes Automatically
On this page:
When you run an inspection against your code, the Inspection Tool Window is displayed showing the results of code analysis. You can then examine the issues that have been detected and apply the suggested quickfixes.
However, you may want to streamline this process by automatically applying the quickfixes from your inspection profile to the selected scope, without having to examine the results and implement each separate fix individually.
Applying quickfixes automatically
To apply quickfixes automatically
- From the main menu, select Code | Code Cleanup.
- In the Specify Code Cleanup Scope dialog that opens, select ths scope to which you want the inspection profile to be applied.
- Select the inspection profile from the drop-down list, or click the button to configure a new profile in the Inspections dialog that opens. You can also click the button to check which fixes will be applied.
- Click OK to launch the inspection.
PhpStorm will perform code analysis and will automatically apply quickfixes from the selected inspection profile to all issues that are detected.
Alternatively, you can place the caret at an error in the source code that corresponds to a quickfix, click the red bulb (quick-fix suggested) icon that appears on the left, and select Code Cleanup from the drop-down menu. Code cleanup will be performed for the current file with the current inspection profile.
Applying quickfixes on commit to VCS
To apply quickfixes when committing changes to a VCS
- From the main menu, select VCS | Commit Changes.
- In the Commit Changes dialog that opens, select the files that you want to commit, and select the Cleanup code option in the Before Submit area.
Code cleanup will be performed for all selected files before they are committed to your version control system (the current project inspection profile will be applied).