Checking out code analysis results

As a Bot Creator (RPA developer) or Citizen Developer, you can use code analysis to check and fix any coding errors in your automation files (Task Bot or API Task). You can develop automation based on configured code analysis policies and predefined rules.

With code analysis, you can improve the reliability of your automations by implementing coding best practices such as variable naming conventions, comment coverage, and error handling. Building automations conforming to the predefined guidelines or rules helps you to identify possible errors during automation development. This reduces automation failures in the production environment. You can run code analysis in both your private and public workspaces and view the results.

With code analysis (available from the Bot editor), you get the following benefits:
  • Run code analysis as required.
  • Get tooltip guidance for compliance with rules.
  • Integration with Assistant for accounting and guidance.

Code analysis results

To view the results of code analysis, go to the Automation page, and check the Code Analysis results. This column shows a summary status of the code analysis results for each automation file (Task Bot or API Task). The following details of each status are available:
  • N/A: You will see the not applicable status for any of the following reasons:
    • Code analysis does not apply to the object because the object is not a Task Bot or API Task file.
    • There is no policy assigned to the Task Bot or API Task file or folder. When a Task Bot or API Task file or folder is in N/A status, row level actions for run code analysis option is not shown. Code analysis will not automatically run on these automations that have the N/A status.
  • Not Scanned: Code analysis has not been run on the Task Bot or API Task.
  • High severity: The Task Bot or API Task has at least one high severity violation.
  • Low severity: The Task Bot or API Task has at least one low severity violation, but no high severity violations.
  • No violations: There are no code analysis violations in the Task Bot or API Task.

The following image shows an example result from code analysis:


code analysis results column

Note: The status of the Task Bots or API Tasks in the code analysis results column is set to not scanned for the following scenarios:
  • The automation file is edited in the private workspace and has not been saved yet.
  • Code analysis is recently enabled by the administrator or there is a change in any of the rule configuration in the applicable policy for the automation file and the file is waiting to be scanned.

Reviewing results in Bot editor

When you create an automation file (Task Bot or API Task) or modify an existing automation file and then save it in the Bot editor, code analysis is initiated in the background, and the results are displayed in the Assistant. The code analysis header shows the total count of violations in the automation file. You can expand the code analysis option, select a specific object and view the following attributes:
  • Applicable object: Displays the automation file, variable, action, and action attribute.
  • Rule code: Unique RULE_CODE ID.
  • Severity: High or low.
  • Rule text: Description to indicate the nature of evaluation to be performed on the code.

The following image shows an example of code analysis displayed in the Assistant:


code analysis results in Assistant

The code analysis results are displayed in the following order:
Attribute Rules violated
Bot
  • Mandatory header comment
  • Comment coverage
  • Action maximum
Variable
  • Variable name pattern
  • Variable name length
  • No unused variables
Action
  • No hard-coded delay
  • No hard-coded file path
  • No hard-coded email address
  • No empty catch
  • Mandatory catch logging
  • Mandatory catch screen capture

The code analysis header displays the count of objects with a violation error within the automation file. Each object can have either low or high severity. The violation is displayed with the attribute followed by the line number and the severity. All the high severity errors are displayed first. Navigate to the corresponding line in the automation file that has the violation, rectify the violation, and save the automation.

You must save the automation file to see the latest code analysis results in the Assistant.

Code analysis violations and policy details in Bot editor

Professional and Citizen Developers can see the code analysis violations in actions at the canvas level. A violation indicator is available for flow and list views, enabling professional and Citizen Developers to quickly see and correct any actions in their automations that have code analysis violations. Code quality is enhanced when developers can easily determine violations and adhere to best practices when they are developing automations.

Professional and Citizen Developers no longer need to navigate to the policies page to view the applied policy and the rules contained in the policy. They can see the current code analysis policy and their rules from directly within the Bot editor from the drop-down menu (access from the three vertical ellipses in the upper right of the Bot editor) . This helps the users who do not have View policies and Manage policies permission to view current policy and their rules while editing the automation in the Bot editor itself instead of just viewing the violation.

code analysis policy option in bot editor

System-created variables

Variables created by the system such as input or output variables, package-suggested variables, or auto-generated variables (window variables) use the default variable naming case convention from code analysis or Pascal case if no format is defined in code analysis rule.

Audit log

When code analysis is initiated either by saving an automation file or running code analysis in the Bot editor, the information is captured in the audit log. The following details are captured:
  • Bot name
  • User information
  • The method through which code analysis is initiated (save option or run code analysis option)
  • Time taken for the code analysis to run including details such as the number of code lines if captured by code analysis process
  • Total number of violations
  • Details of the violations