Skip to end of metadata
Go to start of metadata

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 Cmd+F1):

To navigate through the highlighted issues use F2 (to the next one) and Shift+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 Alt+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:

  1. Highlight an issue (Cmd+F1)
  2. Open inspection context menu (Alt+Enter)
  3. Select suppressing the inspection for the required scope, for statement for example:

    You can easily remove the suppression by “Remove suppression” intention action (Alt+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:

All the inspections in AppCode are split into groups: General, C++, CSS, XML, Objective-C, 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.

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 Cmd+F1 to see the description). For example suggests that some enum values are missing in the switch case or the default branch is omitted:
  2. Then you can use a quick fix (Alt+Enter) like adding a default branch:

    After accepting:
  3. Or select the action from the context menu (Alt+Enter):

If some particular inspection needs to be called use Run inspection by name action (Alt+Shift+Cmd+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.

Click the Hector icon on the Status bar (or select Code | Configure Current File Analysis (Alt+Shift+Cmd+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.
Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.