Skip to content

Commit

Permalink
CC-23123 : Integrated Sonarqube code quality check (#677) (#680)
Browse files Browse the repository at this point in the history
Co-authored-by: Amit R <[email protected]>
  • Loading branch information
ConfluentJenkins and amitr17 authored Jan 2, 2024
1 parent bd77c34 commit 4898aae
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Jenkinsfile
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ common {
slackChannel = '#connect-warn'
upstreamProjects = ['confluentinc/schema-registry','confluentinc/common']
nodeLabel = 'docker-debian-jdk8'
sonarqubeScannerEnable = true
sonarqubeQualityCheck = true
disableConcurrentBuilds = true
}
107 changes: 107 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@
<confluent.maven.repo>http://packages.confluent.io/maven/</confluent.maven.repo>
<apacheds-jdbm1.version>2.0.0-M2</apacheds-jdbm1.version>
<kafka.connect.maven.plugin.version>0.11.1</kafka.connect.maven.plugin.version>
<instruction.coverage.threshold>0.65</instruction.coverage.threshold>
<branch.coverage.threshold>0.59</branch.coverage.threshold>
<method.coverage.threshold>0.63</method.coverage.threshold>
<class.coverage.threshold>0.67</class.coverage.threshold>
<complexity.coverage.threshold>0.53</complexity.coverage.threshold>
<line.coverage.threshold>0.66</line.coverage.threshold>
</properties>

<repositories>
Expand Down Expand Up @@ -274,6 +280,107 @@
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.11</version>
<configuration>
<excludes>
<exclude>**/model/**</exclude>
<exclude>**/rest/**</exclude>
</excludes>
</configuration>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>prepare-agent-it</id>
<goals>
<goal>prepare-agent-integration</goal>
</goals>
<phase>pre-integration-test</phase>
</execution>
<execution>
<id>merge-coverage-reports</id>
<phase>verify</phase>
<goals>
<goal>merge</goal>
</goals>
<configuration>
<fileSets>
<fileSet>
<directory>${project.basedir}</directory>
<includes>
<include>/target/jacoco.exec</include>
<include>/target/jacoco-it.exec</include>
</includes>
</fileSet>
</fileSets>
<destFile>${project.basedir}/target/jacoco-aggregate.exec</destFile>
</configuration>
</execution>
<execution>
<id>check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule>
<element>BUNDLE</element>
<limits>
<limit>
<counter>INSTRUCTION</counter>
<value>COVEREDRATIO</value>
<minimum>${instruction.coverage.threshold}</minimum>
</limit>
<limit>
<counter>BRANCH</counter>
<value>COVEREDRATIO</value>
<minimum>${branch.coverage.threshold}</minimum>
</limit>
<limit>
<counter>COMPLEXITY</counter>
<value>COVEREDRATIO</value>
<minimum>${complexity.coverage.threshold}</minimum>
</limit>
<limit>
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>${line.coverage.threshold}</minimum>
</limit>
<limit>
<counter>METHOD</counter>
<value>COVEREDRATIO</value>
<minimum>${method.coverage.threshold}</minimum>
</limit>
<limit>
<counter>CLASS</counter>
<value>COVEREDRATIO</value>
<minimum>${class.coverage.threshold}</minimum>
</limit>
</limits>
</rule>
</rules>
<dataFile>${project.basedir}/target/jacoco-aggregate.exec</dataFile>
</configuration>
</execution>
<execution>
<id>generate-code-coverage-report</id>
<phase>verify</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${project.basedir}/target/jacoco-aggregate.exec</dataFile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>

<resources>
Expand Down
8 changes: 8 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
sonar.projectKey=kafka-connect-hdfs
sonar.sources=src/main/java
sonar.java.binaries=target/classes/**
sonar.exclusions=**/test/**/*,**/tests/**/*,**/mock/**/*,**/mocks/**/*,**/*mock*,**/*test*
sonar.test.inclusions=**/*Test.java,**/*IT.java,**/*Test*.java
sonar.coverage.jacoco.xmlReportPaths=**/jacoco.xml
sonar.java.tests.reportPaths=**/surefire/**
sonar.language=java

0 comments on commit 4898aae

Please sign in to comment.