SonarQube code coverage for AEM project

Avatar

Avatar
Ignite 1
Level 1
Debal-Das
Level 1

Likes

0 likes

Total Posts

3 posts

Correct reply

0 solutions
Top badges earned
Ignite 1
Give Back
View profile

Avatar
Ignite 1
Level 1
Debal-Das
Level 1

Likes

0 likes

Total Posts

3 posts

Correct reply

0 solutions
Top badges earned
Ignite 1
Give Back
View profile
Debal-Das
Level 1

13-04-2020

Hi All,

 

We are using separate Sonarqube server and integrated with our application. Using that we are able to receive the code vulnerabilities properly. But Generating the Code Coverage is having issues. Currently we have integrated with Jacoco Plugin with SonarQube for  Code Coverage and we have installed Sonarqube with AEM rules plugin version 1.0.

 

We have done below changes in POM file -

 

POM Changes

 

<properties>

        <sonar.exclusions>**/*.js,**/*.xml,lib/*,packages/*,ui.galen/*,**/*.json,ui.npm/*,content/*</sonar.exclusions>

        <sonar.junit.reportPaths>bundle/target/surfire-reports</sonar.junit.reportPaths>

        <sonar.jacoco.reportPaths>bundle/target/jacoco.exec</sonar.jacoco.reportPaths>

</properties>

<plugin>

<groupId>org.jacoco</groupId>

<artifactId>jacoco-maven-plugin</artifactId>

<version>0.7.9</version>

<executions>

              <execution>

                             <id>pre-unit-test</id>

                             <goals>

                                           <goal>prepare-agent</goal>

                             </goals>

                             <configuration>

                                           <!-- Sets the path to the file which contains the execution data. -->

                                           <destFile>bundle/target/jacoco.exec</destFile>

                                           <excludes>

                                                          <exclude>**/*.js</exclude>

                                                          <exclude>**/*.xml</exclude>

                                                          <exclude>lib/*</exclude>

                                                          <exclude>packages/*</exclude>

                                                          <exclude>ui.galen/*</exclude>

                                                          <exclude>**/*.json</exclude>

                                                          <exclude>ui.npm/*</exclude>

                                                          <exclude>content/*</exclude>

                                           </excludes>

                                           <!-- Sets the name of the property containing the settings for JaCoCo runtime agent. -->

                                           <propertyName>surefireArgLine</propertyName>

                             </configuration>

              </execution>

              <!-- Ensures that the code coverage report for unit tests is created after unit tests have been run. -->

              <execution>

                             <id>post-unit-test</id>

                             <phase>test</phase>

                             <goals>

                                           <goal>report</goal>

                             </goals>

                             <configuration>

                                           <!-- Sets the path to the file which contains the execution data. -->

                                           <dataFile>bundle/target/jacoco.exec</dataFile>

                                           <!-- Sets the output directory for the code coverage report. -->

                                           <outputDirectory>bundle/target</outputDirectory>

                             </configuration>

              </execution>

              <execution>

                             <id>generate-code-coverage-report</id>

                             <phase>test</phase>

                             <goals>

                                             <goal>report</goal>

                             </goals>

              </execution>

</executions>

</plugin>

 

SONAR Command Used

 

mvn clean package sonar:sonar

 

With all these changes we are getting code coverage 0.0. So, please help me to resolve this issue.

 

Note: We are able to see the Code Coverage in IDE – Eclipse/IntelliJ. But not able to get the coverage report in sonarqube site. 

 

Thanks,

Debal

Replies

Avatar

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,134 likes

Total Posts

3,161 posts

Correct reply

1,079 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,134 likes

Total Posts

3,161 posts

Correct reply

1,079 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile
Jörg_Hoh
Employee

13-04-2020

This question is not specific to AEM, but rather belongs to a SonarQube forum.

Avatar

Avatar
Validate 1
MVP
Theo_Pendle
MVP

Likes

238 likes

Total Posts

251 posts

Correct reply

105 solutions
Top badges earned
Validate 1
Ignite 5
Ignite 3
Ignite 10
Ignite 1
View profile

Avatar
Validate 1
MVP
Theo_Pendle
MVP

Likes

238 likes

Total Posts

251 posts

Correct reply

105 solutions
Top badges earned
Validate 1
Ignite 5
Ignite 3
Ignite 10
Ignite 1
View profile
Theo_Pendle
MVP

13-04-2020

Hi,

What do you mean by "plugin" exactly? 

If you mean special rules for AEM projects, you can find those (and installation instructions) here: https://github.com/Cognifide/AEM-Rules-for-SonarQube

If you are talking about an IDE plugin that will do the same analysis, then you are looking for this: https://www.sonarlint.org/intellij/. You can install that plugin in IntelliJ for example and then connect to a remote SonarQube server to make sure you are using the same rules in the IDE as Sonar will during static analysis.

Avatar

Avatar
Ignite 1
Level 1
Debal-Das
Level 1

Likes

0 likes

Total Posts

3 posts

Correct reply

0 solutions
Top badges earned
Ignite 1
Give Back
View profile

Avatar
Ignite 1
Level 1
Debal-Das
Level 1

Likes

0 likes

Total Posts

3 posts

Correct reply

0 solutions
Top badges earned
Ignite 1
Give Back
View profile
Debal-Das
Level 1

13-04-2020

Hi ,

 

Apologize for the confusion.

 

Please allow me to provide details here.

 

We are using separate Sonarqube server and integrated with our application. Using that we are able to receive the code vulnerabilities properly. But Generating the Code Coverage is having issues. Currently we have integrated with Jacoco Plugin with SonarQube for  Code Coverage and we have installed Sonarqube with AEM rules plugin version 1.0.

 

We have done below changes in POM file -

 

POM Changes

 

<properties>

        <sonar.exclusions>**/*.js,**/*.xml,lib/*,packages/*,ui.galen/*,**/*.json,ui.npm/*,content/*</sonar.exclusions>

        <sonar.junit.reportPaths>bundle/target/surfire-reports</sonar.junit.reportPaths>

        <sonar.jacoco.reportPaths>bundle/target/jacoco.exec</sonar.jacoco.reportPaths>

</properties>

<plugin>

<groupId>org.jacoco</groupId>

<artifactId>jacoco-maven-plugin</artifactId>

<version>0.7.9</version>

<executions>

              <execution>

                             <id>pre-unit-test</id>

                             <goals>

                                           <goal>prepare-agent</goal>

                             </goals>

                             <configuration>

                                           <!-- Sets the path to the file which contains the execution data. -->

                                           <destFile>bundle/target/jacoco.exec</destFile>

                                           <excludes>

                                                          <exclude>**/*.js</exclude>

                                                          <exclude>**/*.xml</exclude>

                                                          <exclude>lib/*</exclude>

                                                          <exclude>packages/*</exclude>

                                                          <exclude>ui.galen/*</exclude>

                                                          <exclude>**/*.json</exclude>

                                                          <exclude>ui.npm/*</exclude>

                                                          <exclude>content/*</exclude>

                                           </excludes>

                                           <!-- Sets the name of the property containing the settings for JaCoCo runtime agent. -->

                                           <propertyName>surefireArgLine</propertyName>

                             </configuration>

              </execution>

              <!-- Ensures that the code coverage report for unit tests is created after unit tests have been run. -->

              <execution>

                             <id>post-unit-test</id>

                             <phase>test</phase>

                             <goals>

                                           <goal>report</goal>

                             </goals>

                             <configuration>

                                           <!-- Sets the path to the file which contains the execution data. -->

                                           <dataFile>bundle/target/jacoco.exec</dataFile>

                                           <!-- Sets the output directory for the code coverage report. -->

                                           <outputDirectory>bundle/target</outputDirectory>

                             </configuration>

              </execution>

              <execution>

                             <id>generate-code-coverage-report</id>

                             <phase>test</phase>

                             <goals>

                                             <goal>report</goal>

                             </goals>

              </execution>

</executions>

</plugin>

 

SONAR Command Used

 

mvn clean package sonar:sonar

 

With all these changes we are getting code coverage 0.0. So, please help me to resolve this issue.

 

Thanks,

Debal

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,440 likes

Total Posts

3,312 posts

Correct reply

941 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,440 likes

Total Posts

3,312 posts

Correct reply

941 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile
Arun_Patidar
MVP

13-04-2020

you can run the code coverage using in built eclipse plugin and follow the code quality rules https://docs.adobe.com/content/help/en/experience-manager-cloud-manager/using/how-to-use/understand-...

 

Screenshot 2020-04-13 at 4.05.24 PM.png