Most Valuable Pathfinder

How to Use Code Analysis in the Automation Success Platform

  • 20 January 2023
  • 0 replies
  • 581 views

Userlevel 6
Badge +16

This is a guest post from Automation Anywhere Most Valuable Pathfinder ChanduMohammad S, a Module Lead and Senior RPA Developer. 


 

Currently, most of us use the manual code review process, which means we wait until development is finished before starting the code review process with the Lead Developer (or the Architect in some organizations). Every developer has a unique way of developing solution; however, to promote consistency across the team or organization, developers will be required to refer to existing Coding Best Practices for Reliability & Maintainability of the Code. 

This begs the questions: 

  • Do you really need to wait until the development is complete for the code review? 

  • Or, during development, If you as an RPA/Citizen Developers, deviate from the set of best practices will the bot editor alert us with remediation steps to deliver the reliable code?

Automation Success Platform comes with a new feature called Code Analysis [a.k.a Linter] which helps you define and enforce coding standards easily. In this tutorial, we’ll look at how to enable code analysis in the Automation Success Platform and explore how to use it.

 

🛠️ Prerequisites: 

  1. Upgrade your control room to A360.26 version

  2. Require below permissions to setup code analysis policy

    1. View Policies - Allows you to view the code analysis policy that defines how you can build your automations.

    2. Manage Policies - Allows you to view and edit the code analysis policy that defines how you can build your automations.

🏗️ Setup Code Analysis Policy 

  1. Access the control room by entering the user id with the required permissions.

  2. Go to Administration, then Policies, as shown below.

zSlLZgV4j2mmHmAnAKCGJ0J-dQsW9pNwlElTonKUtFx7G_CdsH7Pzsq4DD7KCpex1raDQ9Y30K70-6vDRzuqmyAU0c4YLATNP31BYV26VGSWupp18zOZGw-S6_NiJUIeUvdaitkJ5Pt9SrdYSTjsGJP8hmSYmLlXt13yr_syHk5ZwzRp7WdQ3rIMU-4mQIr3vwDY6rwcZg

 

  1. Click on Edit and select Enabled in the code analysis section.bi2ElG8dG1dFt5iVpw5Yz_2DyMCWpjkbxWukN7Reul6NLXGKGGdn4iJNXRUunFC-aSA6ohU_x77oDgGkErLIfr_H-BmenDCJNN-OGaQCZVoJk0MjfeIXiozXkycHK4Vj6xmgHjhQecRp-Dkj08-atMBQEzgS4b1wbMdxOSI3HdI-qc-ecyO1_nhAX9O3vyWQOMKwgCj0RQzfJ3qjB8Rb-ZaiZYnLwmlHW6ybBHhkdZiO9ZpoZqfrAnXyU_XmmTGA36cv0dMrhYQModwsd6LTDWP9PlPX16vPAPZo9wcSpKTtfLYVW3Y2eux0wNt4UGWoUvaP69gq0c_HpMSI-OjFVi2szPzszSKUVBJpsiX9_H8s4sdlDGnScAnsbDyJm4-i6dLN6uURLS365d8EYUbQ

  2. Enable all the required rules under Rules section in Policy editor and select a rule's High or Low severity level based on your organization's policies. Click Save changes

shJUEHqPIVMgfIL_L28WZT6Sf9hjpj2Ab9lrsGGs0iM3XOWwNKrCc67wzT3-fbnV7QRfrExWOwEL6XNe7gyPW-Xy6CclDFDNOuk4_STRq4E2NGMokmCL94NSB-XsbkdNeEsDbW03y18UQW3Ohrat0FURnQX0ph6bIek87bTpivquivy7hYVj5BVovM9GekyyaBPatxSnzA

 

💡Bonus Tips

📌 Code Analysis policy is applied to all the control room users.

📌 Numbers less than 30 will not be accepted by the policy editor when providing input for the Action Maximum rule.

📌Variable Naming patterns

  • Camel case - Variable names in camel case begin with a small letter. If it includes more than one word, the first letter of the subsequent word will be capitalised.

    • Ex: sBaseUrl

  • Pascal case - Variable names begin with a capital letter when written in Pascal case. If it includes more than one word, the first letter of the subsequent word will likewise be capital.

    • Ex: SBaseUrl

  • Kebab case - Variable names in the kebab case begin with small letters. If it contains more than one word, use a [-] in between them so that the second word begins with a small letter.

    • Ex: sbase-url

  • Snake case - It’s similar to kebab case. The only difference is replace the [-] with [_].

    • Ex: sbase_url 

 

📕Code Analysis Rules

 

The Lead Developer/CoE can define rules based on the Best Practises to be enforced for developing automations across the organization. Code analysis policy editor makes it simple to configure these rules, which are then applicable to all of the Automation Success Platform code editor's available packages and commands.

