# About Workflow Analyzer

> **Workflow Analyzer** is a static code analyzer that ensures your project meets high quality and reliability standards. A static code analyzer checks for inconsistencies without actually executing the project, as opposed to dynamic analyzers which step in during execution.

**Workflow Analyzer** is a static code analyzer that ensures your project meets high quality and reliability standards. A static code analyzer checks for inconsistencies without actually executing the project, as opposed to dynamic analyzers which step in during execution.

**Workflow Analyzer** uses a set of rules to check for various inconsistencies unrelated to project execution. The rules are based on [Automation Best Practices](https://docs.uipath.com/studio/standalone/latest/user-guide/workflow-design#workflow-design) 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.

![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/studio-docs-image-617028-9f22c175.webp)

It is available in the **Design** ribbon tab as the **Analyze File** and **Analyze Project** buttons. The first performs an analysis on the file currently focused in the **Designer** panel, while the second analyzes all files in the automation project.

You can also use the **Build Project** button to check for compilation errors. This allows you to compile a project without running or publishing it.

Studio comes with a set of built-in rules, identifiable by the `ST-` prefix. The [UIAutomation.Activities](https://docs.uipath.com/activities/docs/ui-automation-workflow-analyzer-rules), [Excel.Activities](https://docs.uipath.com/activities/docs/excel-workflow-analyzer-rules), [Testing Activities](https://docs.uipath.com/activities/docs/application-testing-workflow-analyzer-rules), and [Mail.Activities](https://docs.uipath.com/activities/docs/mail-workflow-analyzer-rules) also have their own rules, identifiable by the prefix. Find more in the table below:

| Rule Category | Description | Source |
| --- | --- | --- |
| [Naming](https://docs.uipath.com/studio/standalone/2023.4/user-guide/naming-rules) | Checks the file or project for any inconsistencies related to naming. | Studio |
| [Design](https://docs.uipath.com/studio/standalone/2023.4/user-guide/design-best-practices) | Ensures your project meets a general set of [best practices](https://docs.uipath.com/studio/standalone/2023.4/user-guide/workflow-design). | Studio |
| [Project Anatomy](https://docs.uipath.com/studio/standalone/2023.4/user-guide/project-anatomy-rules) | Ensures your project meets general requirements in terms of anatomy. | Studio |
| [Maintainability and Readability](https://docs.uipath.com/studio/standalone/2023.4/user-guide/maintainability-readability-rules) | Confirms projects are easy to understand so that maintainability is ensured. | Studio |
| [Usage](https://docs.uipath.com/studio/standalone/2023.4/user-guide/usage-rules) | Ensures elements defined in your project are actually used. | Studio |
| [Performance and Reusability](https://docs.uipath.com/studio/standalone/2023.4/user-guide/performance-and-reusability-rules) | Checks the file or project for any inconsistencies related to performance and reusability. | Studio |
| [Reliability](https://docs.uipath.com/studio/standalone/2023.4/user-guide/reliability-rules) | Checks the file or project for any inconsistencies related to reliability. | Studio |
| [Security](https://docs.uipath.com/studio/standalone/2023.4/user-guide/security-rules) | Checks the file or project for any inconsistencies related to security. | Studio |
| [Application Testing](https://docs.uipath.com/activities/other/latest/workflow/application-testing-workflow-analyzer-rules) | Tests the workflows and automation projects. | Activities |
| [UI Automation Activities](https://docs.uipath.com/activities/other/latest/ui-automation/ui-automation-workflow-analyzer-rules) | Validates workflows that consume either Classic or Modern UI Automation activities. | Activities |
| [Excel Activities](https://docs.uipath.com/activities/other/latest/productivity/excel-workflow-analyzer-rules) | Validates workflows that consume Excel Activities. | Activities |
| [Mail Activities](https://docs.uipath.com/activities/other/latest/productivity/mail-workflow-analyzer-rules) | Validates workflows that consume Mail Activities. | Activities |

You can also create custom rules. For more information, see [Building Workflow Analyzer Rules](https://docs.uipath.com/developer/other/latest/developer-guide/building-workflow-analyzer-rules) in the Developer guide.

Rules can also be configured when creating a Studio policy in Automation Ops. For more information, see the Automation Ops [guide](https://docs.uipath.com/automation-ops/automation-cloud/latest/user-guide/settings-for-studio-policies#workflow-analyzer).

:::note
Studio built-in rules cannot be ported to older Studio versions. However, rules from compatible activities packages can be used in older Studio versions that come with the Workflow Analyzer.
:::

## Rules Naming Convention

Each rule has an ID, name, description, and recommendation. The ID contains the origin, category, and number. For example, [Variables Naming Convention](https://docs.uipath.com/studio/standalone/latest/user-guide/st-nmg-001) has the `ST-NMG-001` ID:

* `ST` - reveals that the rule is built into Studio.
* `NMG` - shows that the rule is part of the [Naming Rules](https://docs.uipath.com/studio/standalone/latest/user-guide/naming-rules) category. Rules part of [Project Anatomy Rules](https://docs.uipath.com/studio/standalone/latest/user-guide/project-anatomy-rules) category have the `ANA` abbreviation, those part of [Design Best Practices](https://docs.uipath.com/studio/standalone/latest/user-guide/design-best-practices) the `DBP`, and so on.
* `001` - is the rule number.

  ![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/studio-docs-image-168449-e79ed4a0.webp)

## Scope

Each rule has a scope to which it applies:

* **Activity**: The rules are enforced at activity level, checking variables, arguments, properties. [Variables Naming Convention](https://docs.uipath.com/studio/standalone/latest/user-guide/st-nmg-001) is one such rule.
* **Workflow**: Rules perform checks in a single project file, for example [Unused Variables](https://docs.uipath.com/studio/standalone/latest/user-guide/st-usg-009).
* **Project**: Checks are performed at project level.

## Action

Rules have a number of actions that can be set:

* **Error**: Generates an error in the **Errors** panel.
* **Warning**: Generates a warning in the **Errors** panel.
* **Info**: Generates a message in the **Errors** panel.
* **Verbose**: Creates large log files.

Check the [Logging Levels](https://docs.uipath.com/studio/standalone/latest/user-guide/logging-levels#logging-levels) page to learn more about logging with Studio.

## Managing Rules

The project or file is analyzed based on a set of rules available in the **Project Settings** window:

* In the **Project** panel, click the ![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/studio-image-properties_button-b787d949.png) icon, then select **Workflow Analyzer**.
* In the ribbon, click the **Analyze File** button, then select **Workflow Analyzer Settings** from the dropdown.

By default, rules are arranged by code in the window, and enabled rules are displayed first.

Use the search box at the top of the window to search rules by name or code. To filter rules by scope and default action, click the ![](https://dev-assets.cms.uipath.com/assets/images/studio/studio-image-packages_filter-859b7811.png) button to the right of the search box.

  ![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/studio-docs-image-167505-5ea7be1e.webp)

### Configure Rules

You can enable/disable a rule using the checkbox on its left, or change the default action using the dropdown on its right.

Some rules require no additional configuration, while others contain parameters that you can configure, such as thresholds not to be exceeded, or lists of specific items that are allowed or prohibited. Please note that when you configure rules that contain text fields (for example [SecureString Misusage](https://docs.uipath.com/studio/standalone/latest/user-guide/st-sec-009) or [Package Restrictions](https://docs.uipath.com/studio/standalone/latest/user-guide/st-usg-014)), text shouldn't be entered between quotes.

### Reset to Default

After any changes were made to the default values of rules, be it Regex or thresholds, the values may be reverted to default by right-clicking the rule and then selecting **Reset to Default**.

  ![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/studio-docs-image-166415-cd79eeb6.webp)

## Validation

Validation of the file or project is performed whenever the **Workflow Analyzer** is triggered. Validation options are available in the **Analyze File** ribbon button, **Validate File** and **Validate Project**.

This action checks whether variables, arguments, expressions, and imports are properly configured. The **Validate File** action can be triggered using the **F8** shortcut, while **Validate Project** using **Shift + F8**. Validation can be cancelled at any time.

The file(s) that contain errors are marked in the **Project** panel with a red dot, and the errors are shown in the **Errors** and **Output** panels.

Double-clicking an item in the **Errors** panel opens the `.xaml` and highlights the element which threw the error, whether it's an activity, argument, or variable.

Unless all `.xaml` files are validated, the project cannot be debugged, executed or published. Breakpoint conditions are not evaluated.

## Managing Errors

When triggered, the **Workflow Analyzer** uses the configured ruleset to check the project or file, and logs the found errors in the **Errors** panel, in accordance with the rule action.

  ![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/studio-docs-image-167869-f2d58498.gif)

The **Errors** panel filters items by **Errors**, **Warnings** and **Messages**. The scope drop-down menu is useful for filtering errors by project, current file or a specific file in the automation. In addition, items can be filtered by rule ID.

  ![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/studio-docs-image-615221-febce3fc.webp)

Click a found warning or error to display the rule’s recommendation and a link to the documentation page for each rule.

In addition to rule violations, the Errors panel also displays errors that may occur in the execution of workflow analysis, When the Workflow Analyzer or one of the configured rules fails to run, an error is logged with details about the cause of the error in the description.

You can also hover over an error and select the **Autopilot** ![](https://dev-assets.cms.uipath.com/assets/images/studio/studio-image-615231-94207b6d.webp) button to send the error to the Autopilot panel. You can then ask Autopilot to fix the error or ask questions about potential fixes.

## Command-Line Support

The `UiPath.Studio.CommandLine.exe` command-line user interface contains a set of parameters for checking files or projects against certain rules, even in CI/CD pipeline configurations.

`UiPath.Studio.CommandLine.exe` is available in the installation folder:

* For per-machine installations, the default path is `%ProgramFiles%\UiPath\Studio\`
* For per-user installations, the default path is `%LocalAppData%\Programs\UiPath\Studio`
  :::note
  `UiPath.Studio.CommandLine.exe` does not require a Studio license.
  :::
Configure Rules

By default, all Workflow Analyzer rules are enabled when installing Studio with the exception of the following:

* [Argument Default Values](https://docs.uipath.com/studio/standalone/latest/user-guide/st-nmg-012)
* [Undefined Output Properties](https://docs.uipath.com/studio/standalone/latest/user-guide/st-dbp-020)

You can configure rules:

* From the Workflow Analyzer Settings window, enable or disable rules by clicking the checkbox next to each one of them,
* From the `RuleConfig.json` file, path `%LocalAppData%\UiPath\Rules`. Find a specific rule, modify its parameter, change the `IsEnabled` parameter to `false` to disable the rule. Optionally, if the path is not accessible, you can place the `RuleConfig.json` file in a custom location and include the path to the file in the command. For more information, see [Analyze Files and Projects](https://docs.uipath.com/studio/standalone/latest/user-guide/about-workflow-analyzer).

Rules are organized according to their unique ID, visible in the **Workflow Analyzer Settings** also.

For example, in the image below only the [Variables Naming Convention](https://docs.uipath.com/studio/standalone/latest/user-guide/st-nmg-001) rule was enabled and received the `([A-Z])` Regex expression. This means that variable names must be uppercase. All the other rules were disabled in this example.

  ![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/studio-docs-image-267550-b57787c6.webp)

The following parameters are available for each rule:

| Parameter | Description |
| --- | --- |
| RuleId | The ID of the rule. |
| IsEnabled | Whether the rule is enabled or disabled. If set to null, the value of the parameter DefaultIsEnabled is applied. |
| DefaultIsEnabled | Whether the rule is enabled or disabled by default. |
| DefaultErrorLevel | The default level of the log message (Error, Warning, Info, Verbose). |
| Parameters | Additional parameters that the rule can contain (for example, Name or Value). |
| ErrorLevel | The level of the log message. If set to null, the value of the parameter DefaultErrorLevel is applied. |

### Analyze Files and Projects

After configuring the rules, access the `UiPath.Studio.CommandLine.exe` command-line user interface.

The following Workflow Analyzer commands are available:

* `analyze` - Analyzes the whole project. Requires the path to the `project.json` file.
* `analyze-file` - Analyzes a single file. Requires the path to the `.xaml` file.

The following arguments are available for Workflow Analyzer commands:

| Argument | Description |
| --- | --- |
| `-p, --project-path` | For analyzing one file, provide the path to the `.xaml`. For analyzing the entire project, specify the path to the `project.json` file. |
| `-c, --config-path` | Path to the `RuleConfig.json` file. Specify this path only if the rule configuration file is not placed in the default location (`%LocalAppData%\UiPath\Rules`). |
| `--help` | View the arguments available for each command. |
| `--version` | Check the version of `UiPath.Studio.CommandLine.exe`. |

For example, the command `UiPath.Studio.CommandLine.exe analyze-file -p "C:\BlankProcess\Main.xaml"` analyzes only one file in a project, `Main.xaml`. The output of the command returns a json-encoded dictionary with the following information for each rule violation:

* `FilePath`: The path to the analyzed file.
* `ErrorCode` : The rule ID.
* `ActivityDisplayName`: The display name of the activity (`null` if not applicable).
* `Item` - The name and type of the item (for example, activity or variable) where the error message was generated.
* `ErrorSeverity`: The value of the `DefaultAction` parameter, which is the configured log message for each rule, either Warning, Error, Info or Verbose.
* `Description`: The rule's description.
* `Recommendation` and `URL`: The recommended changes for solving the issue, together with the documentation link with more information.

  ![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/studio-docs-image-168073-2e89e72b.webp)

To use a `RuleConfig.json` file placed in a custom location, add the location to the command. Using the previous command as an example, to configure rules with the file located at `C:\CustomFolder\RuleConfig.json`, run the command as follows: `UiPath.Studio.CommandLine.exe analyze-file -c "C:\CustomFolder\RuleConfig.json" -p "C:\BlankProcess\Main.xaml"`.

To return the exit code of the command, execute `echo %errorlevel%` after you run it. If there are no messages with the `ErrorSeverity` Error, the code `0` is returned. Otherwise, `1` is returned.

Please note that some of the entries may not be associated with a rule, but can be errors generated by the Workflow Analyzer. For example, in the case of an empty `.xaml` file, an error is displayed.

The Globally Unique Identifiers (GUID) used as prefixes for an entry are generated on each run and apply to the current result only.

## Exporting Workflow Analyzer Results

To configure Studio to export the results of each workflow analysis to the project folder, go to **Studio Backstage View** &gt; **Settings** &gt; **Design** and enable the **Export Analyzer results** option.

When this option is enabled, the results of each workflow analysis are saved in the `\.local\.analysis\` subfolder of the project folder in a file named with the timestamp of the analysis followed either by `project_analysis_results.json` (when the **Analyze Project** option is used) or `file_analysis_results.json` (when the **Analyze File** option is used) .

:::note
The `.local` folder is hidden. You can enable viewing hidden items from the Windows File Explorer settings.
:::

The files contain the following information about each enabled rule:

* `RuleId` - The rule ID.
* `RuleName` - The name of the rule.
* `Parameters` - The customizable parameters in the rule, if applicable.
* `Severity` - The rule action, if the rule is violated.
* `ErrorsDescription` - A list of error messages generated by the rule, if applicable.

## Enforcing the Workflow Analyzer before Run, Publish, or Push/Check in

You can prevent executing, publishing, and pushing/checking in to remote repositories projects that contain Workflow Analyzer errors by enabling the following options from **Studio Backstage View** &gt; **Settings** &gt; **Design**:

* **Enforce Analyzer before Run** - Whenever running/debugging a file or project is initiated, the Workflow Analyzer checks all the rules with the `Error` action and execution is allowed only if no errors are found.
* **Enforce Analyzer before Publish** - Whenever publishing is initiated, the Workflow Analyzer checks all enabled rules regardless of their action and publishing is allowed only if there are no rule violations with the action `Error`.
* **Enforce Analyzer before Push/Check-in** - Whenever sending a project to a remote repository is initiated (**Commit and Push** for GIT, **Check in** for SVN and TFS), the Workflow Analyzer checks all enabled rules regardless of their action and the operation is allowed only if there are no rule violations with the action `Error`.

When Enforce Analyzer before Publish is enabled, if publishing is successful (there are no rule violations with the action `Error`) the results of the workflow analysis are included in the published `.nupkg` package in the file `project_analysis_results.json` located in `\lib\net45\.analysis\`. The file contains the following information about each enabled rule:

* `RuleId` - The rule ID.
* `RuleName` - The name of the rule.
* `Parameters` - The customizable parameters in the rule, if applicable.
* `Severity` - The rule action (if the rule is violated).
* `ErrorsDescription` - A list of error messages generated by the rule, if applicable.
