Skip to content

Commit

Permalink
Merge pull request #83 from ADORSYS-GIS/chore/add-pmd-check-to-project
Browse files Browse the repository at this point in the history
Chore/add pmd check to project
  • Loading branch information
nancymuyeh authored Nov 19, 2024
2 parents be7df5c + 7bec007 commit bbafba9
Show file tree
Hide file tree
Showing 6 changed files with 269 additions and 5 deletions.
37 changes: 35 additions & 2 deletions .github/workflows/develop.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
java-version: '17'
distribution: 'temurin'
- name: Cache Maven packages
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
Expand Down Expand Up @@ -60,12 +60,14 @@ jobs:
distribution: 'temurin'

- name: Cache Maven packages
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2



- name: Set up Maven settings.xml
run: |
mkdir -p ~/.m2
Expand All @@ -85,6 +87,37 @@ jobs:




pmdCheck:
needs: build
name: Run code analyser PMD
runs-on: ubuntu-latest
steps:
- name: Clone webank online banking repository
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
architecture: x64
distribution: 'temurin'
- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2



- name: build project before check
run: mvn -ntp -DskipTests -DskipITs -Dmaven.javadoc.skip=true clean install

- name: Check pmd
run: mvn -ntp pmd:check


security-scan:
name: Owasp security scan
runs-on: ubuntu-latest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ public String registerAccount(RegistrationRequest registrationRequest) {
return "Error creating account for phone number: " + registrationRequest.getPhoneNumber();
}
} catch (Exception e) {
System.err.println("Exception occurred during account registration: " + e);
return "An error occurred while processing the request: " + e.getMessage();
}
}
Expand Down
1 change: 1 addition & 0 deletions online-banking-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<properties>
<java.version>17</java.version>
<spring-cloud.version>2023.0.3</spring-cloud.version>
<ruleset.basedir>../</ruleset.basedir>
</properties>
<dependencies>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.adorsys.webank.Config;
package com.adorsys.webank.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand Down
98 changes: 97 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,66 @@
<module>online-banking-app</module>
</modules>

<name>Webank</name>
<description>OpenSource Implementation Of Online banking Functionalities</description>

<url></url>

<licenses>
<license>
<name>The Apache License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>

<developers>
<developer>
<name>Francis Pouatcha</name>
<email>[email protected]</email>
<organization>adorsys GmbH &amp; Co KG</organization>
<organizationUrl>https://adorsys.de/</organizationUrl>
</developer>
<developer>
<name>Nancy Muyeh</name>
<email>[email protected]</email>
<organization>adorsys GmbH &amp; Co KG</organization>
<organizationUrl>https://adorsys.de/</organizationUrl>
</developer>
<developer>
<name>Chia Hans Ful</name>
<email>[email protected]</email>
<organization>adorsys GmbH &amp; Co KG</organization>
<organizationUrl>https://adorsys.de/</organizationUrl>
</developer>
<developer>
<name>Nkwa Jude Tambe</name>
<email>[email protected]</email>
<organization>adorsys GmbH &amp; Co KG</organization>
<organizationUrl>https://adorsys.de/</organizationUrl>
</developer>
<developer>
<name>Ariel Tchikaya</name>
<email>[email protected]</email>
<organization>adorsys GmbH &amp; Co KG</organization>
<organizationUrl>https://adorsys.de/</organizationUrl>
</developer>
<developer>
<name>
Koufan De Koufan Menkene</name>
<email>[email protected]</email>
<organization>adorsys GmbH &amp; Co KG</organization>
<organizationUrl>https://adorsys.de/</organizationUrl>
</developer>
<developer>
<name>Yvan Henang </name>
<email>[email protected]</email>
<organization>SKY ENGINEERING PROFESSIONAL Sarl</organization>
<organizationUrl>https://skyengpro.de/</organizationUrl>
</developer>

</developers>



