Skip to content

Commit 6875a57

Browse files
authored
Merge pull request #801 from forcedotcom/dev-3
@W-11606553@: Release activity for 3.4.0
2 parents 0c46d16 + 32ac240 commit 6875a57

File tree

78 files changed

+2600
-651
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+2600
-651
lines changed

cli-messaging/src/main/java/com/salesforce/messaging/CliMessager.java

Lines changed: 51 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.util.Arrays;
55
import java.util.List;
66

7+
import com.google.common.collect.Lists;
78
import com.google.gson.Gson;
89

910
public class CliMessager {
@@ -12,8 +13,17 @@ public class CliMessager {
1213
// The END string lets us know when a message stops, which should prevent bugs involving multi-line output.
1314
private static final String END = "SFDX-END";
1415

16+
private static final String REALTIME_START = "SFCA-REALTIME-START";
17+
private static final String REALTIME_END = "SFCA-REALTIME-END";
18+
19+
/* Deprecated: Don't maintain state in a class that's essentially used as a utility.*/
20+
@Deprecated
1521
private static final List<Message> MESSAGES = new ArrayList<>();
1622

23+
/**
24+
* Deprecated - switch to static invocation of {@link #postMessage(String, EventKey, String...)}
25+
*/
26+
@Deprecated
1727
public static CliMessager getInstance() {
1828
return LazyHolder.INSTANCE;
1929
}
@@ -26,6 +36,7 @@ public static CliMessager getInstance() {
2636
*
2737
* @param exception to send to Typescript layer
2838
*/
39+
@Deprecated
2940
public void addMessage(MessagePassableException exception) {
3041
final EventKey eventKey = exception.getEventKey();
3142
addMessage(
@@ -43,34 +54,59 @@ public void addMessage(MessagePassableException exception) {
4354
* @param eventKey EventKey to display to user
4455
* @param args String args passed to the EventKey to make the displayed message meaningful
4556
*/
57+
@Deprecated
4658
public void addMessage(String internalLog, EventKey eventKey, String... args) {
47-
// Developer error if eventKey was not added to exception and we'll get a bunch of NPEs
48-
assert (eventKey != null);
49-
// Confirm that the correct number of arguments for the message has been provided
50-
// If this fails, this would be a developer error
51-
assert (eventKey.getArgCount() == args.length);
52-
53-
final Message message = new Message(
54-
eventKey.getMessageKey(),
55-
Arrays.asList(args),
56-
internalLog,
57-
eventKey.getMessageType(),
58-
eventKey.getMessageHandler(),
59-
eventKey.isVerbose());
60-
MESSAGES.add(message);
59+
final Message message = createMessage(internalLog, eventKey, args);
60+
MESSAGES.add(message);
6161
}
6262

63-
/**
63+
/**
64+
* Publish formatted stdout message to pass onto Typescript layer.
65+
* Make sure EventKey is updated with messages/EventKeyTemplates.json
66+
* and has correct properties in the enum.
67+
*
68+
* @param internalLog Information for internal use. Will be logged but not displayed to user
69+
* @param eventKey EventKey to display to user
70+
* @param args String args passed to the EventKey to make the displayed message meaningful
71+
*/
72+
public static void postMessage(String internalLog, EventKey eventKey, String... args) {
73+
final Message message = createMessage(internalLog, eventKey, args);
74+
final List<Message> messages = Lists.newArrayList(message);
75+
76+
final String messageAsJson = new Gson().toJson(messages);
77+
System.out.println(REALTIME_START + messageAsJson + REALTIME_END);
78+
}
79+
80+
private static Message createMessage(String internalLog, EventKey eventKey, String[] args) {
81+
// Developer error if eventKey was not added to exception and we'll get a bunch of NPEs
82+
assert (eventKey != null);
83+
// Confirm that the correct number of arguments for the message has been provided
84+
// If this fails, this would be a developer error
85+
assert (eventKey.getArgCount() == args.length);
86+
87+
final Message message = new Message(
88+
eventKey.getMessageKey(),
89+
Arrays.asList(args),
90+
internalLog,
91+
eventKey.getMessageType(),
92+
eventKey.getMessageHandler(),
93+
eventKey.isVerbose());
94+
return message;
95+
}
96+
97+
/**
6498
* Convert all messages stored by the instance into a JSON-formatted string, enclosed in the start and end strings.
6599
* Java code can use this method to log the messages to console, and TypeScript code can seek the start and stop
66100
* strings to get an array of messages that can be deserialized.
67101
* @return
68102
*/
103+
@Deprecated
69104
public String getAllMessagesWithFormatting() {
70105
final String messagesAsJson = getMessagesAsJson();
71106
return START + messagesAsJson + END;
72107
}
73108

109+
@Deprecated
74110
private String getMessagesAsJson() {
75111
return new Gson().toJson(MESSAGES);
76112
}

cli-messaging/src/main/java/com/salesforce/messaging/EventKey.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
public enum EventKey {
55
// MAKE SURE `messageKey` OF EVERY VALUE ADDED HERE HAS AN ENTRY IN 'messages/EventKeyTemplates.js'!
6+
7+
/** PMD-CATALOGER RELATED **/
68
INFO_GENERAL_INTERNAL_LOG("info.generalInternalLog", 1, MessageType.INFO, MessageHandler.INTERNAL, true),
79
WARNING_INVALID_CAT_SKIPPED("warning.invalidCategorySkipped", 1, MessageType.WARNING, MessageHandler.UX, true),
810
WARNING_INVALID_RULESET_SKIPPED("warning.invalidRulesetSkipped", 1, MessageType.WARNING, MessageHandler.UX, true),
@@ -20,8 +22,23 @@ public enum EventKey {
2022
ERROR_EXTERNAL_RECURSION_LIMIT("error.external.recursionLimitReached", 2, MessageType.ERROR, MessageHandler.UX, false),
2123
ERROR_EXTERNAL_XML_NOT_READABLE("error.external.xmlNotReadable", 2, MessageType.ERROR, MessageHandler.UX, false),
2224
ERROR_EXTERNAL_XML_NOT_PARSABLE("error.external.xmlNotParsable", 2, MessageType.ERROR, MessageHandler.UX, false),
25+
26+
27+
28+
29+
/** SFGE RELATED **/
30+
INFO_GENERAL("info.sfgeInfoLog", 1, MessageType.INFO, MessageHandler.UX, true),
31+
INFO_META_INFO_COLLECTED("info.sfgeMetaInfoCollected", 2, MessageType.INFO, MessageHandler.UX, true),
32+
INFO_COMPLETED_FILE_COMPILATION("info.sfgeFinishedCompilingFiles", 1, MessageType.INFO, MessageHandler.UX_SPINNER, false),
33+
INFO_STARTED_BUILDING_GRAPH("info.sfgeStartedBuildingGraph", 0, MessageType.INFO, MessageHandler.UX_SPINNER, false),
34+
INFO_COMPLETED_BUILDING_GRAPH("info.sfgeFinishedBuildingGraph", 0, MessageType.INFO, MessageHandler.UX_SPINNER, false),
35+
INFO_PATH_ENTRY_POINTS_IDENTIFIED("info.sfgePathEntryPointsIdentified", 1, MessageType.INFO, MessageHandler.UX_SPINNER, false),
36+
INFO_PATH_ANALYSIS_PROGRESS("info.sfgeViolationsInPathProgress", 4, MessageType.INFO, MessageHandler.UX_SPINNER, false),
37+
INFO_COMPLETED_PATH_ANALYSIS("info.sfgeCompletedPathAnalysis", 3, MessageType.INFO, MessageHandler.UX_SPINNER, false),
38+
WARNING_GENERAL("warning.sfgeWarnLog", 1, MessageType.WARNING, MessageHandler.UX, true),
2339
WARNING_MULTIPLE_METHOD_TARGET_MATCHES("warning.multipleMethodTargetMatches", 3, MessageType.WARNING, MessageHandler.UX, false),
24-
WARNING_NO_METHOD_TARGET_MATCHES("warning.noMethodTargetMatches", 2, MessageType.WARNING, MessageHandler.UX, false);
40+
WARNING_NO_METHOD_TARGET_MATCHES("warning.noMethodTargetMatches", 2, MessageType.WARNING, MessageHandler.UX, false),
41+
ERROR_GENERAL("error.internal.sfgeErrorLog", 1, MessageType.ERROR, MessageHandler.UX, false);
2542

2643
final String messageKey;
2744
final int argCount;

cli-messaging/src/main/java/com/salesforce/messaging/Message.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
public class Message {
77
final private String messageKey;
88
final private List<String> args;
9-
final private String internalLog;
9+
final private String internalLog;
1010
final private MessageType type;
1111
final private MessageHandler handler;
1212
final private boolean verbose;
@@ -34,8 +34,25 @@ public String getInternalLog() {
3434
return internalLog;
3535
}
3636

37+
public MessageType getType() {
38+
return type;
39+
}
40+
41+
public MessageHandler getHandler() {
42+
return handler;
43+
}
44+
45+
public boolean isVerbose() {
46+
return verbose;
47+
}
48+
49+
public long getTime() {
50+
return time;
51+
}
52+
3753
enum MessageHandler {
3854
UX,
55+
UX_SPINNER,
3956
INTERNAL
4057
}
4158

messages/DefaultRuleManager.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module.exports = {
22
"warning": {
33
"targetSkipped": "Target: '%s' was not processed by any engines.",
4-
"targetsSkipped": "Targets: '%s' were not processed by any engines."
4+
"targetsSkipped": "Targets: '%s' were not processed by any engines.",
5+
"pathsDoubleProcessed": "At least one file was processed by both ESLint and ESLint-LWC simultaneously, which could result in duplicate violations. Customize the targetPatterns property for eslint and eslint-lwc engines in %s to remove overlap on the following file(s): %s",
56
}
67
}

messages/EventKeyTemplates.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@ module.exports = {
77
"customEslintHeadsUp": "About to run Eslint with custom config in %s. Please make sure your current directory has all the required NPM dependencies.",
88
"customPmdHeadsUp": "About to run PMD with custom config in %s. Please make sure that any custom rule references have already been added to the plugin through scanner:rule:add command.",
99
"pmdRuleSkipped": "Omitting results for PMD rule \"%s\". Reason: %s.",
10-
"unmatchedPathExtensionCpd": "Path extensions for the following files will not be processed by CPD: %s"
10+
"unmatchedPathExtensionCpd": "Path extensions for the following files will not be processed by CPD: %s",
11+
"sfgeInfoLog": "%s",
12+
"sfgeMetaInfoCollected": "Loaded %s: [ %s ]",
13+
"sfgeFinishedCompilingFiles": "Compiled %s files.",
14+
"sfgeStartedBuildingGraph": "Building graph.",
15+
"sfgeFinishedBuildingGraph": "Added all compilation units to graph.",
16+
"sfgePathEntryPointsIdentified": "Identified %s path entry point(s).",
17+
"sfgeViolationsInPathProgress": "Detected %s violation(s) from %s path(s) on %s/%s entry point(s).",
18+
"sfgeCompletedPathAnalysis": "Overall, analyzed %s path(s) from %s entry point(s). Detected %s violation(s)."
1119
},
1220
"warning": {
1321
"invalidCategorySkipped": "Cataloger skipped invalid PMD Category file '%s'.",
@@ -20,15 +28,17 @@ module.exports = {
2028
"unexpectedPmdNodeType": "Encountered unexpected PMD node of type '%s'",
2129
"multipleMethodTargetMatches": "Total of %s methods in file %s matched name #%s",
2230
"noMethodTargetMatches": "No methods in file %s matched name #%s()",
23-
"pmdConfigError": "PMD failed to evaluate rule '%s'. Message: %s"
31+
"pmdConfigError": "PMD failed to evaluate rule '%s'. Message: %s",
32+
"sfgeWarnLog": "%s"
2433
},
2534
"error": {
2635
"internal": {
2736
"unexpectedError": "INTERNAL ERROR: Unexpected error occurred while cataloging rules: %s. Please log an issue with us at github.com/forcedotcom/sfdx-scanner.",
2837
"mainInvalidArgument": "INTERNAL ERROR: Invalid arguments passed to Main. Details: %s. Please log an issue with us at github.com/forcedotcom/sfdx-scanner.",
2938
"jsonWriteFailed": "INTERNAL ERROR: Failed to write JSON to file: %s. Please log an issue with us at github.com/forcedotcom/sfdx-scanner.",
3039
"classpathDoesNotExist": "INTERNAL ERROR: Path does not exist: %s. Please log an issue with us at github.com/forcedotcom/sfdx-scanner.",
31-
"xmlMissingInClasspath": "INTERNAL ERROR: XML resource [%s] found in jar, but not in Classpath. Please log an issue with us at github.com/forcedotcom/sfdx-scanner."
40+
"xmlMissingInClasspath": "INTERNAL ERROR: XML resource [%s] found in jar, but not in Classpath. Please log an issue with us at github.com/forcedotcom/sfdx-scanner.",
41+
"sfgeErrorLog": "%s"
3242
},
3343
"external": {
3444
"errorMessageAbove": "Please see error details displayed above.",

messages/common.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
2-
FEEDBACK_SURVEY_BANNER: `We're constantly improving Salesforce Code Analyzer. Tell us what you think! Give feedback at https://research.net/r/SalesforceCA.`
3-
};
2+
surveyRequestMessage: `We're constantly improving Salesforce Code Analyzer. Tell us what you think! Give feedback at https://research.net/r/SalesforceCA.`
3+
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@salesforce/sfdx-scanner",
33
"description": "Static code scanner that applies quality and security rules to Apex code, and provides feedback.",
4-
"version": "3.3.0",
4+
"version": "3.4.0",
55
"author": "ISV SWAT",
66
"bugs": "https://github.com/forcedotcom/sfdx-scanner/issues",
77
"dependencies": {

pmd-cataloger/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ group = "sfdx"
99
version = "1.0"
1010

1111
val distDir = "$buildDir/../../dist"
12-
val pmdVersion = "6.47.0"
12+
val pmdVersion = "6.48.0"
1313
val pmdFile = "pmd-bin-$pmdVersion.zip"
1414
val pmdUrl = "https://github.com/pmd/pmd/releases/download/pmd_releases%2F${pmdVersion}/${pmdFile}"
1515
val skippableJarRegexes = setOf("""^common_[\d\.-]*\.jar""".toRegex(),

0 commit comments

Comments
 (0)