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

Feat/implement pmd check #40

Merged
merged 7 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion .github/workflows/develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,39 @@ jobs:
run: echo "The Quality Gate status is ${{ steps.sonarqube-quality-gate-check.outputs.quality-gate-status }}"


# Automatically Deploy artifacts to github packages

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 -Ddependency-check.skip=true

- name: Check pmd
run: mvn -ntp pmd:check -Ddependency-check.skip=true



# Automatically Deploy artifacts to github packages

# publish:
# name: Deploy Artifacts
Expand Down
87 changes: 84 additions & 3 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

package de.adorsys.webank.bank.api.utils;

@SuppressWarnings("PMD")

public abstract class Constants {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ public ResponseEntity<List<AccountBalanceTO>> getBalances(String accountId) {

@Override
public ResponseEntity<List<TransactionTO>> getTransactionByDates(String accountId, LocalDateTime dateFrom, LocalDateTime dateTo) {
// dateChecker(dateFrom, dateTo);
// List<TransactionTO> transactions = bankAccountService.getTransactionsByDates(accountId, validDate(dateFrom), validDate(dateTo));
// return ResponseEntity.ok(transactions);
dateChecker(dateFrom, dateTo);

return null;
}

Expand All @@ -71,6 +70,7 @@ public ResponseEntity<TransactionTO> getTransactionById(String accountId, String
private void dateChecker(LocalDateTime dateFrom, LocalDateTime dateTo) {
if (!validDate(dateFrom).isEqual(validDate(dateTo))
&& validDate(dateFrom).isAfter(validDate(dateTo))) {
throw new IllegalArgumentException("Invalid date range: 'date from' cannot be after 'date to'");
// throw MiddlewareModuleException.builder()
// .errorCode(REQUEST_VALIDATION_FAILURE)
// .devMsg("Illegal request dates sequence, possibly swapped 'date from' with 'date to'")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import de.adorsys.ledgers.postings.api.domain.LedgerBO;
import de.adorsys.ledgers.postings.api.service.LedgerService;
import lombok.RequiredArgsConstructor;

@SuppressWarnings("PMD")
@RequiredArgsConstructor
public abstract class AbstractServiceImpl {
protected final BankAccountConfigService bankAccountConfigService;
Expand Down
Loading
Loading