Let's try to understand anatomy of the Rules in Code Analysis,

Xz-yKmj2h9lKcPQZKvNAB45NmOSn-Db8DS5WU5xOtIi_7ocOcMR8WgOnJfTQe_OqqblRlkhGJMK2oIqIvHm25XFxQcP1BL1wbnSJ4AxMhhLt1xdirHWCfhJmQUNWXPAIiwKsOfn9MXrB4yCIJ2gP2CXG4TcinMdpkPoeSCi4fy6jg3L-65PRs8IVwkwrZdXgziUtxuGF6Q

DlwJSQfHxVyoEkcz9xbH6iVE65LeHrqiZFQbsfNL3lKkXHyaeh-T2t6obHqlx2Dkygt-QyFw_s-68nCvGHV8rvYwAEPr5HUCYbc3GfdoR_K-OrA4qBVg7-XChHk_7DOTTlGELW-thnuQTenpuY41spBVg-BFmFYFG3hSCYFngZiCsg_lkPIVMCjUFAy4up9tKxFTGHoX9Q

 

🚧Run Code Analysis

 

While developing the automations, you can run code analysis in both the Private and Public workspaces. 

During Development: During Bot development if we (RPAs/Citizen Developers) violate any rules set by Lead Developer/CoE team, you’ll instantly get an indicator via Bot Assistant, which will also guide us on how to resolve the violations. This reduces bot failures in the production environment by allowing us to solve all issues while still in the development stage. And you’ll be adhering to all best practices and guidelines.

Let's explore one of the bots using Bot Assistant,

  1. Click on Assistant, expand Issue browser to view the code analysis results.

sLLRahuFKcSv3D0M_AJeLc8qvE3DleTg-FCEiiT2DfYr1jL4yW2Zcb8-FX3NY5syAkk8FN3snSzcwqoOXqO1xsFohTYfFzdFXUNsjaqvKgEhV1j4Pqp86g9oDhVXe7vAi6WjDAWsJEmPqFcnY65OvqKvNRbX3wgYkB9i9aGCxON3l8U3Pg71JT3vpKxEjXrKocYtxqPtMg

  1. In this scenario we see 7 violations in the bot

oiLNRVwEmeIKpyrPLL2E3H8d2jLJovwlOMQaQu43m3jCsF0pThg3dwgYf2d-UV6JlnF0g1SeiFkn08b3d8BbogUVqnLdNbI0Le4nJPFpqXIN72W-r7xiUFl7yB8gXlFTWhRIz7fEaoC9lpGpgNyW2dWdS_u2QEbgIo_dBOC0NbqlhxPFGo7FegQ31_UGNAz9vU_yvvQkogI9YUuFoQXz9aSMnPXvqj1SP3dPqFsVlenT3P8YqR88SwbEbSG1_8vW3QsY5VEyxIN8RlWq-cHypqPWbGbPE5s4PoQ0zCRr0o6FC_GLc8fkd5MyFA79Gt5pAbCUMsvy3zaEx96cLOR8Z02utci2X_Tgv15qq7jRoVFL_feSNbVdHzHhykYMYfpbK0iDUoZ_VNBLuKANMOXA


 

  1. Go through all the violations one by one and use the provided hints to resolve the issues. Save the bot to see the latest code analysis results in the bot assistant.

Mza3q9tKKReuP_w_ev7G7a2UeHn6UvrQQNl6G-quJ-GmsPaZ9BkOCJ2bq1fRR9HSujHtkb8auy-EFw2HCbUoswrb_iY9-7IN2IyrmhbAQY92_2E3lDi5s6YXLeWl1wVVhh5VswC-XJtQVVNEsgC0vt42128amaYoD7DEKewqS2DGYa_yKIMAnzPx8frdyepS8oInfmAH9w

The A360.25 release invokes code analysis through the automation page, however in the .26 release, every time you click Save, bot editor will automatically run the code analysis. A new column has been added to the automation page that provides a summary of the code analysis results for every file you have access to. Let's explore various results statuses for code analysis,

 

8Hxc3U51KYuQi0QX7_hTE2qFmIoj-UMql0bRvmanAA_uEWqPqiLuX8iW_qa_pPk4Euv_qTkLcUuO5ybWxtf4GQ-P0xjEjaBHmr5v0hX8PWIfsPJAFvGCtMISTZHZV0RarkEH7OSjGYbU6vK6nrIXK5K9KQWtyAy5wGWJsC5BTsmqyD2hk-pvvIWDuIi_3pcD0cYKohNXmQ

  • N/A: Code analysis does not apply to the object because the object is a folder or is not a bot file.

  • Not Scanned: The bot has not been scanned.

  • High severity: The bot has at least one high severity violation.

  • Low severity: The bot has at least one low severity violation, but no high severity violations.

  • No violations: The bot has been scanned in accordance with the current policy, and there are no violations.

 

