March 23, 2021
Estimated Post Reading Time ~

AEM Sonar Integration

Usually in any of the projects, code quality plays an important role not only in the performance of your site as well as to detect bugs, but code also smells, and security vulnerabilities. In this article, I am going to discuss how we can set up sonar on our local instance to get all the issues fixed up before we merge our code.

Follow the below steps to integrate Sonar Qube Server with Code Branch:
1) Download Sonar Qube version 7.7 https://www.sonarqube.org/downloads/ ( Version compatible with Java 8)

2) Unzip the package, go inside the folder \bin\windows-x86-64 (Windows), and run StartSonar.bat.

3) Once up Sonar will be running on port 9000. (default port)

4) Now go the pom.xml of core branch of your project and add the following changes:

a) 
<properties>
    <sonar.host.url>http://localhost:9000</sonar.host.url>
</properties>


b) 
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.6.0.1398</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>sonar</goal>
</goals>
</execution>
</executions>
</plugin>


5) Now run mvn clean install on the core branch and check the sonar, you will be able to see all the changes of Sonar.

Note: Do not commit changes on point 4. I don’t want changes in pom.xml, run command mvn sonar:sonar

Additionally download and install the sonar lint eclipse plugin to have inbuilt code issues identified. This will give additional help to identify the quality issues upfront.


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.