CLion performs code analysis by applying inspections to your code. Code inspections work for C/C++ and other supported languages.
The inspections detect not only compiling errors, but also different code inefficiencies. Whenever you have some unreachable code, unused code, unresolved method, memory leaks or even spelling problems – you'll find it very quickly.
CLion's code analysis is configurable. You can enable or disable each code inspection and change its severity, create profiles with custom sets of inspections, apply inspections differently in different scopes, suppress inspections in specific pieces of code, and more.
The analysis can be performed in several ways:
By default, CLion analyses all open files and highlights all detected code issues right in the editor. On the right side of the editor you can see the analysis status of the whole file (the icon in the top-right corner).
The severity levels are the following: an error (), a warning , no issues found ().
Alternatively, you can run code analysis in a bulk mode for the specified scope, which can be as large as the whole project.
If necessary, you can apply a single code inspection in a specific scope.
For the majority of the detected code issues, CLion provides quick fix suggestions. You can quickly review errors in a file by navigating from one highlighted line to another by pressing F2Shift+F2.
CLion analyses your projects on the various levels:
The on-the-fly analysis helps you to fix problems as you type. To apply a fix, use intention actions.
Code inspections are intended to point out issues related to the program design.
Highlighting level allows you to control the scope of problems highlighted in the current file.
Dependencies analysis helps you understand the structure of your source code, explore relationships between the components of your projects, track down dependencies and work through the code hierarchies.