Skip to content

Commit efc87ea

Browse files
authored
Merge pull request #1024 from forcedotcom/rm/updateUIMsg_OutOfMemory
CHANGE (GraphEngine): @W-12672520@: Applies UI text feedback
2 parents 7a914c6 + a9ada0f commit efc87ea

File tree

17 files changed

+74
-53
lines changed

17 files changed

+74
-53
lines changed

messages/run-dfa.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sfge/src/main/java/com/salesforce/Main.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ int process(String... args) {
8585
}
8686
if (args.length == 0) {
8787
// No args means we can't do anything productive.
88-
dependencies.printError(UserFacingMessages.REQUIRES_AT_LEAST_ONE_ARGUMENT);
88+
dependencies.printError(
89+
UserFacingMessages.InvocationErrors.REQUIRES_AT_LEAST_ONE_ARGUMENT);
8990
return EXIT_WITH_INTERNAL_ERROR_NO_VIOLATIONS;
9091
}
9192

@@ -222,7 +223,7 @@ private String formatError(Throwable error) {
222223
return ERROR_PREFIX
223224
+ (error.getCause() != null
224225
? String.format(
225-
UserFacingMessages.EXCEPTION_FORMAT_TEMPLATE,
226+
UserFacingMessages.CompilationErrors.EXCEPTION_FORMAT_TEMPLATE,
226227
error.getMessage(),
227228
error.getCause().getMessage())
228229
: error.getMessage());

sfge/src/main/java/com/salesforce/apex/jorje/JorjeUtil.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ public static AstNodeWrapper<?> compileApexFromString(String sourceCode) {
8787
.map(
8888
e ->
8989
String.format(
90-
UserFacingMessages.INVALID_SYNTAX_TEMPLATE,
90+
UserFacingMessages.CompilationErrors
91+
.INVALID_SYNTAX_TEMPLATE,
9192
e.getLoc().getLine(),
9293
e.getLoc().getColumn(),
9394
e.getError()))

sfge/src/main/java/com/salesforce/cli/CliArgParser.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ public CLI_ACTION getCliAction(String... args) {
3737
return CLI_ACTION.CATALOG;
3838
} else {
3939
throw new InvocationException(
40-
String.format(UserFacingMessages.UNRECOGNIZED_ACTION, actionArg));
40+
String.format(
41+
UserFacingMessages.InvocationErrors.UNRECOGNIZED_ACTION, actionArg));
4142
}
4243
}
4344

