Context-sensitive analysis with AppCode 3: Never miss a value again!
One of the most notable features of AppCode is code analysis, which helps keep your code accurate and clean. The flexible mechanism of resolving problems works on the fly and allows you to easily improve code structure, detect unreachable and redundant code, conform to numerous guidelines and standards, detect performance issues, and much more.
AppCode not only highlights code issues in the editor, but also suggests intelligent quick-fixes and adds useful indicators to the right-hand gutter which let you instantly see the status of the file and navigate around the detected issues:
AppCode also provides shortcuts for navigating between these issues (Go to next highlighted error with
F2; go to previous with
Shift+F2). This detailed tutorial on code inspections will help you explore and learn more useful shortcuts and preferences.
In AppCode 3 we improved the handling of one of the most intelligent case for code analysis: context-sensitive analysis. The IDE helps you with many smart scenarios, for example if a condition is redundant, or if you are trying to access a reference that can be nil, or if you use an unrecognized selector, or if you cast to a type that’s probably incompatible. AppCode warns you about any potential problems and suggests quick-fixes for all cases. Here we’d like to show you a few examples.
Relying on thorough data flow analysis, AppCode is aware of all possible values of a variable and can decide in some cases if a given condition is always true or false at a certain point of program execution. The IDE successfully handles many complicated cases such as several data flow branches with input parameters involved:
…or tracking variable values through loops:
AppCode highlights the potential problem and suggests an appropriate quick-fix, which can be applied simply by pressing
The most popular case for data flow analysis is unreachable code, which may indicate a flaw in logic. For example:
Reference may be nil
Nil references often cause serious errors, but as they say forewarned is forearmed. AppCode will highlight potential problems for you:
Type checks can be tricky. It’s easy to miss an incompatible cast or unrecognized selector call, especially when working with a complicated inheritance tree:
And what’s your case for the context-sensitive analysis that you’d like AppCode to cover?
Subscribe to Blog updates
Thanks, we've got you!
Writing Code Documentation in AppCode
Code documentation can save you a lot of time and headaches. On the other hand, it also takes a lot of effort to write and maintain it. In this article, we will look at the AppCode features that can help you create detailed and well-structured code documentation and keep it updated after code refact…
Polish Your Code with AppCode’s Inspections and Intentions
AppCode is constantly analyzing your code to find parts that can be improved. It provides sets of code inspections and intention actions for each supported language for this exact purpose. Inspections locate unused or redundant code, syntax errors, probable bugs, spelling mistakes, obsolete or redun…
Navigation in AppCode
Navigating through files and source code, especially in complex projects, can eat up a lot of time, which is why it is essential to learn how to move around quickly in your IDE. AppCode provides plenty of navigation features that can help you move faster. In this blog post, we’ll take a look at some…
Server-side Swift in AppCode
In this short article we’ll take a look at various AppCode features that are useful for server-side Swift development, as now you can open standalone SPM projects in AppCode on macOS. Check out and open the project On the Welcome screen, click the Get from VCS button and enter the address of the Fe…