Skip to content

Commit d866ce7

Browse files
committed
prettier Apex classes
1 parent 75d86c2 commit d866ce7

32 files changed

+257
-614
lines changed

.prettierrc

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,81 @@
11
{
2-
"plugins": ["prettier-plugin-apex"],
2+
"arrowParens": "avoid",
3+
"bracketSpacing": true,
4+
"bracketSameLine": true,
5+
"printWidth": 100,
6+
"semi": true,
7+
"singleQuote": true,
38
"trailingComma": "none",
9+
"endOfLine": "lf",
10+
"apexInsertFinalNewline": false,
411
"useTabs": true,
512
"overrides": [
613
{
714
"files": "**/lwc/**/*.html",
815
"options": { "parser": "lwc" }
916
},
17+
{
18+
"files": "*.{cls,trigger}",
19+
"options": { "parser": "apex", "tabWidth": 2, "useTabs": true }
20+
},
21+
{
22+
"files": "*.trigger",
23+
"options": { "printWidth": 200 }
24+
},
1025
{
1126
"files": "*.{cmp,page,component}",
12-
"options": { "parser": "html" }
27+
"options": {
28+
"parser": "html",
29+
"useTabs": true,
30+
"htmlWhitespaceSensitivity": "css"
31+
}
32+
},
33+
{
34+
"files": "*.{apex,soql}",
35+
"options": { "parser": "apex-anonymous" }
36+
},
37+
{
38+
"files": "*.{yml,yaml}",
39+
"options": { "parser": "yaml", "tabWidth": 2, "useTabs": false }
40+
},
41+
{
42+
"files": ".prettier*",
43+
"options": { "parser": "json", "printWidth": 80, "useTabs": true }
44+
},
45+
{
46+
"files": "*.xml",
47+
"options": {
48+
"parser": "xml",
49+
"useTabs": true,
50+
"singleQuote": false,
51+
"xmlSelfClosingSpace": true
52+
}
53+
},
54+
{
55+
"files": ["**/pmd/*.xml", "*ruleset*.xml", "config/**/*.xml"],
56+
"options": {
57+
"parser": "xml",
58+
"xmlSelfClosingSpace": true,
59+
"xmlWhitespaceSensitivity": "ignore"
60+
}
61+
},
62+
{
63+
"files": "*meta.xml",
64+
"options": {
65+
"parser": "xml",
66+
"useTabs": false,
67+
"xmlSelfClosingSpace": false
68+
}
69+
},
70+
{
71+
"files": "*.json",
72+
"options": {
73+
"parser": "json-stringify",
74+
"useTabs": false,
75+
"tabWidth": 2
76+
}
1377
}
14-
]
78+
],
79+
"plugins": ["prettier-plugin-apex", "@prettier/plugin-xml"],
80+
"$schema": "https://json.schemastore.org/prettierrc"
1581
}

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
},
1212
"devDependencies": {
1313
"@prettier/plugin-xml": "^3.4.1",
14-
"eslint": "^9.22.0",
15-
"eslint-config-prettier": "^10.1.1",
1614
"husky": "^9.1.7",
1715
"lint-staged": "^15.5.0",
1816
"prettier": "3.5.3",

trigger-actions-framework/main/default/classes/FinalizerHandler.cls

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,7 @@ public with sharing virtual class FinalizerHandler {
121121
* @param finalizerMetadata The metadata of the finalizer to execute.
122122
* @param context The context to pass to the finalizer's `execute` method.
123123
*/
124-
private void callReferencedFinalizer(
125-
DML_Finalizer__mdt finalizerMetadata,
126-
Context context
127-
) {
124+
private void callReferencedFinalizer(DML_Finalizer__mdt finalizerMetadata, Context context) {
128125
Object dynamicInstance;
129126
String className = finalizerMetadata.Apex_Class_Name__c;
130127
if (FinalizerHandler.isBypassed(className)) {
@@ -166,9 +163,7 @@ public with sharing virtual class FinalizerHandler {
166163
}
167164

168165
private void handleFinalizerException(String errorFormat, String className) {
169-
throw new FinalizerException(
170-
String.format(errorFormat, new List<String>{ className })
171-
);
166+
throw new FinalizerException(String.format(errorFormat, new List<String>{ className }));
172167
}
173168

174169
/**
@@ -178,10 +173,7 @@ public with sharing virtual class FinalizerHandler {
178173
* @param requiredPermission The required permission for the finalizer.
179174
* @return True if bypassed, false otherwise.
180175
*/
181-
private boolean isBypassed(
182-
String bypassPermission,
183-
String requiredPermission
184-
) {
176+
private boolean isBypassed(String bypassPermission, String requiredPermission) {
185177
return (bypassPermission != null && permissionMap.get(bypassPermission)) ||
186178
(requiredPermission != null && !permissionMap.get(requiredPermission));
187179
}
@@ -192,10 +184,7 @@ public with sharing virtual class FinalizerHandler {
192184
*/
193185
private void populatePermissionMap(String permissionName) {
194186
if (permissionName != null && !permissionMap.containsKey(permissionName)) {
195-
permissionMap.put(
196-
permissionName,
197-
FeatureManagement.checkPermission(permissionName)
198-
);
187+
permissionMap.put(permissionName, FeatureManagement.checkPermission(permissionName));
199188
}
200189
}
201190

@@ -231,8 +220,7 @@ public with sharing virtual class FinalizerHandler {
231220
* equal to, or greater than the specified object.
232221
*/
233222
public Integer compareTo(Object other) {
234-
Decimal difference = (this.metadata.Order__c -
235-
((FinalizerSorter) other).metadata.Order__c);
223+
Decimal difference = (this.metadata.Order__c - ((FinalizerSorter) other).metadata.Order__c);
236224
return difference < 0 ? -1 : difference == 0 ? 0 : 1;
237225
}
238226
}
@@ -249,4 +237,4 @@ public with sharing virtual class FinalizerHandler {
249237
*/
250238
private class FinalizerException extends Exception {
251239
}
252-
}
240+
}

trigger-actions-framework/main/default/classes/FinalizerHandlerTest.cls

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,7 @@ private with sharing class FinalizerHandlerTest {
9494
@IsTest
9595
private static void staticallyBypassedFinalizerShouldNotExecute() {
9696
handler.allFinalizers = new List<DML_Finalizer__mdt>{
97-
new DML_Finalizer__mdt(
98-
Apex_Class_Name__c = TEST_FOO_FINALIZER,
99-
Order__c = 1
100-
)
97+
new DML_Finalizer__mdt(Apex_Class_Name__c = TEST_FOO_FINALIZER, Order__c = 1)
10198
};
10299

103100
FinalizerHandler.bypass(TEST_FOO_FINALIZER);
@@ -150,14 +147,8 @@ private with sharing class FinalizerHandlerTest {
150147
@IsTest
151148
private static void finalizersShouldExecuteInOrder() {
152149
handler.allFinalizers = new List<DML_Finalizer__mdt>{
153-
new DML_Finalizer__mdt(
154-
Apex_Class_Name__c = TEST_FOO_FINALIZER,
155-
Order__c = 1
156-
),
157-
new DML_Finalizer__mdt(
158-
Apex_Class_Name__c = TEST_BAR_FINALIZER,
159-
Order__c = 2
160-
)
150+
new DML_Finalizer__mdt(Apex_Class_Name__c = TEST_FOO_FINALIZER, Order__c = 1),
151+
new DML_Finalizer__mdt(Apex_Class_Name__c = TEST_BAR_FINALIZER, Order__c = 2)
161152
};
162153

163154
handler.handleDynamicFinalizers();
@@ -213,10 +204,7 @@ private with sharing class FinalizerHandlerTest {
213204
System.Assert.isNotNull(myException, EXCEPTION_SHOULD_BE_THROWN);
214205

215206
System.Assert.areEqual(
216-
String.format(
217-
FinalizerHandler.INVALID_TYPE_ERROR_FINALIZER,
218-
new List<String>{ MY_CLASS }
219-
),
207+
String.format(FinalizerHandler.INVALID_TYPE_ERROR_FINALIZER, new List<String>{ MY_CLASS }),
220208
myException.getMessage(),
221209
EXCEPTION_SHOULD_HAVE_CORRECT_MESSAGE
222210
);
@@ -307,4 +295,4 @@ private with sharing class FinalizerHandlerTest {
307295
Database.setSavepoint();
308296
}
309297
}
310-
}
298+
}

trigger-actions-framework/main/default/classes/FlowChangeEventHeader.cls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,4 @@ public with sharing class FlowChangeEventHeader {
113113
public Integer hashCode() {
114114
return JSON.serialize(this).hashCode();
115115
}
116-
}
116+
}

trigger-actions-framework/main/default/classes/FlowChangeEventHeaderTest.cls

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ private with sharing class FlowChangeEventHeaderTest {
2323

2424
@IsTest
2525
private static void shouldBeAbleToConstruct() {
26-
System.Assert.isNotNull(
27-
header,
28-
'Unable to construct a FlowChangeEventHeader'
29-
);
26+
System.Assert.isNotNull(header, 'Unable to construct a FlowChangeEventHeader');
3027
}
3128

3229
@IsTest
@@ -36,9 +33,7 @@ private with sharing class FlowChangeEventHeaderTest {
3633

3734
@IsTest
3835
private static void shouldBeAbleToCompare() {
39-
FlowChangeEventHeader other = new FlowChangeEventHeader(
40-
new EventBus.ChangeEventHeader()
41-
);
36+
FlowChangeEventHeader other = new FlowChangeEventHeader(new EventBus.ChangeEventHeader());
4237
other.changeType = 'CREATE';
4338

4439
System.Assert.areEqual(
@@ -57,4 +52,4 @@ private with sharing class FlowChangeEventHeaderTest {
5752
'Unable to detect difference between FlowChangeEventHeader and null'
5853
);
5954
}
60-
}
55+
}

trigger-actions-framework/main/default/classes/FormulaFilter.cls

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ global class FormulaFilter {
2323
private static final String ERROR_PREFIX = 'Please check the `SObject_Trigger_Setting__mdt` metadata for the the {0} sObject.';
2424
@TestVisible
2525
private static final String MISSING_CLASS_NAME =
26-
ERROR_PREFIX +
27-
' The record is missing the `TriggerRecord_Class_Name__c` field.';
26+
ERROR_PREFIX + ' The record is missing the `TriggerRecord_Class_Name__c` field.';
2827
@TestVisible
2928
private static final String INVALID_CLASS =
3029
ERROR_PREFIX +
@@ -74,18 +73,14 @@ global class FormulaFilter {
7473
List<SObject> triggerOld
7574
) {
7675
FormulaFilter.Result result = new FormulaFilter.Result();
77-
String entryCriteriaFormula = this.triggerActionConfiguration
78-
?.Entry_Criteria__c;
76+
String entryCriteriaFormula = this.triggerActionConfiguration?.Entry_Criteria__c;
7977

8078
if (String.isBlank(entryCriteriaFormula)) {
8179
result.triggerNew = triggerNew;
8280
result.triggerOld = triggerOld;
8381
return result;
8482
}
85-
String nameOfType = getNameOfType(
86-
this.triggerActionConfiguration,
87-
this.context
88-
);
83+
String nameOfType = getNameOfType(this.triggerActionConfiguration, this.context);
8984
System.Type triggerRecordSubType = getType(nameOfType);
9085
FormulaEval.FormulaInstance fx = getFormulaInstance(
9186
triggerRecordSubType,
@@ -97,10 +92,7 @@ global class FormulaFilter {
9792
for (Integer i = 0; i < size; i++) {
9893
SObject record = triggerNew?.get(i);
9994
SObject recordPrior = triggerOld?.get(i);
100-
TriggerRecord toProcess = getTriggerRecord(
101-
triggerRecordSubType,
102-
nameOfType
103-
);
95+
TriggerRecord toProcess = getTriggerRecord(triggerRecordSubType, nameOfType);
10496
toProcess.newSobject = record;
10597
toProcess.oldSobject = recordPrior;
10698
if ((Boolean) fx.evaluate(toProcess)) {
@@ -120,28 +112,19 @@ global class FormulaFilter {
120112
System.Type response = System.Type.forName(className);
121113
if (response == null) {
122114
throw new IllegalArgumentException(
123-
String.format(
124-
INVALID_CLASS,
125-
new List<String>{ this.sObjectName, className }
126-
)
115+
String.format(INVALID_CLASS, new List<String>{ this.sObjectName, className })
127116
);
128117
}
129118
return response;
130119
}
131120

132-
private TriggerRecord getTriggerRecord(
133-
System.Type triggerRecordSubType,
134-
String nameOfType
135-
) {
121+
private TriggerRecord getTriggerRecord(System.Type triggerRecordSubType, String nameOfType) {
136122
TriggerRecord dynamicInstance;
137123
try {
138124
dynamicInstance = (TriggerRecord) triggerRecordSubType.newInstance();
139125
} catch (System.TypeException e) {
140126
throw new IllegalArgumentException(
141-
String.format(
142-
INVALID_SUBTYPE,
143-
new List<String>{ this.sObjectName, nameOfType }
144-
)
127+
String.format(INVALID_SUBTYPE, new List<String>{ this.sObjectName, nameOfType })
145128
);
146129
}
147130
return dynamicInstance;
@@ -204,4 +187,4 @@ global class FormulaFilter {
204187
this.triggerOld = new List<SObject>();
205188
}
206189
}
207-
}
190+
}

0 commit comments

Comments
 (0)