From bc45bb932d85064fc99f8b515d3c21a877567b51 Mon Sep 17 00:00:00 2001 From: Piotr PG Gajek Date: Fri, 4 Sep 2026 12:03:32 +0200 Subject: [PATCH 1/4] Fix UnusedLocalVariable PMD issues --- force-app/main/default/classes/AsyncTest.cls | 20 ++++--------------- .../default/classes/queue/QueueableJob.cls | 3 ++- website/installation.md | 8 ++++++++ 3 files changed, 14 insertions(+), 17 deletions(-) create mode 100644 website/installation.md diff --git a/force-app/main/default/classes/AsyncTest.cls b/force-app/main/default/classes/AsyncTest.cls index 555fcf1..35f429d 100644 --- a/force-app/main/default/classes/AsyncTest.cls +++ b/force-app/main/default/classes/AsyncTest.cls @@ -3178,14 +3178,8 @@ private class AsyncTest implements Database.Batchable { @IsTest private static void shouldDeleteOnlyOldNonFailedResultsWhenOnlyOthersRetentionIsSet() { - AsyncResult__c oldCompleted = insertAsyncResultWithAge( - QueueableManager.STATUS_COMPLETED, - 31 - ); - AsyncResult__c oldSkipped = insertAsyncResultWithAge( - QueueableManager.STATUS_SKIPPED_DEPENDENCY, - 31 - ); + insertAsyncResultWithAge(QueueableManager.STATUS_COMPLETED, 31); + insertAsyncResultWithAge(QueueableManager.STATUS_SKIPPED_DEPENDENCY, 31); AsyncResult__c veryOldFailed = insertAsyncResultWithAge( QueueableManager.STATUS_FAILED, 400 @@ -3214,18 +3208,12 @@ private class AsyncTest implements Database.Batchable { @IsTest private static void shouldApplySeparateRetentionCutoffsPerTrack() { - AsyncResult__c failedPastCutoff = insertAsyncResultWithAge( - QueueableManager.STATUS_FAILED, - 100 - ); + insertAsyncResultWithAge(QueueableManager.STATUS_FAILED, 100); AsyncResult__c failedWithinCutoff = insertAsyncResultWithAge( QueueableManager.STATUS_FAILED, 60 ); - AsyncResult__c completedPastCutoff = insertAsyncResultWithAge( - QueueableManager.STATUS_COMPLETED, - 60 - ); + insertAsyncResultWithAge(QueueableManager.STATUS_COMPLETED, 60); AsyncResult__c completedWithinCutoff = insertAsyncResultWithAge( QueueableManager.STATUS_COMPLETED, 10 diff --git a/force-app/main/default/classes/queue/QueueableJob.cls b/force-app/main/default/classes/queue/QueueableJob.cls index aac91dd..6eafe08 100644 --- a/force-app/main/default/classes/queue/QueueableJob.cls +++ b/force-app/main/default/classes/queue/QueueableJob.cls @@ -226,7 +226,8 @@ public abstract class QueueableJob implements Queueable, Comparable { private String getFullClassName(Object job) { String result; try { - DateTime typeCheck = (DateTime) job; + // A failed cast is the only way to read the runtime type with its namespace + String.valueOf((DateTime) job); } catch (System.TypeException expectedTypeException) { String message = expectedTypeException.getMessage() .substringAfter('Invalid conversion from runtime type '); diff --git a/website/installation.md b/website/installation.md new file mode 100644 index 0000000..721df85 --- /dev/null +++ b/website/installation.md @@ -0,0 +1,8 @@ +# Installation + +## Copy and Deploy + +**Apex** + +- [`DML.cls`](https://github.com/beyond-the-cloud-dev/dml-lib/blob/main/force-app/main/default/classes/DML.cls) +- [`DML_Test.cls`](https://github.com/beyond-the-cloud-dev/dml-lib/blob/main/force-app/main/default/classes/DML_Test.cls) \ No newline at end of file From 12e692a26a19dd3c902bc6ff4a4cba3433e1d4b7 Mon Sep 17 00:00:00 2001 From: Piotr PG Gajek Date: Fri, 4 Sep 2026 12:05:15 +0200 Subject: [PATCH 2/4] Revert installation --- website/installation.md | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 website/installation.md diff --git a/website/installation.md b/website/installation.md deleted file mode 100644 index 721df85..0000000 --- a/website/installation.md +++ /dev/null @@ -1,8 +0,0 @@ -# Installation - -## Copy and Deploy - -**Apex** - -- [`DML.cls`](https://github.com/beyond-the-cloud-dev/dml-lib/blob/main/force-app/main/default/classes/DML.cls) -- [`DML_Test.cls`](https://github.com/beyond-the-cloud-dev/dml-lib/blob/main/force-app/main/default/classes/DML_Test.cls) \ No newline at end of file From ea523b35ae0d41b3e0d7e1a59a4d7c28427e57bf Mon Sep 17 00:00:00 2001 From: Piotr PG Gajek Date: Fri, 4 Sep 2026 12:08:37 +0200 Subject: [PATCH 3/4] PMD Issues --- force-app/main/default/classes/AsyncTest.cls | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/force-app/main/default/classes/AsyncTest.cls b/force-app/main/default/classes/AsyncTest.cls index 35f429d..971e79b 100644 --- a/force-app/main/default/classes/AsyncTest.cls +++ b/force-app/main/default/classes/AsyncTest.cls @@ -2,8 +2,12 @@ * PMD False Positives: * - ApexAssertionsShouldIncludeMessage: IMO not all assertions need a message * - EmptyStatementBlock: It is test class, some methods are just to create jobs placeholders + * - NcssTypeCount: It is a library and all of its tests live in ONE test class + * - NcssCount: It is a library and all of its tests live in ONE test class **/ -@SuppressWarnings('PMD.ApexAssertionsShouldIncludeMessage,PMD.EmptyStatementBlock') +@SuppressWarnings( + 'PMD.ApexAssertionsShouldIncludeMessage,PMD.EmptyStatementBlock,PMD.NcssTypeCount,PMD.NcssCount' +) @IsTest @TestVisible private class AsyncTest implements Database.Batchable { @@ -4048,7 +4052,7 @@ private class AsyncTest implements Database.Batchable { @IsTest private static void shouldInjectQueueableMockIntoAChunkPage() { List accounts = createAccounts(2); - Id mockJobId = '707000000000001AAA'; + Id mockJobId = AsyncApexJob.SObjectType.getDescribe().getKeyPrefix() + '000000000001AAA'; AsyncMock.whenQueueable('chunk-page') .thenReturn(new AsyncMock.MockQueueableContext().setJobId(mockJobId)); From 4f5aa3350497874d1bce0a392bbe31b2f6fc400c Mon Sep 17 00:00:00 2001 From: Piotr PG Gajek Date: Fri, 4 Sep 2026 12:15:14 +0200 Subject: [PATCH 4/4] PMD Issue Fix --- force-app/main/default/classes/AsyncTest.cls | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/force-app/main/default/classes/AsyncTest.cls b/force-app/main/default/classes/AsyncTest.cls index 971e79b..b284028 100644 --- a/force-app/main/default/classes/AsyncTest.cls +++ b/force-app/main/default/classes/AsyncTest.cls @@ -4052,7 +4052,7 @@ private class AsyncTest implements Database.Batchable { @IsTest private static void shouldInjectQueueableMockIntoAChunkPage() { List accounts = createAccounts(2); - Id mockJobId = AsyncApexJob.SObjectType.getDescribe().getKeyPrefix() + '000000000001AAA'; + Id mockJobId = fakeId(AsyncApexJob.SObjectType, 1); AsyncMock.whenQueueable('chunk-page') .thenReturn(new AsyncMock.MockQueueableContext().setJobId(mockJobId)); @@ -4661,6 +4661,12 @@ private class AsyncTest implements Database.Batchable { return accounts; } + private static Id fakeId(Schema.SObjectType sObjectType, Integer index) { + String prefix = sObjectType.getDescribe(SObjectDescribeOptions.DEFERRED).getKeyPrefix(); + String suffix = String.valueOf(index); + return Id.valueOf(prefix + '0'.repeat(15 - prefix.length() - suffix.length()) + suffix); + } + private static List accountsWithOneFailingRecord() { List accounts = new List{ new Account(Name = 'ok first'),