Skip to content

Commit

Permalink
v1.6.19 - Updates Extra Code Coverage Plugin (#574)
Browse files Browse the repository at this point in the history
* Removes some goofy test-based workarounds for System.OrgLimits not being previously available during packaging workflows thanks to @jongpie

* Adding Task/Event/User wiki post to README

* Updates Extra Code Coverage plugin which fixes #573 

* Updates sfdx-scanner

* Updating pipeline to use the preview version of PMD 7
  • Loading branch information
jamessimone authored Mar 12, 2024
1 parent 01f5654 commit c814f75
Show file tree
Hide file tree
Showing 15 changed files with 16,717 additions and 363 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ Read below for more on how you can use Apex Rollup in your day-to-day. Please no
- [Rollup Control custom metadata configuration](https://youtu.be/vUP_uBB2m-k)
- [Unit testing Apex Rollup](https://youtu.be/u7ly5xGMfFM)

As well, don't miss [the Wiki](../../wiki), which includes even more info for common topics.
As well, don't miss [the Wiki](../../wiki), which includes even more info for common topics like [setting up Task/Event/User rollups](../../wiki/Creating-Task-User-Event-Based-Rollups).

## Deployment & Setup

<a href="https://login.salesforce.com/packaging/installPackage.apexp?p0=04t6g000008Oak1AAC">
<a href="https://login.salesforce.com/packaging/installPackage.apexp?p0=04t6g000008Oal4AAC">
<img alt="Deploy to Salesforce"
src="./media/deploy-package-to-prod.png">
</a>

<a href="https://test.salesforce.com/packaging/installPackage.apexp?p0=04t6g000008Oak1AAC">
<a href="https://test.salesforce.com/packaging/installPackage.apexp?p0=04t6g000008Oal4AAC">
<img alt="Deploy to Salesforce Sandbox"
src="./media/deploy-package-to-sandbox.png">
</a>
Expand Down
3 changes: 2 additions & 1 deletion extra-tests/classes/RollupTests.cls
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@SuppressWarnings('PMD.NcssTypeCount')
@IsTest
private class RollupTests {
static Rollup.Op testOp;
Expand Down Expand Up @@ -3035,7 +3036,7 @@ private class RollupTests {
);
Rollup.apexContext = TriggerOperation.AFTER_INSERT;
// one over the default limit
RollupLimits.orgAsyncJobsUsed = 250001;
RollupLimits.currentAsyncJobsUsed = 250001;

// specifically no Test.startTest()/Test.stopTest() to prove it's been run sync
Rollup.sumFromApex(ContactPointAddress.PreferenceRank, ContactPointAddress.ParentId, Account.Id, Account.AnnualRevenue, Account.SObjectType).runCalc();
Expand Down
16,995 changes: 16,675 additions & 320 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apex-rollup",
"version": "1.6.18",
"version": "1.6.19",
"description": "Fast, configurable, elastically scaling custom rollup solution. Apex Invocable action, one-liner Apex trigger/CMDT-driven logic, and scheduled Apex-ready.",
"repository": {
"type": "git",
Expand All @@ -19,7 +19,7 @@
"@salesforce/eslint-config-lwc": "3.5.2",
"@salesforce/eslint-plugin-lightning": "1.0.0",
"@salesforce/sfdx-lwc-jest": "3.1.1",
"@salesforce/sfdx-scanner": "^3.21.0",
"@salesforce/sfdx-scanner": "^3.22.0",
"eslint": "*",
"eslint-config-prettier": "9.1.0",
"husky": "8.0.3",
Expand Down Expand Up @@ -47,12 +47,12 @@
"create:package:code-coverage": "pwsh -Command \"&{ . ./scripts/generatePackage.ps1; Generate -PackageName '\"Apex Rollup - Extra Code Coverage\"' -ReadmePath \"./plugins/ExtraCodeCoverage/README.md\" }\"",
"get:project:json": "pwsh -Command \"&{ . ./scripts/generatePackage.ps1; Update-SFDX-Project-JSON }\"",
"husky:pre-commit": "lint-staged",
"lint:verify": "sfdx scanner:run --target **/lwc/**/*.js,!node_modules/** --engine eslint-lwc --severity-threshold 3 --eslintconfig .eslintrc.json",
"prepare": "husky install && sfdx plugins:link ./node_modules/@salesforce/sfdx-scanner && sfdx plugins:link ./node_modules/@jongpie/sfdx-bummer-plugin",
"lint:verify": "sf scanner run --target **/lwc/**/*.js,!node_modules/** --engine eslint-lwc --severity-threshold 3 --eslintconfig .eslintrc.json",
"prepare": "husky install && sf plugins link ./node_modules/@salesforce/sfdx-scanner && sf plugins link ./node_modules/@jongpie/sfdx-bummer-plugin",
"prettier": "prettier",
"scan": "npm run lint:verify && npm run scan:pmd",
"scan:pmd": "sfdx scanner:run --pmdconfig config/pmd-ruleset.xml --target .,!plugins/ExtraCodeCoverage/** --engine pmd --severity-threshold 3",
"scan:graph": "sfdx scanner:run -e sfge -p . --target 'rollup'",
"scan:pmd": "sf scanner run --pmdconfig config/pmd-ruleset.xml --target .,!plugins/ExtraCodeCoverage/** --engine pmd --severity-threshold 3 --preview-pmd7",
"scan:graph": "sf scanner run -e sfge -p . --target 'rollup'",
"test": "npm run test:apex && npm run test:lwc",
"test:apex": "sh ./scripts/runLocalTests.sh",
"test:lwc": "sfdx-lwc-jest --coverage --skipApiVersionCheck"
Expand Down
4 changes: 2 additions & 2 deletions plugins/ExtraCodeCoverage/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Extra Code Coverage

<a href="https://login.salesforce.com/packaging/installPackage.apexp?p0=04t6g000008C78yAAC">
<a href="https://login.salesforce.com/packaging/installPackage.apexp?p0=04t6g000008OakpAAC">
<img alt="Deploy to Salesforce"
src="../../media/deploy-package-to-prod.png">
</a>

<a href="https://test.salesforce.com/packaging/installPackage.apexp?p0=04t6g000008C78yAAC">
<a href="https://test.salesforce.com/packaging/installPackage.apexp?p0=04t6g000008OakpAAC">
<img alt="Deploy to Salesforce Sandbox"
src="../../media/deploy-package-to-sandbox.png">
</a>
Expand Down
4 changes: 2 additions & 2 deletions rollup-namespaced/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ For more info, see the base `README`.

## Deployment & Setup

<a href="https://login.salesforce.com/packaging/installPackage.apexp?p0=04t6g000008Oak6AAC">
<a href="https://login.salesforce.com/packaging/installPackage.apexp?p0=04t6g000008Oal9AAC">
<img alt="Deploy to Salesforce"
src="./media/deploy-package-to-prod.png">
</a>

<a href="https://test.salesforce.com/packaging/installPackage.apexp?p0=04t6g000008Oak6AAC">
<a href="https://test.salesforce.com/packaging/installPackage.apexp?p0=04t6g000008Oal9AAC">
<img alt="Deploy to Salesforce Sandbox"
src="./media/deploy-package-to-sandbox.png">
</a>
2 changes: 1 addition & 1 deletion rollup-namespaced/sfdx-project.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
"apex-rollup-namespaced@1.1.13": "04t6g000008OaYwAAK",
"apex-rollup-namespaced@1.1.14": "04t6g000008OaZBAA0",
"apex-rollup-namespaced@1.1.16": "04t6g000008OaZaAAK",
"apex-rollup-namespaced@1.1.17": "04t6g000008Oak6AAC"
"apex-rollup-namespaced@1.1.17": "04t6g000008Oal9AAC"
}
}
1 change: 1 addition & 0 deletions rollup/core/classes/Rollup.cls
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@SuppressWarnings('PMD.NcssTypeCount')
global without sharing virtual class Rollup implements RollupLogger.ToStringObject {
/**
* Test override / bookkeeping section. Normally I would do this through dependency injection,
Expand Down
1 change: 1 addition & 0 deletions rollup/core/classes/RollupAsyncProcessor.cls
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@SuppressWarnings('PMD.NcssTypeCount')
global virtual without sharing class RollupAsyncProcessor extends Rollup implements Database.Batchable<SObject>, Database.RaisesPlatformEvents, System.Comparable {
private final Evaluator eval;
private final Op op;
Expand Down
1 change: 1 addition & 0 deletions rollup/core/classes/RollupCalculator.cls
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@SuppressWarnings('PMD.NcssTypeCount')
public without sharing abstract class RollupCalculator {
private Boolean isCDCUpdate = false;
private Boolean isFirstTimeThrough = true;
Expand Down
1 change: 1 addition & 0 deletions rollup/core/classes/RollupEvaluator.cls
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@SuppressWarnings('PMD.NcssTypeCount')
public without sharing abstract class RollupEvaluator implements Rollup.Evaluator, RollupLogger.ToStringObject {
private static final String RELATIONSHIP_FIELD_DELIMITER = '\\.';
private static final String TRUE_VAL = 'true';
Expand Down
15 changes: 6 additions & 9 deletions rollup/core/classes/RollupLimits.cls
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ public without sharing class RollupLimits {
@TestVisible
private static Integer stubbedQueryRows;
@TestVisible
private static Integer orgAsyncJobsUsed;
private static Integer currentAsyncJobsUsed;
@TestVisible
private static Integer stubAsyncTimeoutInterval;

Expand All @@ -22,18 +22,15 @@ public without sharing class RollupLimits {

private static final Boolean HAS_EXCEEDED_ORG_ASYNC_JOB_LIMIT {
get {
Integer countOfJobsUsed = 0;
Integer asyncJobLimit = 250000;
// at the moment, packaging orgs run tests synchronously, which produces an error when fetching System.OrgLimits.getMap()
// this is a workaround until it's safe to access OrgLimits from a synchronously running test
if (HAS_EXCEEDED_ORG_ASYNC_JOB_LIMIT == null && orgAsyncJobsUsed == null) {
System.OrgLimit asyncLimit = System.OrgLimits.getMap().get('DailyAsyncApexExecutions');
asyncJobLimit = asyncLimit.getLimit();
countOfJobsUsed = asyncLimit.getValue();
} else if (HAS_EXCEEDED_ORG_ASYNC_JOB_LIMIT == null) {
countOfJobsUsed = orgAsyncJobsUsed;
if (HAS_EXCEEDED_ORG_ASYNC_JOB_LIMIT == null) {
System.OrgLimit asyncOrgLimit = System.OrgLimits.getMap().get('DailyAsyncApexExecutions');
asyncJobLimit = asyncOrgLimit.getLimit();
Integer countOfJobsUsed = currentAsyncJobsUsed != null ? currentAsyncJobsUsed : asyncOrgLimit.getValue();
HAS_EXCEEDED_ORG_ASYNC_JOB_LIMIT = countOfJobsUsed - asyncJobLimit > 0;
}
HAS_EXCEEDED_ORG_ASYNC_JOB_LIMIT = countOfJobsUsed - asyncJobLimit > 0;
return HAS_EXCEEDED_ORG_ASYNC_JOB_LIMIT;
}
set;
Expand Down
2 changes: 1 addition & 1 deletion rollup/core/classes/RollupLogger.cls
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
global without sharing virtual class RollupLogger implements ILogger {
@TestVisible
// this gets updated via the pipeline as the version number gets incremented
private static final String CURRENT_VERSION_NUMBER = 'v1.6.18';
private static final String CURRENT_VERSION_NUMBER = 'v1.6.19';
private static final System.LoggingLevel FALLBACK_LOGGING_LEVEL = System.LoggingLevel.DEBUG;
private static final RollupPlugin PLUGIN = new RollupPlugin();

Expand Down
17 changes: 8 additions & 9 deletions rollup/core/classes/RollupRelationshipFieldFinder.cls
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
* Big caveat here - this class can only be used with lookup relationships. The larger Rollup framework
* accepts and even welcomes text-based keys being used, but here we accept that text-based keys
* are likely niche, anyway, and that people looking to make use of a grandchild -> grandparent (or greater!)
* rollup are likely operating using lookups anyway
* rollup are likely operating using lookups
*/
@SuppressWarnings('PMD.NcssTypeCount')
public without sharing class RollupRelationshipFieldFinder {
private final Rollup__mdt metadata;
private final List<String> originalParts;
Expand Down Expand Up @@ -616,9 +617,7 @@ public without sharing class RollupRelationshipFieldFinder {
this.uniqueChildrenFieldNames.add(relationshipPath + '.Id');
List<SObject> additionalCalcItems = this.getAdditionalCalcItems(
this.traversal.lookupIdMap.keySet(),
relationshipPath +
'.' +
this.metadata.LookupFieldOnLookupObject__c
relationshipPath + '.' + this.metadata.LookupFieldOnLookupObject__c
);

List<String> recurseChainOriginal = relationshipPath.split('\\.');
Expand Down Expand Up @@ -646,11 +645,11 @@ public without sharing class RollupRelationshipFieldFinder {
try {
List<SObject> additionalCalcItems = this.repo.setQuery(
RollupQueryBuilder.Current.getAllRowSafeQuery(
childType,
RollupQueryBuilder.Current.getQuery(childType, new List<String>(queryFields), relationshipPath, '=', this.metadata.CalcItemWhereClause__c)
) +
'\nAND Id != :' +
bindVar
childType,
RollupQueryBuilder.Current.getQuery(childType, new List<String>(queryFields), relationshipPath, '=', this.metadata.CalcItemWhereClause__c)
) +
'\nAND Id != :' +
bindVar
)
.setArg(inclusiveIds)
.setArg(bindVar, this.records)
Expand Down
16 changes: 7 additions & 9 deletions sfdx-project.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"package": "apex-rollup",
"path": "rollup",
"scopeProfiles": true,
"versionName": "More accurate counts when adding up relevant children/parents prior to going async. More accurate REFRESH calculations for rollups to multiple parents",
"versionNumber": "1.6.18.0",
"versionName": "More accurate checking of org async limits while testing",
"versionNumber": "1.6.19.0",
"versionDescription": "Fast, configurable, elastically scaling custom rollup solution. Apex Invocable action, one-liner Apex trigger/CMDT-driven logic, and scheduled Apex-ready.",
"releaseNotesUrl": "https://github.com/jamessimone/apex-rollup/releases/latest",
"unpackagedMetadata": {
Expand Down Expand Up @@ -71,9 +71,10 @@
"versionName": "Updating code coverage",
"versionNumber": "0.0.20.0",
"default": false,
"scopeProfiles": true,
"dependencies": [
{
"package": "apex-rollup@1.6.0-0"
"package": "apex-rollup@1.6.19"
}
]
},
Expand All @@ -90,8 +91,8 @@
"Apex Rollup - Custom Logger@0.0.11-0": "04t6g000008SirvAAC",
"Apex Rollup - Custom Logger@0.0.12-0": "04t6g000008SjqIAAS",
"Apex Rollup - Extra Code Coverage": "0Ho6g000000GnCWCA0",
"Apex Rollup - Extra Code Coverage@0.0.19-0": "04t6g000008C6rRAAS",
"Apex Rollup - Extra Code Coverage@0.0.20-0": "04t6g000008C78yAAC",
"Apex Rollup - Extra Code Coverage@0.0.21": "04t6g000008OakpAAC",
"Apex Rollup - Nebula Logger": "0Ho6g000000Gn8PCAS",
"Apex Rollup - Nebula Logger@0.0.7-0": "04t6g000008b0O7AAI",
"Apex Rollup - Nebula Logger@0.0.8-0": "04t6g000007zM6tAAE",
Expand All @@ -100,10 +101,7 @@
"Apex Rollup - Rollup Callback@0.0.3-0": "04t6g000008Sis0AAC",
"Nebula Logger - Core@4.8.0-NEXT-ignore-origin-method": "04t5Y0000015lslQAA",
"apex-rollup": "0Ho6g000000TNcOCAW",
"apex-rollup@1.6.14": "04t6g000008OaYrAAK",
"apex-rollup@1.6.15": "04t6g000008OaZQAA0",
"apex-rollup@1.6.16": "04t6g000008OaZVAA0",
"apex-rollup@1.6.17": "04t6g000008OafFAAS",
"apex-rollup@1.6.18": "04t6g000008Oak1AAC"
"apex-rollup@1.6.18": "04t6g000008Oak1AAC",
"apex-rollup@1.6.19": "04t6g000008Oal4AAC"
}
}

0 comments on commit c814f75

Please sign in to comment.