> For the complete documentation index, see [llms.txt](https://knowledgebase.autorabit.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://knowledgebase.autorabit.com/product-guides/integral-zone/iz-analyzer/autofix/autofix-in-scanner.md).

# Autofix - In Scanner

Autofix in scanner is a feature where static code analysis issues can be fixed automatically by enabling a few properties while scanning the projects.

{% hint style="warning" %}
Make sure you have a:

* Valid license with Autofix module enabled for either Mule or API or both
  {% endhint %}

### Enable Auto Fix

1. Autofix can be enabled by passing **`analyzer.<plugin>.auto.fix.all`** system property while running the sonarscanner/mvn command to analyze the project. For more information refer Code Analysis In Server
   * Ex: -Danalyzer.mule.auto.fix.all=true\
     \&#xNAN;*To enable auto fix for Mule plugin*
   * Ex: -Danalyzer.api.auto.fix.all=true\
     \&#xNAN;*To enable auto fix for API plugin*
2. Preview mode can be enabled to get the list of changes that would be performed by Auto Fix without updating any of the files.
   * Can be enabled using **`-Danalyzer.<plugin>.auto.fix.preview`** system property
3. Default log location is **`target/autofix_log.csv`** relative to the project from which scanner is invoked. This property can be customized using **`analyzer.<plugin>.auto.fix.log.location`** system property.
4. Fix can also be applied only on certain issues by passing various filters. Every rule will be associated with a **`Type`**, **`Severity`** and **`Tag`**, any of these properties can be used to specify the filters
   * Ex: -Danalyzer.\<plugin>.auto.fix.rule.severities can be set to MAJOR,MINOR to fix only major and minor issues
   * Ex: -Danalyzer.\<plugin>.auto.fix.rule.types can be set to CODE\_SMELL to fix only Code Smells
   * Ex: -Danalyzer.\<plugin>.auto.fix.rule.tags can be set to any custom tags attached to the rule. Only rules with specified tags will be auto fixed in this case.

### Mule Scanner Properties

Following parameters can be passed as system properties to Mule scanner.

| Property Name                                | Description                                                                                                                                                                   | Possible Values                                       | Default                                 |
| -------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------- | --------------------------------------- |
| **`analyzer.mule.auto.fix.all`**             | Enable auto fix for the Mule scanner                                                                                                                                          | true / false                                          | false                                   |
| **`analyzer.mule.auto.fix.log.location`**    | Location of the Auto Fix log. Logs will be generated in .csv format                                                                                                           | Any location where the .csv should be generated       | target/autofix\_log.csv                 |
| **`analyzer.mule.auto.fix.preview`**         | Enable or disable the Auto Fix preview mode                                                                                                                                   | true / false                                          | false                                   |
| **`analyzer.mule.auto.fix.rule.types`**      | Rule types to be auto fixed. Only those issues with specified rule types will be fixed. Multiple rule types can be specified by using comma(,) as a delimiter.                | BUG / VULNERABILITY / CODE\_SMELL / SECURITY\_HOTSPOT | By default all the issues will be fixed |
| **`analyzer.mule.auto.fix.rule.severities`** | Rule severities to be auto fixed. Only those issues with specified rule severities will be fixed. Multiple rule severities can be specified by using comma(,) as a delimiter. | BLOCKER / CRITICAL / MAJOR / MINOR / INFO             | By default all the issues will be fixed |
| **`analyzer.mule.auto.fix.rule.tags`**       | Rule tags to be auto fixed. Only those issues with specified rule tags will be fixed. Multiple rule tags can be specified by using comma(,) as a delimiter.                   | Any tags associated with rule                         | By default all the issues will be fixed |

### API Scanner Properties

Following parameters can be passed as system properties to API scanner.

| Property Name                               | Description                                                                                                                                                                   | Possible Values                                       | Default                                 |
| ------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------- | --------------------------------------- |
| **`analyzer.api.auto.fix.all`**             | Enable auto fix for the API scanner                                                                                                                                           | true / false                                          | false                                   |
| **`analyzer.api.auto.fix.log.location`**    | Location of the Auto Fix log. Logs will be generated in .csv format                                                                                                           | Any location where the .csv should be generated       | target/autofix\_log.csv                 |
| **`analyzer.api.auto.fix.preview`**         | Enable or disable the Auto Fix preview mode                                                                                                                                   | true / false                                          | false                                   |
| **`analyzer.api.auto.fix.rule.types`**      | Rule types to be auto fixed. Only those issues with specified rule types will be fixed. Multiple rule types can be specified by using comma(,) as a delimiter.                | BUG / VULNERABILITY / CODE\_SMELL / SECURITY\_HOTSPOT | By default all the issues will be fixed |
| **`analyzer.api.auto.fix.rule.severities`** | Rule severities to be auto fixed. Only those issues with specified rule severities will be fixed. Multiple rule severities can be specified by using comma(,) as a delimiter. | BLOCKER / CRITICAL / MAJOR / MINOR / INFO             | By default all the issues will be fixed |
| **`analyzer.api.auto.fix.rule.tags`**       | Rule tags to be auto fixed. Only those issues with specified rule tags will be fixed. Multiple rule tags can be specified by using comma(,) as a delimiter.                   | Any tags associated with rule                         | By default all the issues will be fixed |

### Multiple Plugins Scanning the Same Project

While scanning the Mule projects, by default Mule and API Analyzer plugins would report the static code analysis issues. If there are any other open source plugins scanning files in the same project, then the **`Background Task`** might fail in the server with an error \_ Source of file has less/more lines than expected\_ .

As a resolution the scanner command should be executed again without **`analyzer.<plugin>.auto.fix.all`** system property.

* Scan 1 - To auto Fix issues \_sonar-scanner -Dsonar.projectKey=\<key> -Dsonar.sources=. -Dsonar.host.url=\<host> -Dsonar.login=\<token> -Dsonar.exclusions=target/\*\* -Danalyzer.api.auto.fix.all=true -Danalyzer.mule.auto.fix.all=true \_
* Scan 2 - To upload results to the server \_sonar-scanner -Dsonar.projectKey=\<key> -Dsonar.sources=. -Dsonar.host.url=\<host> -Dsonar.login=\<token> -Dsonar.exclusions=target/\*\* \_

#### Details

* [Manage Anypoint Studio Plugin](/product-guides/integral-zone/iz-suite/iz-scan/anypoint-studio/installation/install-iz-analyzer-studio.md)
* [Manage Server Plugin](/product-guides/integral-zone/iz-analyzer/manage-server-plugin/install-server-plugin.md)

***

[SonarQube™](https://www.sonarqube.org) is a trademark belonging to SonarSource SA. For further information, please visit [www.sonarqube.org](https://www.sonarqube.org).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://knowledgebase.autorabit.com/product-guides/integral-zone/iz-analyzer/autofix/autofix-in-scanner.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
