From 159de923a2edff76dd5d99d6f56f1ef134a390e0 Mon Sep 17 00:00:00 2001 From: Manditha Madushanka Athukorala <152949293+Manditha77@users.noreply.github.com> Date: Mon, 21 Sep 2026 20:28:18 +0530 Subject: [PATCH 1/5] test write access --- PPCH_TEST.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 PPCH_TEST.md diff --git a/PPCH_TEST.md b/PPCH_TEST.md new file mode 100644 index 0000000000..b6fc4c620b --- /dev/null +++ b/PPCH_TEST.md @@ -0,0 +1 @@ +hello \ No newline at end of file From 2efe22aa375d5e1244d4062de82b2678d6dd2054 Mon Sep 17 00:00:00 2001 From: Manditha Madushanka Athukorala <152949293+Manditha77@users.noreply.github.com> Date: Mon, 21 Sep 2026 20:28:34 +0530 Subject: [PATCH 2/5] remove write-access test file --- PPCH_TEST.md | 1 - 1 file changed, 1 deletion(-) delete mode 100644 PPCH_TEST.md diff --git a/PPCH_TEST.md b/PPCH_TEST.md deleted file mode 100644 index b6fc4c620b..0000000000 --- a/PPCH_TEST.md +++ /dev/null @@ -1 +0,0 @@ -hello \ No newline at end of file From de48214f3106fbd7efb6c358b838141cfd9095ce Mon Sep 17 00:00:00 2001 From: Manditha Madushanka Athukorala <152949293+Manditha77@users.noreply.github.com> Date: Mon, 21 Sep 2026 22:51:09 +0530 Subject: [PATCH 3/5] Add PPCH Cognitive Complexity Guard workflow --- .github/workflows/ppch-guard.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .github/workflows/ppch-guard.yml diff --git a/.github/workflows/ppch-guard.yml b/.github/workflows/ppch-guard.yml new file mode 100644 index 0000000000..5518faeb47 --- /dev/null +++ b/.github/workflows/ppch-guard.yml @@ -0,0 +1,15 @@ +name: PPCH Cognitive Complexity Guard + +on: + pull_request: + types: [opened, synchronize, reopened] + +jobs: + ppch-guard: + runs-on: self-hosted + steps: + - uses: Manditha77/ppch-framework@main + with: + post-comment: "true" + sonar-token: ${{ secrets.SONAR_TOKEN }} + sonar-host-url: "http://localhost:9000" From 260c233539e52be9ffbbdc96f1a2d489b699f8ec Mon Sep 17 00:00:00 2001 From: Manditha Madushanka Athukorala <152949293+Manditha77@users.noreply.github.com> Date: Mon, 21 Sep 2026 23:21:48 +0530 Subject: [PATCH 4/5] Grant pull-requests: write so the guard can post its comment --- .github/workflows/ppch-guard.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ppch-guard.yml b/.github/workflows/ppch-guard.yml index 5518faeb47..0fface0d26 100644 --- a/.github/workflows/ppch-guard.yml +++ b/.github/workflows/ppch-guard.yml @@ -7,6 +7,9 @@ on: jobs: ppch-guard: runs-on: self-hosted + permissions: + pull-requests: write + contents: read steps: - uses: Manditha77/ppch-framework@main with: From de9f5ffee2a90f9d4f62332decc04f7d6258080e Mon Sep 17 00:00:00 2001 From: Manditha77 Date: Tue, 22 Sep 2026 02:39:30 +0530 Subject: [PATCH 5/5] Add transaction and customer classification utilities Adds ComplexityTestUtil with classifyTransaction and scoreCustomer, used to validate cognitive-complexity handling for risk-scoring logic across international, flagged, and tiered-customer scenarios. --- .../text/similarity/ComplexityTestUtil.java | 135 ++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 src/main/java/org/apache/commons/text/similarity/ComplexityTestUtil.java diff --git a/src/main/java/org/apache/commons/text/similarity/ComplexityTestUtil.java b/src/main/java/org/apache/commons/text/similarity/ComplexityTestUtil.java new file mode 100644 index 0000000000..7ae07ad560 --- /dev/null +++ b/src/main/java/org/apache/commons/text/similarity/ComplexityTestUtil.java @@ -0,0 +1,135 @@ +package org.apache.commons.text.similarity; + +/** + * PPCH-framework test addition: a deliberately over-complex method used only + * to exercise a live cognitive-complexity-guard test on this fork. Not + * intended for upstream apache/commons-text. + */ +public final class ComplexityTestUtil { + + private ComplexityTestUtil() { + } + + public static String classifyTransaction(int amount, String currency, boolean isInternational, + boolean isFlagged, int riskScore, String region, boolean isNewCustomer, int previousFailures) { + String result; + if (amount <= 0) { + result = "invalid"; + } else { + if (isFlagged) { + if (riskScore > 80) { + result = "blocked"; + } else if (riskScore > 50) { + if (isNewCustomer) { + result = "manual_review"; + } else { + if (previousFailures > 2) { + result = "manual_review"; + } else { + result = "approved_with_delay"; + } + } + } else { + result = "approved"; + } + } else { + if (isInternational) { + if (region.equals("HIGH_RISK")) { + if (amount > 10000) { + result = "blocked"; + } else if (amount > 5000) { + if (isNewCustomer && previousFailures > 0) { + result = "manual_review"; + } else { + result = "approved_with_delay"; + } + } else { + result = "approved"; + } + } else if (region.equals("MEDIUM_RISK")) { + if (amount > 20000) { + result = "manual_review"; + } else { + result = "approved"; + } + } else { + result = "approved"; + } + } else { + if (currency.equals("USD") || currency.equals("EUR")) { + if (amount > 50000) { + result = "manual_review"; + for (int i = 0; i < previousFailures; i++) { + if (i > 3) { + result = "blocked"; + break; + } + } + } else { + result = "approved"; + } + } else { + if (isNewCustomer) { + result = "manual_review"; + } else { + result = "approved"; + } + } + } + } + } + return result; + } + + public static int scoreCustomer(int age, int accountAgeMonths, int loginCount, boolean hasVerifiedEmail, + boolean hasVerifiedPhone, int failedLogins, String tier) { + int score = 0; + if (age < 18) { + score -= 50; + } else if (age < 25) { + score -= 10; + } else { + score += 5; + } + + if (accountAgeMonths > 24) { + score += 20; + } else if (accountAgeMonths > 12) { + score += 10; + } else if (accountAgeMonths > 1) { + if (loginCount > 50) { + score += 5; + } else { + score -= 5; + } + } else { + score -= 15; + } + + if (hasVerifiedEmail && hasVerifiedPhone) { + score += 15; + } else if (hasVerifiedEmail || hasVerifiedPhone) { + score += 5; + } else { + score -= 20; + } + + if (failedLogins > 10) { + score -= 30; + } else if (failedLogins > 5) { + score -= 15; + } else if (failedLogins > 2) { + score -= 5; + } + + if ("PLATINUM".equals(tier)) { + score += 25; + } else if ("GOLD".equals(tier)) { + score += 15; + } else if ("SILVER".equals(tier)) { + score += 5; + } + + return score; + } +} \ No newline at end of file