AppCode 2017.1 Help

Inspections

Shortcuts and settings

Show the error description ⌃F1
Navigate to next/previous error F2/⇧F2
Invoke Quick-Fix ⌥⏎
Run Inspection by name ⌃⌥⇧I
Configure highlighting level ⌃⌥⇧H
Preferences Preferences | Inspections

Essentials

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):

/help/img/idea/2017.1/ac_InspTutorial_lighting.png

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):

/help/img/idea/2017.1/ac_InspTutorial_quick_fixes@2x.png

Settings

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:

/help/img/idea/2017.1/ac_InspTutorial_inspections_settings@2x.png
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:

  1. Highlight an issue (⌃F1)
    /help/img/idea/2017.1/ac_InspTutorial_simplifiable@2x.png
  2. Open inspection context menu (⌥⏎)
    /help/img/idea/2017.1/ac_InspTutorial_supress_inspection@2x.png
  3. Select suppressing the inspection for the required scope, for statement for example:
    /help/img/idea/2017.1/ac_InspTutorial_supress_result@2x.png
    You can easily remove the suppression by “Remove suppression” intention action (⌥⏎):
    /help/img/idea/2017.1/ac_InspTutorial_remove_suppression@2x.png
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 Simplifiable statement for example:
/help/img/idea/2017.1/ac_InspTutorial_inspections_prefs@2x.png

All the inspections in AppCode are split into groups: Objective-C, C++, Swift, General, CSS, XML, JavaScript, etc. Some are based on the compile warnings while others are taking you to the next level. The full list of inspections includes more than 100 possibilities. Go to Preferences | Inspections for it. Also it’s possible to save various configurations as named profiles and use them separately on different projects or scopes inside one project.

Try in action

Let’s us demonstrate how the things work on an example. That will be a missing switch case issue.

  1. 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:
    /help/img/idea/2017.1/ac_InspTutorial_Step 0.png
  2. Then you can use a quick fix (⌥⏎) like adding a default branch:
    /help/img/idea/2017.1/ac_InspTutorial_Step 1.png
  3. After accepting:
    /help/img/idea/2017.1/ac_InspTutorial_Step 3.png
  4. Or select the action from the context menu (⌥⏎):
    /help/img/idea/2017.1/ac_Insp_Tutoprial_step 4.png

Running single inspection

If some particular inspection needs to be called use Run Inspection by name action (⌃⌥⇧I):

/help/img/idea/2017.1/ac_InspTutorial_run_inspection_by_name@2x.png
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 Code | Inspect Code.

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.
/help/img/idea/2017.1/ac_InspTutorial_inspection_scope@2x.png

Upon running that AppCode shows the full list of inspections found in the selected scope:

/help/img/idea/2017.1/ac_InspTutorial_inspection_scope.png
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.

/help/img/idea/2017.1/ac_InspTutorial_hector_window.png
Click the Hector icon /help/img/idea/2017.1/ac_InspTutorial_hector.png on the Status bar or press ⌃⌥⇧H and you will be able to:

  1. 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.
  2. Configure the inspections.
  3. 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.

See Also

Last modified: 26 July 2017