Skip to content

Commit 0884762

Browse files
authored
CC-23123 : Integrated Sonarqube code quality check (#677)
1 parent 3d1fc81 commit 0884762

File tree

3 files changed

+117
-0
lines changed

3 files changed

+117
-0
lines changed

Jenkinsfile

100755100644
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ common {
33
slackChannel = '#connect-warn'
44
upstreamProjects = ['confluentinc/schema-registry','confluentinc/common']
55
nodeLabel = 'docker-debian-jdk8'
6+
sonarqubeScannerEnable = true
7+
sonarqubeQualityCheck = true
68
}

pom.xml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@
5858
<hadoop.version>2.7.3</hadoop.version>
5959
<apacheds-jdbm1.version>2.0.0-M2</apacheds-jdbm1.version>
6060
<kafka.connect.maven.plugin.version>0.11.1</kafka.connect.maven.plugin.version>
61+
<instruction.coverage.threshold>0.65</instruction.coverage.threshold>
62+
<branch.coverage.threshold>0.59</branch.coverage.threshold>
63+
<method.coverage.threshold>0.63</method.coverage.threshold>
64+
<class.coverage.threshold>0.67</class.coverage.threshold>
65+
<complexity.coverage.threshold>0.53</complexity.coverage.threshold>
66+
<line.coverage.threshold>0.66</line.coverage.threshold>
6167
</properties>
6268

6369
<repositories>
@@ -265,6 +271,107 @@
265271
</filesets>
266272
</configuration>
267273
</plugin>
274+
<plugin>
275+
<groupId>org.jacoco</groupId>
276+
<artifactId>jacoco-maven-plugin</artifactId>
277+
<version>0.8.11</version>
278+
<configuration>
279+
<excludes>
280+
<exclude>**/model/**</exclude>
281+
<exclude>**/rest/**</exclude>
282+
</excludes>
283+
</configuration>
284+
<executions>
285+
<execution>
286+
<id>prepare-agent</id>
287+
<goals>
288+
<goal>prepare-agent</goal>
289+
</goals>
290+
</execution>
291+
<execution>
292+
<id>prepare-agent-it</id>
293+
<goals>
294+
<goal>prepare-agent-integration</goal>
295+
</goals>
296+
<phase>pre-integration-test</phase>
297+
</execution>
298+
<execution>
299+
<id>merge-coverage-reports</id>
300+
<phase>verify</phase>
301+
<goals>
302+
<goal>merge</goal>
303+
</goals>
304+
<configuration>
305+
<fileSets>
306+
<fileSet>
307+
<directory>${project.basedir}</directory>
308+
<includes>
309+
<include>/target/jacoco.exec</include>
310+
<include>/target/jacoco-it.exec</include>
311+
</includes>
312+
</fileSet>
313+
</fileSets>
314+
<destFile>${project.basedir}/target/jacoco-aggregate.exec</destFile>
315+
</configuration>
316+
</execution>
317+
<execution>
318+
<id>check</id>
319+
<goals>
320+
<goal>check</goal>
321+
</goals>
322+
<configuration>
323+
<rules>
324+
<rule>
325+
<element>BUNDLE</element>
326+
<limits>
327+
<limit>
328+
<counter>INSTRUCTION</counter>
329+
<value>COVEREDRATIO</value>
330+
<minimum>${instruction.coverage.threshold}</minimum>
331+
</limit>
332+
<limit>
333+
<counter>BRANCH</counter>
334+
<value>COVEREDRATIO</value>
335+
<minimum>${branch.coverage.threshold}</minimum>
336+
</limit>
337+
<limit>
338+
<counter>COMPLEXITY</counter>
339+
<value>COVEREDRATIO</value>
340+
<minimum>${complexity.coverage.threshold}</minimum>
341+
</limit>
342+
<limit>
343+
<counter>LINE</counter>
344+
<value>COVEREDRATIO</value>
345+
<minimum>${line.coverage.threshold}</minimum>
346+
</limit>
347+
<limit>
348+
<counter>METHOD</counter>
349+
<value>COVEREDRATIO</value>
350+
<minimum>${method.coverage.threshold}</minimum>
351+
</limit>
352+
<limit>
353+
<counter>CLASS</counter>
354+
<value>COVEREDRATIO</value>
355+
<minimum>${class.coverage.threshold}</minimum>
356+
</limit>
357+
</limits>
358+
</rule>
359+
</rules>
360+
<dataFile>${project.basedir}/target/jacoco-aggregate.exec</dataFile>
361+
</configuration>
362+
</execution>
363+
<execution>
364+
<id>generate-code-coverage-report</id>
365+
<phase>verify</phase>
366+
<goals>
367+
<goal>report</goal>
368+
</goals>
369+
<configuration>
370+
<dataFile>${project.basedir}/target/jacoco-aggregate.exec</dataFile>
371+
</configuration>
372+
</execution>
373+
</executions>
374+
</plugin>
268375
</plugins>
269376

270377
<resources>

sonar-project.properties

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
sonar.projectKey=kafka-connect-hdfs
2+
sonar.sources=src/main/java
3+
sonar.java.binaries=target/classes/**
4+
sonar.exclusions=**/test/**/*,**/tests/**/*,**/mock/**/*,**/mocks/**/*,**/*mock*,**/*test*
5+
sonar.test.inclusions=**/*Test.java,**/*IT.java,**/*Test*.java
6+
sonar.coverage.jacoco.xmlReportPaths=**/jacoco.xml
7+
sonar.java.tests.reportPaths=**/surefire/**
8+
sonar.language=java

0 commit comments

Comments
 (0)