Private Workspace: Go to private workspace, choose the bot for which you wish to invoke code analysis, then click the fly-out icon from the rightmost action’s menu [ ymtxPOAvqxEYw4yVma14jBCrWl43yxwp-iO1xkJcOBVPpXMoSOStSxERoxRkl_ZWKVrJed0Y6XuErmQtajTSDlv-QZZ-ut3V0W0hcIH5maX30mLrNmX8EIk1NQgHTNHmMiltXGAq8i0fmNBoAJhnaz4AQyzXvVnrqHtJYiVbPwKdr_-RNzf8e6h86QrKXKdf8pmMY9AIIA ] . Download the report for further analysis. 

 

4j5vnxum3DQIZ7ajlufk_YMX8LDZ0XRKv4Y4BQaSUK2sqQWk14zJNzvvvIHkwYe0TCdkiNjbgYLCsc5SzS_R96bByUwlD7dqufHbq2R8o9yf79xdfoFHVZd7Gw7AzWtaehowi2SFe1pIAq9MS76UDcEriHCrPLfVuK0q3mE8xB7obN3zcY3SONoQoOJ2nsHM1EFrSEDiYg

 

Public Workspace: Go to public workspace, choose the bot for which you wish to invoke code analysis, then click the fly-out icon from the rightmost action’s menu [ ymtxPOAvqxEYw4yVma14jBCrWl43yxwp-iO1xkJcOBVPpXMoSOStSxERoxRkl_ZWKVrJed0Y6XuErmQtajTSDlv-QZZ-ut3V0W0hcIH5maX30mLrNmX8EIk1NQgHTNHmMiltXGAq8i0fmNBoAJhnaz4AQyzXvVnrqHtJYiVbPwKdr_-RNzf8e6h86QrKXKdf8pmMY9AIIA ] . Download the report for further analysis. 

 

dmd-FL5qH20sS3WBW8ipDg9hGEjaGeBK6ADATmWJlEcqrledMHJKEVTwRUjZXfGyQ1gsQZp1ChJ74ZpbUF-s_vgYEdrHl23Fk7eDN0w_3Ybw955li-y4_t6KL0rUn2_pc6vm9KcCJQl8AZG1DSEvxd_o2AZfnvQi92Am7QeFO43VNaZhhpQpSfAt3ziPvry4t_bteCudmQ

 

You can also invoke code analysis on older version of the same bot by following below steps:

  1. Go to public workspace

  2. Choose the bot

  3. Click the view history icon from the rightmost action’s menu [ ymtxPOAvqxEYw4yVma14jBCrWl43yxwp-iO1xkJcOBVPpXMoSOStSxERoxRkl_ZWKVrJed0Y6XuErmQtajTSDlv-QZZ-ut3V0W0hcIH5maX30mLrNmX8EIk1NQgHTNHmMiltXGAq8i0fmNBoAJhnaz4AQyzXvVnrqHtJYiVbPwKdr_-RNzf8e6h86QrKXKdf8pmMY9AIIA ]

  4. For code analysis, select the earlier version of the bot that interests you, then click the fly-out icon from the rightmost action’s menu [ ymtxPOAvqxEYw4yVma14jBCrWl43yxwp-iO1xkJcOBVPpXMoSOStSxERoxRkl_ZWKVrJed0Y6XuErmQtajTSDlv-QZZ-ut3V0W0hcIH5maX30mLrNmX8EIk1NQgHTNHmMiltXGAq8i0fmNBoAJhnaz4AQyzXvVnrqHtJYiVbPwKdr_-RNzf8e6h86QrKXKdf8pmMY9AIIA ]

  5. Download the report for further analysis. 

FHDrA-NGEscHZLdnZyVez1k69hqBe2gfAXKslyFftpYzA2ixBYSby51slxKCFgon27XYIvfZmwhcIqH6BGFtWIr34sm0OfMmEEiv4OT6t80t08pgoigJFRBdVOOUx0KRC6Bl9vi_wvjJ0CbOKsO-HRW6tdZaM96LfD9HOs5ZHA6RpmwCpFjfRCOG6PFmVYJxLs95pKNKow

 

Conclusion: 

 

Hopefully you enjoyed learning how to use Code Analysis in the Automation Success Platform environment. Code analysis helps you adhere to coding best practices and make the code reliable, efficient, secure, and maintainable. 

 


ChanduMohammad S (Automation Anywhere MVP) is a Module Lead and Senior RPA Developer with a demonstrated history of working in the information technology and services industry. In his free time, he enjoys binge watching, cooking and playing tennis.When he’s not building bots, you can find Chandu on LinkedIn as well as on the Automation Anywhere forums.

 

If you have an idea for a blog post or tutorial that you think would benefit the Automation Anywhere developer community, let us know at developer@automationanywhere.com.


0 replies

Be the first to reply!

Reply