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 | Inspeсtions|
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 ⌥Enter 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 (⌥Enter)
- Select suppressing the inspection for the required scope, for statement for example:
You can easily remove the suppression by “Remove suppression” intention action (⌥Enter):
And of course you can disable it for the whole project.
If you select Edit inspection... AppCode will show you the preferences for the particular inspection where you can read the description, manage the severity (choose from Typo, Server problem, Weak warning, Info, Warning, Error) or even in some cases configure the inspection’s parameters to reflect your demands more precisely. You can do this for Simplifable statement for example:
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 (⌥Enter) like adding a default branch:
- After accepting:
- Or select the action from the context menu (⌥Enter):
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 Code | Inspect Code.
There you will find several possibilities for the file range you’d like to check:
- whole project,
- uncommitted files (if any),
- the recently viewed file,
- the pre-configured scope.
After running this 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.
Inspection level configuration
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 File | Power Save Mode 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.