@@ -120,7 +121,7 @@ public void parseArgs(String... args) {
120121
if (args.length != ARG_COUNT) {
121122
throw new InvocationException(
122123
String.format(
123-
UserFacingMessages.INCORRECT_ARGUMENT_COUNT,
124+
UserFacingMessages.InvocationErrors.INCORRECT_ARGUMENT_COUNT,
124125
ARG_COUNT,
125126
args.length));
126127
}

sfge/src/main/java/com/salesforce/config/UserFacingMessages.java

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -25,46 +25,50 @@ public static final class RuleViolationTemplates {
2525
// Second %s is the name of a class or interface.
2626
public static final String UNIMPLEMENTED_TYPE_RULE = "Extend, implement, or delete %s %s";
2727
public static final String LIMIT_REACHED_VIOLATION_MESSAGE =
28-
"%s. The analysis preemptively stopped running on this path to prevent an OutOfMemory error. Rerun Graph Engine targeting this entry method with a larger heap space.";
28+
"%s. The analysis preemptively stopped running on this path to prevent an OutOfMemory error. Rerun Graph Engine and target this entry method with a larger heap space.";
2929
}
3030

3131
/** Main args and process checks * */
32-
public static final String REQUIRES_AT_LEAST_ONE_ARGUMENT =
33-
"SFGE invocation requires at least one argument.";
34-
35-
public static final String UNRECOGNIZED_ACTION = "Unrecognized action to invoke SFGE: %s.";
36-
public static final String INCORRECT_ARGUMENT_COUNT =
37-
"Wrong number of arguments. Expected %d; received %d";
32+
public static final class InvocationErrors {
33+
public static final String REQUIRES_AT_LEAST_ONE_ARGUMENT =
34+
"SFGE invocation requires at least one argument.";
35+
public static final String UNRECOGNIZED_ACTION = "Unrecognized action to invoke SFGE: %s.";
36+
public static final String INCORRECT_ARGUMENT_COUNT =
37+
"Wrong number of arguments. Expected %d; received %d";
38+
}
3839

3940
/** UserActionException * */
41+
public static final class UserActionMessage {
42+
// format: filename,defined type, line number
43+
public static final String UNREACHABLE_CODE =
44+
"Remove unreachable code to proceed with the analysis: %s,%s:%d";
45+
public static final String VARIABLE_DECLARED_MULTIPLE_TIMES =
46+
"Rename or delete this reused variable to proceed with the analysis: %s,%s:%d";
47+
}
4048

41-
// format: filename,defined type, line number
42-
public static final String UNREACHABLE_CODE =
43-
"Remove unreachable code to proceed with the analysis: %s,%s:%d";
44-
45-
public static final String VARIABLE_DECLARED_MULTIPLE_TIMES =
46-
"This variable is reused. Rename or delete it to proceed with the analysis: %s,%s:%d";
47-
48-
public static final String INSUFFICIENT_HEAP_SPACE =
49-
"There's insufficient heap space (%d bytes) to execute Graph Engine. Increase heap space using --sfgejvmargs option and retry.";
50-
51-
public static final String STRIP_INACCESSIBLE_READ_WARNING_TEMPLATE =
52-
"For stripInaccessible checks on READ operation, Salesforce Graph Engine can't verify that only sanitized data is used after the check. Discard unsanitized data for [%2$s].";
53-
54-
public static final String UNRESOLVED_CRUD_FLS_TEMPLATE =
55-
"Salesforce Graph Engine couldn't resolve the parameter passed to [%2$s] operation%4$s. Confirm that this operation has the necessary %1$s checks.";
56-
57-
public static final String FIELDS_MESSAGE_TEMPLATE = " with field(s) [%s]";
58-
public static final String FIELD_HANDLING_NOTICE =
59-
". Confirm that the objects and fields involved in these segments have FLS checks: [%s]";
49+
public static final class PathExpansionTemplates {
50+
public static final String INSUFFICIENT_HEAP_SPACE =
51+
"There's insufficient heap space (%d bytes) to execute Graph Engine. Increase heap space using the --sfgejvmargs option and retry.";
52+
public static final String PATH_EXPANSION_LIMIT_REACHED =
53+
"Graph Engine reached the path expansion upper limit (%d).";
54+
}
6055

61-
public static final String INVALID_SYNTAX_TEMPLATE = "Invalid syntax at %d:%d. (%s)";
56+
public static final class CrudFlsTemplates {
6257

63-
public static final String FIX_COMPILATION_ERRORS =
64-
"Graph engine encountered compilation errors. Fix the errors in %s and retry.";
58+
public static final String STRIP_INACCESSIBLE_READ_WARNING_TEMPLATE =
59+
"For stripInaccessible checks on READ operation, Salesforce Graph Engine can't verify that only sanitized data is used after the check. Discard unsanitized data for [%2$s].";
60+
public static final String UNRESOLVED_CRUD_FLS_TEMPLATE =
61+
"Salesforce Graph Engine couldn't resolve the parameter passed to [%2$s] operation%4$s. Confirm that this operation has the necessary %1$s checks.";
62+
public static final String FIELDS_MESSAGE_TEMPLATE = " with field(s) [%s]";
63+
public static final String FIELD_HANDLING_NOTICE =
64+
". Confirm that the objects and fields involved in these segments have FLS checks: [%s]";
65+
}
6566

66-
public static final String EXCEPTION_FORMAT_TEMPLATE = "%s, Caused by:\n%s";
67+
public static final class CompilationErrors {
6768

68-
public static final String PATH_EXPANSION_LIMIT_REACHED =
69-
"Graph Engine reached the path expansion upper limit (%d).";
69+
public static final String INVALID_SYNTAX_TEMPLATE = "Invalid syntax at %d:%d. (%s)";
70+
public static final String FIX_COMPILATION_ERRORS =
71+
"Graph engine encountered compilation errors. Fix the errors in %s and retry.";
72+
public static final String EXCEPTION_FORMAT_TEMPLATE = "%s, Caused by:\n%s";
73+
}
7074
}

