Shortcuts and settings
|Show the error description||⌘F1|
|Navigate to next/previous error||F2/⇧F2|
|Run Inspection by name||⌥⇧⌘I|
|Configure highlighting level||⌥⇧⌘H|
|Preferences||Preferences | Inspections|
When writing a code sometimes you try to stop and think about your code’s beauty and accuracy. But it would be so much more comfortable if something assisted you with that on the fly. AppCode works this out! It strives for the code perfection and helps you to find places that smell and improve them just as you type. So here is a small dive into the Code Inspection mechanism.
The inspections work on the fly and highlight the potential problems (to show the error description use ⌘F1):
To navigate through the highlighted issues use F2 (to the next one) and ⇧F2 (to the previous one).
Moreover the mechanism suggests the quick fix (or several of them if possible) for an issue (you can see it by pressing ⌥⏎ after placing the cursor to the problematic code):
If you feel this issue may appear in another scope in your project you can run inspection on it or even fix all the issues of this type at once. All of these and also the inspection settings are available in the context menu section: And what if you don’t consider this as an issue and don’t want the IDE to disturb you in such case? You can suppress it for the limited scope - file, method, statement - so that it will be still working outside this selection but will not bother you inside:
- Highlight an issue (⌘F1)
- Open inspection context menu (⌥⏎)
- Select suppressing the inspection for the required scope, for statement for example: You can easily remove the suppression by “Remove suppression” intention action (⌥⏎):
Try in action
Let’s us demonstrate how the things work on an example. That will be a missing switch case issue.
- AppCode highlights the particular problem as you type (use ⌘F1 to see the description). For example suggests that some enum values are missing in the switch case or the default branch is omitted:
- Then you can use a quick fix (⌥⏎) like adding a default branch:
- After accepting:
- Or select the action from the context menu (⌥⏎):
Running single inspection
If some particular inspection needs to be called use Run Inspection by name action (⌥⇧⌘I): Start typing the name and the AppCode helps you with the rest. The full list of the suggested issues for your project is available by calling the.
There you will find several possibilities for the file range you’d like to check:
- The whole project;
- The uncommitted files (if any);
- The recently viewed file;
- The pre-configured scope.
Upon running that AppCode shows the full list of inspections found in the selected scope: And you can navigate through this list, group the issues by directory or severity, apply quick fixes (to one or more errors) and edit settings.
Click the Hector icon on the Status bar or press ⌥⇧⌘H and you will be able to:
- Configure the highlighting level: move slider to one of the three available positions:
- None: turn off problems highlighting in the editor;
- Syntax: highlight syntax problems only;
- Inspections: (default) highlight syntax problems and inspection issues.
- Configure the inspections.
- Switch on/off the power save mode (the same can be done in menu) - turn it on and save the power especially during the trip when you don’t have power supply. Keep in mind that this mode turns off on-the-fly code inspections.