<properties>
<!-- Common properties -->
Expand Down Expand Up @@ -449,7 +509,43 @@
<!-- <failBuildOnCVSS>5</failBuildOnCVSS>-->
<!-- </configuration>-->
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>${maven-pmd-plugin.version}</version>
<configuration>
<minimumTokens>100</minimumTokens>
<targetJdk>${java.version}</targetJdk>
<analysisCache>true</analysisCache>
<linkXRef>false</linkXRef>
<rulesets>
<ruleset>${ruleset.basedir}/qa/pmd/pmd-ruleset.xml</ruleset>
</rulesets>
<includeTests>true</includeTests>
<failOnViolation>true</failOnViolation>
<printFailingErrors>true</printFailingErrors>
<excludes>
<exclude>**/*MapperImpl.java</exclude>
</excludes>
<excludeRoots>
<excludeRoot>../ledgers-deposit-account-service-impl/target/generated-sources/annotations/
</excludeRoot>
<excludeRoot>../ledgers-middleware-rest-server/target/generated-sources/annotations/
</excludeRoot>
<excludeRoot>../ledgers-middleware-service-impl/target/generated-sources/annotations/
</excludeRoot>
<excludeRoot>../ledgers-postings-service-impl/target/generated-sources/annotations/
</excludeRoot>
<excludeRoot>../ledgers-sca-service-impl/target/generated-sources/annotations/
</excludeRoot>
<excludeRoot>../ledgers-user-management-service-impl/target/generated-sources/annotations/
</excludeRoot>
</excludeRoots>
</configuration>
</plugin>

</plugins>
</build>

</project>
135 changes: 135 additions & 0 deletions qa/pmd/pmd-ruleset.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<?xml version="1.0"?>
<!--
~ Copyright (c) 2018-2024 adorsys GmbH and Co. KG
~ All rights are reserved.
-->

<ruleset name="whizbang 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>
This ruleset defines the PMD rules for webank-online-banking project
</description>
<rule ref="category/java/bestpractices.xml/AvoidUsingHardCodedIP" />
<rule ref="category/java/bestpractices.xml/AbstractClassWithoutAbstractMethod" />
<rule ref="category/java/bestpractices.xml/ArrayIsStoredDirectly" />
<rule ref="category/java/bestpractices.xml/AvoidReassigningLoopVariables" />
<rule ref="category/java/bestpractices.xml/AvoidReassigningLoopVariables" />
<rule ref="category/java/bestpractices.xml/AvoidPrintStackTrace" />
<rule ref="category/java/bestpractices.xml/AvoidReassigningParameters" />
<rule ref="category/java/bestpractices.xml/CheckResultSet" />
<rule ref="category/java/bestpractices.xml/DefaultLabelNotLastInSwitchStmt" />
<rule ref="category/java/bestpractices.xml/JUnit4SuitesShouldUseSuiteAnnotation" />
<rule ref="category/java/bestpractices.xml/JUnit4TestShouldUseAfterAnnotation" />
<rule ref="category/java/bestpractices.xml/JUnit4TestShouldUseBeforeAnnotation" />
<rule ref="category/java/bestpractices.xml/JUnit4TestShouldUseTestAnnotation" />
<rule ref="category/java/bestpractices.xml/LooseCoupling" />
<rule ref="category/java/bestpractices.xml/MethodReturnsInternalArray" />
<rule ref="category/java/bestpractices.xml/MissingOverride" />
<rule ref="category/java/bestpractices.xml/OneDeclarationPerLine" />
<rule ref="category/java/bestpractices.xml/ReplaceEnumerationWithIterator" />
<rule ref="category/java/bestpractices.xml/ReplaceHashtableWithMap" />
<rule ref="category/java/bestpractices.xml/ReplaceVectorWithList" />
<rule ref="category/java/bestpractices.xml/SwitchStmtsShouldHaveDefault" />
<rule ref="category/java/bestpractices.xml/SystemPrintln" />
<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/bestpractices.xml/UseCollectionIsEmpty" />
<rule ref="category/java/bestpractices.xml/UseVarargs" />

<rule ref="category/java/codestyle.xml/AvoidDollarSigns" />
<rule ref="category/java/codestyle.xml/AvoidProtectedFieldInFinalClass" />
<rule ref="category/java/codestyle.xml/AvoidUsingNativeCode" />
<rule ref="category/java/codestyle.xml/BooleanGetMethodName" />
<rule ref="category/java/codestyle.xml/ControlStatementBraces" />
<rule ref="category/java/codestyle.xml/EmptyMethodInAbstractClassShouldBeAbstract" />
<rule ref="category/java/codestyle.xml/ExtendsObject" />
<rule ref="category/java/codestyle.xml/FieldDeclarationsShouldBeAtStartOfClass" />
<rule ref="category/java/codestyle.xml/ForLoopShouldBeWhileLoop" />
<rule ref="category/java/codestyle.xml/IdenticalCatchBranches" />
<rule ref="category/java/codestyle.xml/LongVariable">
<properties>
<property name="minimum" value="50"/>
</properties>
</rule>
<rule ref="category/java/codestyle.xml/NoPackage" />
<rule ref="category/java/codestyle.xml/PackageCase" />
<rule ref="category/java/codestyle.xml/PrematureDeclaration" />
<rule ref="category/java/codestyle.xml/ShortClassName" >
<properties>
<property name="minimum" value="3"/>
</properties>
</rule>
<rule ref="category/java/codestyle.xml/ShortMethodName" >
<properties>
<property name="minimum" value="4"/>
</properties>
</rule>
<rule ref="category/java/codestyle.xml/UnnecessaryFullyQualifiedName" />
<rule ref="category/java/codestyle.xml/UnnecessaryLocalBeforeReturn" />
<rule ref="category/java/codestyle.xml/UnnecessaryModifier" />
<rule ref="category/java/codestyle.xml/UnnecessaryReturn" />
<rule ref="category/java/codestyle.xml/UselessParentheses" />
<rule ref="category/java/codestyle.xml/UselessQualifiedThis" />

<rule ref="category/java/design.xml/AvoidDeeplyNestedIfStmts" >
<properties>
<property name="problemDepth" value="4"/>
</properties>
</rule>
<rule ref="category/java/design.xml/AvoidRethrowingException" />
<rule ref="category/java/design.xml/AvoidThrowingNewInstanceOfSameException" />
<rule ref="category/java/design.xml/AvoidThrowingNullPointerException" />
<rule ref="category/java/design.xml/AvoidThrowingRawExceptionTypes" />
<rule ref="category/java/design.xml/CollapsibleIfStatements" />
<rule ref="category/java/design.xml/CouplingBetweenObjects" />
<rule ref="category/java/design.xml/CyclomaticComplexity"/>
<rule ref="category/java/design.xml/GodClass" />
<rule ref="category/java/design.xml/DoNotExtendJavaLangError" />
<rule ref="category/java/design.xml/ExceptionAsFlowControl" />
<rule ref="category/java/design.xml/ExcessivePublicCount" />
<rule ref="category/java/design.xml/FinalFieldCouldBeStatic" />
<rule ref="category/java/design.xml/NPathComplexity" />
<rule ref="category/java/design.xml/SignatureDeclareThrowsException" />
<rule ref="category/java/design.xml/SimplifiedTernary" />
<rule ref="category/java/design.xml/SimplifyBooleanExpressions" />
<rule ref="category/java/design.xml/SimplifyBooleanReturns" />
<rule ref="category/java/design.xml/SingularField" />
<rule ref="category/java/design.xml/SwitchDensity" />
<rule ref="category/java/design.xml/TooManyMethods" >
<properties>
<property name="maxmethods" value="20"/>
</properties>
</rule>
<rule ref="category/java/design.xml/UselessOverridingMethod" />

<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/EmptyIfStmt" />
<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>

0 comments on commit bbafba9

Please sign in to comment.