By default, CLion analyses the code in all open files and highlights the detected code issues. You can fix most of the issues immediately by applying quick-fixes.
Place the caret at the highlighted piece of code and press Alt+Enter:
You can also hover the mouse over the highlighted element and apply a quick-fix from the inspection popup:
For some inspections, you can open a preview by pressing Ctrl+Shift+I.
If there are available fixes to the issue, CLion notifies it in the following ways:
The Apply a Quickfix button becomes available on the toolbar of the Inspection Results tool window.
The available fixes are shown in the optional Problem resolution field of the report.
The available fixes are shown in the context menu of the issue.
If there are no available fixes, the only option is to fix the issue manually.
tip
Note the following:
To display the source code of an issue in the editor, when it is selected in the Inspection results tool window, toggle the Navigate with Single Click button.
If you find that some of the reported issues are minor or not helpful to you, you can ignore them either by disabling the corresponding inspection or by suppressing it in a specific piece of code.
Apply quick-fixes from the Inspections Results tool window
If CLion suggests any fixes to the issue as described above, you can use one of them to fix the problem immediately:
You can also batch-apply quick-fixes for several issues at a time: select the issues, click the bulb button (or press Alt+Enter) and select the resolution to be applied:
If no resolutions are suggested, use the Jump to source command in the context menu and fix the problem manually.