Chapter 3 Browsers Enhancements : Code Analytics

Code Analytics
C:\Users\documentation\Documents\vastePublisher\stable\VAS Documentation Word\images\vaast\vaast_3_ca1.png
VA Assist Pro provides a sophisticated code analytics engine, which is designed to Detect, Report and Repair issues with source code. Furthermore, the code analytics engine is designed to run in real time, analyzing the code in the background as the user types.
Detecting
Code Analysis works against a set of known lint rules which are checked as changes to the system or source code are detected. Each rule has a default classification, but these classifications can be adjusted by the user. The classifications are:
Disabled - The rule will be skipped
Fatal Error - Highest Severity. An example of this is a compiler error.
Error - High Severity. An example of this is an unknown selector that is saved into a method. The method can still be saved, but it is usually a good indication that something is wrong.
Warning - Medium Severity. An example is a variable whose value is read before it has been assigned to. Unassigned variables are implicitly nil so it's not an error, but it is probably a good indication that something is amiss.
Info - Low Severity. An example is a variable that could be pushed to an inner scope.
The following is the list of rules with their default classifications:
Compiler Error - An error within the source that keeps it from compiling. Classification: Fatal Error
Unimplemented method in system - A selector referenced within the code is not implemented in the image. This could be because the appropriate code is not loaded or it may be a spelling mistake. Classification: Error
Unimplemented method in receiver - A message selector exists in the image, but it has been determined that the receiver of the message does not implement it. Classification: Error
Class/Method not visible in application - A reference to a class or a message selector is not visible in the application prerequisite chain. This can cause errors when packaging because the packager relies heavily on the prerequisite chain to know what can be stripped out of a reduced image. This is also an early warning sign of a disorganized code base. Classification: Warning
Variable is unused - A temporary is defined but never used. Classification: Warning
Variable read before written - The value of a variable is read before it is ever assigned to. Classification: Warning
Variable written but never read - A variable is assigned a value (or multiple values) but the value is never used. Classification: Warning
Variable can be pushed to inner scope - A variable could be defined in a more local scope. Classification: Info
Reporting
When using real time code analysis, issues should be reported to the user in a subtle way so the user is not distracted while coding, and can choose to address the issues when he/she is ready.
The first part to reporting is decorating the affected section of text. This is done using an indicator that is drawn underneath the text and is shaped and colored according to the specification of the editor theme. Additionally, a marker of the same color is placed in the margin area (left part of the editor) on the same line as where the issue occurred. This allows the developer to quickly find issues when scrolling.
While indicator visualizations show where an issue exists, it does not detail what the issue is. Call tips are used to do this. The developer simply hovers the mouse pointer over an indicator for a short period of time (@300ms) and a call tip will appear with a short description of the issue.
Repairing
Repairing is taking action against the reported issue in order to resolve it. There may be more than one possible action to take. Before a repair can proceed, the possible list of actions need to be presented to the user. VA Assist Pro accomplishes this with what are called Action List Call Tips. For more information on this, see the Action List Call Tips section described above in the "Call Tips" section.
The action list call tip shown below is a report from an unused local detection. Notice the down arrow button on the left side:
C:\Users\documentation\Documents\vastePublisher\stable\VAS Documentation Word\images\vaast\vaast_3_ca2.png
Clicking the down arrow button expands the call tip. The user can now select the appropriate action using the up/down arrows on the call tip or keyboard. The user can apply the action by double-clicking the call tip or pressing <Enter>:
C:\Users\documentation\Documents\vastePublisher\stable\VAS Documentation Word\images\vaast\vaast_3_ca3.png
Invoking a repair is considered refactoring. The available types of refactoring will be described in a subsequent section.
Code Analytics Configuration Options
C:\Users\documentation\Documents\vastePublisher\stable\VAS Documentation Word\images\vaast\vaast_3_cacfg.png
Code Analysis configuration options can be accessed by (Options | Code Assist | Configure...) in any browser menu and selecting "Code Analysis" from the Feature combo box in the Configuration UI.
The following is a description of all configuration options:
Enable Incremental Compiler - Enable/Disable real-time compiler error indication.
Default: true
Show Margin Markers - Enable/Disable the use of markers in the margin to indicate annotated source.
Default: true
Unimplemented method in system - Classification of lint rule that detects if a selector is implemented anywhere in the image.
Default: Error
Unimplemented method in receiver - Classification of lint rule that detects if a selector is implemented by the receiver.
Default: Error
Class/Method not visible in application - Classification of lint rule that checks the prerequisite visibility of references to classes and message sends.
Default: Warning
Variable is unused - Classification of lint rule that checks for declared temporaries that are never referenced.
Default: Warning
Variable is read before written - Classification of lint rule that checks for variables whose value is read before an assignment occurs.
Default: Warning
Variable is written but never read - Classification of lint rule that checks for variables that are assigned values but are never used.
Default: Warning
Variable can be pushed to inner scope - Classification of lint rule that checks for variables that could be defined in a more local scope.
Default: Info