# Static Code Check Using Mule Sonar Plugin

### Prerequisites:

* Docker
    
* SonarQube
    
* Anypoint Studio
    

### Installation of Docker:

* [Installation on Windows](https://docs.docker.com/desktop/install/windows-install/)
    
* [Installation on Mac](https://docs.docker.com/desktop/install/mac-install/)
    

### Installation of mule sonar plugin:

* [mule-sonar Repository link](https://github.com/mulesoft-catalyst/mule-sonarqube-plugin#server)
    

[https://github.com/mulesoft-catalyst/mule-sonarqube-plugin#server](https://github.com/mulesoft-catalyst/mule-sonarqube-plugin#server)

* On successful installation of docker run the below command to install mule sonar plugin
    

```c
               docker pull fperezpa/mulesonarqube:7.7.3
```

* On successful installation of sonar run the following command to start the sonar.
    

```c
docker run -d --name sonarqube -p 9000:9000 -p 9092:9092 fperezpa/mulesonarqube:7.7.3
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695722838461/7c07e188-0a3c-42f8-833a-24bd1005a0f0.png align="center")

* On Docker, screen sonar status can be seen
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695722901210/56d29467-b3c0-4762-8b82-90678ffaa0ac.png align="center")

* On a Successful run and once the Sonar is **Up**.
    
* Call [http://localhost:9000](http://localhost:9000) on the browser.
    
* Pass credentials below
    
    username: admin
    
                                  Password: admin
    
    ### Static Code Check:
    
* Update the properties with
    

```xml
                <sonar.sources>src/</sonar.sources>
```

* Update profiles to connect with sonar.
    

```xml
        <profiles>
        		<profile>
        			<id>sonar</id>
        			<activation>
        				<activeByDefault>true</activeByDefault>
        			</activation>
        			<properties>
        				<sonar.host.url>
        					http://localhost:9000
        				</sonar.host.url>
        			</properties>
        		</profile>
        </profiles>
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695723688671/0558e883-36c4-4f76-ba3e-f40e724a0d68.jpeg align="center")

* Run the following command at project exists where pom.xml exists.
    

```xml
                mvn sonar:sonar
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695723824384/ace00824-7a24-402d-b4c9-162e34524c59.png align="center")

* On successful build at [http://lolcahost:9000/projects](http://lolcahost:9000/projects), you can see the project got created with static code check.
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695723905985/573ec53a-c427-48eb-aeba-b9025e90f828.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695723932823/40a10288-bf8d-4f2d-8c31-6c49ccd64b7c.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695723954956/a6ef3706-3b06-4723-8d02-b9c4fc27dfff.png align="center")