sfge/src/main/java/com/salesforce/graph/build/MethodPathBuilderVisitor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ private void addEdge(String name, Vertex from, Vertex to) {
597597
// Ask user to fix unreachable code
598598
throw new UserActionException(
599599
String.format(
600-
UserFacingMessages.UNREACHABLE_CODE,
600+
UserFacingMessages.UserActionMessage.UNREACHABLE_CODE,
601601
GremlinUtil.getFileName(g, to),
602602
to.value(Schema.DEFINING_TYPE),
603603
to.value(Schema.BEGIN_LINE)));

sfge/src/main/java/com/salesforce/graph/ops/GraphUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ private static List<Util.CompilationDescriptor> buildFolderComps(String sourceFo
182182
} catch (JorjeUtil.JorjeCompilationException ex) {
183183
throw new GraphLoadException(
184184
String.format(
185-
UserFacingMessages.FIX_COMPILATION_ERRORS,
185+
UserFacingMessages.CompilationErrors.FIX_COMPILATION_ERRORS,
186186
sourceFileVisitor.lastVisitedFile),
187187
ex);
188188
}

sfge/src/main/java/com/salesforce/graph/ops/registry/PathExpansionLimitReachedException.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
*/
1010
public class PathExpansionLimitReachedException extends SfgeRuntimeException {
1111
public PathExpansionLimitReachedException(int limit) {
12-
super(String.format(UserFacingMessages.PATH_EXPANSION_LIMIT_REACHED, limit));
12+
super(
13+
String.format(
14+
UserFacingMessages.PathExpansionTemplates.PATH_EXPANSION_LIMIT_REACHED,
15+
limit));
1316
}
1417
}

sfge/src/main/java/com/salesforce/graph/ops/registry/RegistryDataLimitCalculator.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ int calculateAllowedLimit(long averageItemSize, int minimumItemCountExpected) {
4343

4444
if (heapMaxSize < minimumItemCountExpected * averageItemSize) {
4545
throw new UserActionException(
46-
String.format(UserFacingMessages.INSUFFICIENT_HEAP_SPACE, heapMaxSize));
46+
String.format(
47+
UserFacingMessages.PathExpansionTemplates.INSUFFICIENT_HEAP_SPACE,
48+
heapMaxSize));
4749
}
4850

4951
final int allowedLimit = (int) ((heapMaxSize * CAPACITY_LIMIT) / averageItemSize);

sfge/src/main/java/com/salesforce/graph/symbols/PathScopeVisitor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1593,7 +1593,7 @@ public boolean visit(VariableDeclarationVertex vertex) {
15931593
if (apexValueStack.peek().containsKey(key)) {
15941594
// The variable was defined multiple times
15951595
throw new UserActionException(
1596-
UserFacingMessages.VARIABLE_DECLARED_MULTIPLE_TIMES,
1596+
UserFacingMessages.UserActionMessage.VARIABLE_DECLARED_MULTIPLE_TIMES,
15971597
vertex.getFileName(),
15981598
vertex.getDefiningType(),
15991599
vertex.getBeginLine());

0 commit comments

Comments
 (0)