Skip to content

Commit

Permalink
Sonar coverage fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tshan10 committed Oct 22, 2024
1 parent 9e9a338 commit 9cd3984
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/sonarcloud-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ jobs:
restore-keys: ${{ runner.os }}-m2
- name: Build and analyze
env:
USER_NAME: ${{ secrets.PPE_USER_NAME }}
ACCESS_TOKEN: ${{ secrets.PPE_ACCESS_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=PhonePe_DLM
40 changes: 35 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
<sonatype.central.publishing.maven.plugin.version>0.5.0</sonatype.central.publishing.maven.plugin.version>
<maven.release.plugin.version>2.5.3</maven.release.plugin.version>
<maven.gpg.plugin.version>1.6</maven.gpg.plugin.version>
<maven.sonar.plugin.version>3.9.1.2184</maven.sonar.plugin.version>

<!-- Test related properties -->
<mockito.version>4.3.1</mockito.version>
Expand All @@ -97,14 +98,21 @@
<jdk.target.version>17</jdk.target.version>
<jdk.release.version>17</jdk.release.version>

<!-- Sonar properties -->
<sonar.projectKey>PhonePe_DLM</sonar.projectKey>
<sonar.organization>phonepe</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>

<sonar.sources>src/main</sonar.sources>
<sonar.tests>src/test</sonar.tests>
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<sonar.language>java</sonar.language>
<sonar.qualitygate.wait>true</sonar.qualitygate.wait>
<sonar.coverage.jacoco.xmlReportPaths>${project.basedir}/../target/site/jacoco/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
<sonar.exclusions>
<!-- Excluding test classes from sonar smells -->
**/src/test/com/phonepe/dlm/**/*.java,
**/src/test/com/phonepe/dlm/*.java
**/src/test/java/com/phonepe/dlm/**/*.java,
**/src/test/java/com/phonepe/dlm/*.java
</sonar.exclusions>
</properties>

Expand Down Expand Up @@ -275,25 +283,47 @@
<goals>deploy</goals>
</configuration>
</plugin>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>${maven.sonar.plugin.version}</version>
<executions>
<execution>
<id>sonar-run</id>
<phase>verify</phase>
<goals>
<goal>sonar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.maven.plugin.version}</version>
<executions>
<execution>
<id>prepare-agent</id>
<phase>initialize</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<append>true</append>
</configuration>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
<configuration>
<excludes>
<exclude>**/src/test/**</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
Expand Down

0 comments on commit 9cd3984

Please sign in to comment.