Skip to content

Commit

Permalink
Merge pull request #97 from ankitmashu/pmdandcheckstyle
Browse files Browse the repository at this point in the history
added setup part for pmd and checkstyle
  • Loading branch information
kailash authored May 1, 2023
2 parents 8eca65a + dc538d7 commit 130f808
Show file tree
Hide file tree
Showing 8 changed files with 703 additions and 556 deletions.
4 changes: 4 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ pipeline {
jacoco classPattern: 'target/classes', execPattern: 'target/jacoco.exec', sourcePattern: 'src/main/java', exclusionPattern:'iudx/gis/server/apiserver/*.class,**/*VertxEBProxy.class,**/Constants.class,**/*VertxProxyHandler.class,**/*Verticle.class,iudx/gis/server/deploy/*.class,iudx/gis/server/databroker/DataBrokerService.class,iudx/gis/server/databroker/DataBrokerServiceImpl.class,iudx/gis/server/apiserver/validation/types/Validator.class,iudx/gis/server/metering/MeteringService.class,iudx/gis/server/cache/CacheService.class,iudx/gis/server/database/postgres/PostgresService.class,**/*JwtDataConverter.class'
}
post{
always {
recordIssues enabledForFailure: true, tool: checkStyle(pattern: 'target/checkstyle-result.xml')
recordIssues enabledForFailure: true, tool: pmdParser(pattern: 'target/pmd.xml')
}
failure{
script{
sh 'docker compose -f docker-compose.test.yml down --remove-orphans'
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ services:
- /home/ubuntu/configs/keystore-gis.jks:/usr/share/app/configs/keystore.jks
- ./docker/runTests.sh:/usr/share/app/docker/runTests.sh
- ./src/:/usr/share/app/src
- ./iudx-pmd-ruleset.xml:/usr/share/app/iudx-pmd-ruleset.xml
- ./google_checks.xml:/usr/share/app/google_checks.xml
- ${WORKSPACE}:/tmp/test
- /var/run/docker.sock:/var/run/docker.sock
network_mode: host
Expand Down
2 changes: 2 additions & 0 deletions docker/depl.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ ENV JAR="iudx.gis.interface-cluster-${VERSION}-fat.jar"
WORKDIR /usr/share/app
# Copying openapi docs
COPY docs docs
COPY iudx-pmd-ruleset.xml iudx-pmd-ruleset.xml
COPY google_checks.xml google_checks.xml

# Copying cluster fatjar from builder stage to final image
COPY --from=builder /usr/share/app/target/${JAR} ./fatjar.jar
Expand Down
2 changes: 2 additions & 0 deletions docker/dev.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ ENV JAR="iudx.gis.interface-dev-${VERSION}-fat.jar"
WORKDIR /usr/share/app
# Copying openapi docs
COPY docs docs
COPY iudx-pmd-ruleset.xml iudx-pmd-ruleset.xml
COPY google_checks.xml google_checks.xml

# Copying dev fatjar from builder stage to final image
COPY --from=builder /usr/share/app/target/${JAR} ./fatjar.jar
Expand Down
2 changes: 1 addition & 1 deletion docker/runTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

nohup mvn clean compile exec:java@gis-server &
sleep 20
mvn clean test
mvn clean test checkstyle:checkstyle pmd:pmd
cp -r target /tmp/test/
197 changes: 124 additions & 73 deletions google_checks.xml

Large diffs are not rendered by default.

64 changes: 64 additions & 0 deletions iudx-pmd-ruleset.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="UTF-8"?>

<ruleset name="IUDX PMD RULESET"
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">

<description>
The default ruleset used by the Maven PMD Plugin, when no other ruleset is specified.
</description>

<rule ref="category/java/bestpractices.xml/AvoidUsingHardCodedIP" />
<rule ref="category/java/bestpractices.xml/CheckResultSet" />
<rule ref="category/java/bestpractices.xml/PrimitiveWrapperInstantiation" />
<rule ref="category/java/bestpractices.xml/UnusedFormalParameter" />
<rule ref="category/java/bestpractices.xml/UnusedLocalVariable" />
<rule ref="category/java/bestpractices.xml/UnusedPrivateField" />
<rule ref="category/java/bestpractices.xml/UnusedPrivateMethod" />

<rule ref="category/java/codestyle.xml/EmptyControlStatement" />
<rule ref="category/java/codestyle.xml/ExtendsObject" />
<rule ref="category/java/codestyle.xml/ForLoopShouldBeWhileLoop" />
<rule ref="category/java/codestyle.xml/UnnecessaryFullyQualifiedName" />
<!--<rule ref="category/java/codestyle.xml/UnnecessaryImport" />-->
<rule ref="category/java/codestyle.xml/UnnecessaryModifier" />
<rule ref="category/java/codestyle.xml/UnnecessaryReturn" />
<rule ref="category/java/codestyle.xml/UnnecessarySemicolon" />
<rule ref="category/java/codestyle.xml/UselessParentheses" />
<rule ref="category/java/codestyle.xml/UselessQualifiedThis" />

<rule ref="category/java/design.xml/CollapsibleIfStatements" />
<rule ref="category/java/design.xml/SimplifiedTernary" />
<rule ref="category/java/design.xml/UselessOverridingMethod" />
<rule ref="category/java/codestyle.xml/TooManyStaticImports">
<properties>
<property name="maximumStaticImports" value="100" />
</properties>
</rule>

<rule ref="category/java/errorprone.xml/AvoidBranchingStatementAsLastInLoop" />
<rule ref="category/java/errorprone.xml/AvoidDecimalLiteralsInBigDecimalConstructor" />
<rule ref="category/java/errorprone.xml/AvoidMultipleUnaryOperators" />
<rule ref="category/java/errorprone.xml/AvoidUsingOctalValues" />
<rule ref="category/java/errorprone.xml/BrokenNullCheck" />
<rule ref="category/java/errorprone.xml/CheckSkipResult" />
<rule ref="category/java/errorprone.xml/ClassCastExceptionWithToArray" />
<rule ref="category/java/errorprone.xml/DontUseFloatTypeForLoopIndices" />
<rule ref="category/java/errorprone.xml/EmptyCatchBlock" />
<rule ref="category/java/errorprone.xml/JumbledIncrementer" />
<rule ref="category/java/errorprone.xml/MisplacedNullCheck" />
<rule ref="category/java/errorprone.xml/OverrideBothEqualsAndHashcode" />
<rule ref="category/java/errorprone.xml/ReturnFromFinallyBlock" />
<rule ref="category/java/errorprone.xml/UnconditionalIfStatement" />
<rule ref="category/java/errorprone.xml/UnnecessaryConversionTemporary" />
<rule ref="category/java/errorprone.xml/UnusedNullCheckInEquals" />
<rule ref="category/java/errorprone.xml/UselessOperationOnImmutable" />

<rule ref="category/java/multithreading.xml/AvoidThreadGroup" />
<rule ref="category/java/multithreading.xml/DontCallThreadRun" />
<rule ref="category/java/multithreading.xml/DoubleCheckedLocking" />

<rule ref="category/java/performance.xml/BigIntegerInstantiation" />

</ruleset>
Loading

0 comments on commit 130f808

Please sign in to comment.