Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/add pmd check to project #83

Merged
merged 10 commits into from
Nov 19, 2024
Merged
38 changes: 35 additions & 3 deletions .github/workflows/develop.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ jobs:
java-version: 17
architecture: x64
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 @@ -61,12 +60,14 @@ 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') }}
restore-keys: ${{ runner.os }}-m2



- name: Set up Maven settings.xml
run: |
mkdir -p ~/.m2
Expand All @@ -83,6 +84,37 @@ jobs:
- name: Run Unit and Integration Tests
run: mvn verify -s ~/.m2/settings.xml -Dmaven.javadoc.skip=true


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:
runs-on: ubuntu-latest
needs: build # Ensures that the security scan runs only if the build job succeeds
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
157 changes: 157 additions & 0 deletions online-banking-app/qa/pmd/pmd-ruleset.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
<?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 xs2a project
nancymuyeh marked this conversation as resolved.
Show resolved Hide resolved
</description>

<rule ref="category/java/bestpractices.xml/AvoidUsingHardCodedIP" />
<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/UnusedImports" />
<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/UseAssertEqualsInsteadOfAssertTrue" />
<rule ref="category/java/bestpractices.xml/UseAssertNullInsteadOfAssertTrue" />
<rule ref="category/java/bestpractices.xml/UseAssertSameInsteadOfAssertTrue" />
<rule ref="category/java/bestpractices.xml/UseAssertTrueInsteadOfAssertEquals" />
<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/DontImportJavaLang" />
<rule ref="category/java/codestyle.xml/DuplicateImports" />
<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/SuspiciousConstantFieldName" />
<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/ExcessiveClassLength" />
<rule ref="category/java/design.xml/ExcessiveMethodLength" />
<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/SimplifyBooleanAssertion" />
<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/EmptyFinallyBlock" />
<rule ref="category/java/errorprone.xml/EmptyIfStmt" />
<rule ref="category/java/errorprone.xml/EmptyInitializer" />
<rule ref="category/java/errorprone.xml/EmptyStatementBlock" />
<rule ref="category/java/errorprone.xml/EmptyStatementNotInLoop" />
<rule ref="category/java/errorprone.xml/EmptySwitchStatements" />
<rule ref="category/java/errorprone.xml/EmptySynchronizedBlock" />
<rule ref="category/java/errorprone.xml/EmptyTryBlock" />
<rule ref="category/java/errorprone.xml/EmptyWhileStmt" />
<rule ref="category/java/errorprone.xml/ImportFromSamePackage" />
<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" />
<rule ref="category/java/performance.xml/BooleanInstantiation" />
<rule ref="rulesets/java/junit.xml">
<exclude name = "JUnitAssertionsShouldIncludeMessage"/>
<exclude name = "JUnitTestContainsTooManyAsserts"/>
<exclude name = "JUnitTestsShouldIncludeAssert"/>
</rule>
</ruleset>
nancymuyeh marked this conversation as resolved.
Show resolved Hide resolved
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>francis.pouatcha@adorsys.com</email>
<organization>adorsys GmbH &amp; Co KG</organization>
<organizationUrl>https://adorsys.de/</organizationUrl>
</developer>
<developer>
<name>Nancy Muyeh</name>
<email>nancy.muyeh@adorsys.com</email>
<organization>adorsys GmbH &amp; Co KG</organization>
<organizationUrl>https://adorsys.de/</organizationUrl>
</developer>
<developer>
<name>Chia Hans Ful</name>
<email>hans.chia@adorsys.com</email>
<organization>adorsys GmbH &amp; Co KG</organization>
<organizationUrl>https://adorsys.de/</organizationUrl>
</developer>
<developer>
<name>Nkwa Jude Tambe</name>
<email>jude.nkwa@adorsys.com</email>
<organization>adorsys GmbH &amp; Co KG</organization>
<organizationUrl>https://adorsys.de/</organizationUrl>
</developer>
<developer>
<name>Ariel Tchikaya</name>
<email>ariel.tchikaya@adorsys.com</email>
<organization>adorsys GmbH &amp; Co KG</organization>
<organizationUrl>https://adorsys.de/</organizationUrl>
</developer>
<developer>
<name>
Koufan De Koufan Menkene</name>
<email>menkene.koufan@adorsys.com</email>
<organization>adorsys GmbH &amp; Co KG</organization>
<organizationUrl>https://adorsys.de/</organizationUrl>
</developer>
<developer>
<name>Yvan Henang </name>
<email>yvan.henang@skyengpro.com</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>
Loading
Loading