Code review can be treated as a check-post/ guardrails in which developers submit their code for feedback before merging branches or deploying code to production.
The feedback is usually given by colleagues, either other developers, a manager, or a tech lead.
In this article, I’ll aim to build your code review skills by suggesting the different elements you should consider when conducting one.
You can use this list as a checklist to go through when you’re reviewing code.
Let’s get started!
Introduction
Typically RPA developer opens a pull Request or he/she request a reviewer by creating/moving JIRA tickets to review the code by the Lead developer.
- UiPath also provides the workflow analyser that performs the static code analyser and ensures that it follows the best practices.
- However, it checks for inconsistency without actually executing the project, as opposed to dynamic analysers
“Workflow Analyzer uses a set of rules to check for various inconsistencies unrelated to project execution. The rules are based on Automation Best Practices and take into consideration variable and argument naming, empty sequences or workflows, package restrictions, and so on. The analyzer does not identify errors in execution or compilation.”
So keep in mind even if you perform Workflow Analyzer it still needs code review to be done by a peer developer or Team lead to ensure it’s ready for production use.
Read more details about Enforcing the Workflow Analyzer here.
The goal of code review
There are several benefits of performing code reviews, but each team can focus on a different matter. Typically, the purpose you can look for will be improving general code quality and reducing the number of bugs by sharing the knowledge of the author and reviewers. Also, developers will educate each other on how to write better code and understand business problems.
- Provide better solutions
- Early caught bugs
- Improved overall code quality
- Standardization of code rules and style
- Two reviewers are better than one
Be Your Code Reviewer
First thing first; While reviewing the code, ask yourself the following basic questions:
- Are you able to understand the workflows easily?
- Is the workflow written following the coding standards/guidelines set by RPA COE?
- Are there more appropriate ways of performing the task(Using activities or Custom codes)?
- Is the same workflow duplicated more than twice?
- Is there sufficient logging done for each workflow milestones activity?
- Can I unit test / debug the code easy to find the root cause?
If you feel that the answer is not satisfactory to any of the above questions, then you can suggest/recommend code changes.
Code Review Checklist for UiPath Code Reviewer
The Code Review process, like any other process, can use some rules, especially in bigger and more complex projects. More developers in the team mean diverse experience and practices.
So it is the best practice that you should list and document the steps you follow during code review.
Here is a quick checklist you can rely upon by performing code reviews.
Implementation
- Does this code change do what it is supposed to do?
- Have the requirements been met?
- Can this solution be more simplified?
- Does this change add unwanted Uipath Package (UiPath or Third Party Supported) dependencies?
- Is the Workflow modular enough?
- Would you have solved the problem in a different way that is substantially better in terms of the code’s maintainability, readability, performance, security?
- Does this code follow best practices and framework principles?
- Does this code follow the Re-Framework or Template used by RPA COE?
- Does this automation integrate with Third-party systems via API or Connectors?
Security and Data Privacy
- Are authorization and authentication handled in the right way?
- Our credentials are stored in the Credential store? Such as Orchestrator asset or Cyber arc
- Is sensitive data like user data, credit card information securely handled and stored? Is the right encryption used?
- Are shared folders used in automation have the right set of access controls?
- Is data retrieved from external APIs or libraries checked accordingly?
- Is there any PII related information logged in UiPath Orchastartor logs?
- Is there Error screens captured with sensitive information?
- Is the service account or Robot account has additional permission than Process SME?
- How can we know what automation is used in the organization?
Readability
- Is the UiPath workflow easy to understand?
- Can the readability of the workflows be improved by smaller workflow xamls?
- Are there redundant comments? Commenting on your code is fantastic; however, it can be overdone or just be plain redundant.
- Is there any commented out code?
- Are there deeply nested if-else or sequence blocks?
- Are there pinned annotations or Comments at the top of each workflow, describing what the workflow is used for an explanation of each Argument to send In and Out?
Maintainability
- Is Configuration is hard-coded?
- Are all required configurable values are in (XML file, database table, Excel, txt ) so that no code changes are required?
- Does it contribute to tech debt by increasing investment in a technology that the team wants to phase out? Such as the use of specific features of the old library?
- Is workflow using pre-built RPA content provided by a third party? If any…are they supported by publishers?
Speed and Performance
- Performance for users and resource consumption? Is there an activity using a high CPU?
- When possible, code should use lazy loading and parallel processing
- Use a data type that best suits the needs such as data tables, lists etc.
- Is workflow using “for each”? Avoid doing it over a large no of records.
- Use LINQ Queries. LINQ is commonly used to query arrays, data tables, dictionaries, lists, and XML. Arrays, dictionaries, and lists require no modifications or special treatment to act as a LINQ data source.
Scalability
- Consider if it supports a large user transaction?
- Consider if it supports Multi Bot architecture?
Reusability
- Check that the workflow is written with likely future use-cases in mind
- DRY (Do not Repeat Yourself) principle: The same workflow steps should not be repeated more than twice.
- Is there are workflow that can be created as a Re-usable library ?
Extensibility
- Easy to add enhancements with minimal changes to the existing workflow
Download UiPath Code Review Checklist
Conclusion
But most importantly, keep improving your code review checklist. The chances of you getting a perfect checklist the first time you build one are slim.
Find out which bugs have slipped through the review process and add the necessary checklist items to prevent them.
The above code review checklist is not exhaustive but provides a direction to the code reviewer to conduct effective code reviews and deliver good quality code.
Initially, it would take some time to review the code from various aspects. After a bit of practice, code reviewers can perform effective code reviews, without much effort and time.
If you would like to become an expert code reviewer, this code review checklist serves as a great starting point.
Happy Code Reviewing!
Very well written article with important code review points.