Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
386c234
Handle unresolved parameters passed to Database operations
rmohan20 Jul 21, 2022
7988e3e
Adding more tests
rmohan20 Jul 21, 2022
6c28d09
Handle escapeSingleQuotes() on String since this is a common invocati…
rmohan20 Jul 21, 2022
9cfa39b
Clean up + adding comments/logs
rmohan20 Jul 22, 2022
2c9d9f4
Renaming new violation type to include Info in its name
rmohan20 Jul 22, 2022
9c119aa
Merge branch 'dev-3' into rm/methodCallInDml
rmohan20 Jul 22, 2022
3b1a4a6
Merge pull request #768 from forcedotcom/rm/methodCallInDml
rmohan20 Jul 22, 2022
37a0b99
@W-10778096@ Minor error message fixes
rmohan20 Jul 22, 2022
bcdbed4
Fixing test issues + reformatted unresolved violation template
rmohan20 Jul 22, 2022
5e22b58
Merge pull request #770 from forcedotcom/rm/unresolved-violation-msg-fix
rmohan20 Jul 22, 2022
c99d39f
@W-11446174@: changed eslint parser to @babel/eslint-parser
gkjung Jul 20, 2022
962da2f
Merge pull request #767 from forcedotcom/d/W-11446174
gkjung Jul 22, 2022
2a855ff
Revert "@W-11397711@: Integrated feedback from code review."
rmohan20 Jul 25, 2022
40bc593
Revert "@W-11397711@: Added banner requesting that people take our su…
rmohan20 Jul 25, 2022
d9f983e
Converting stylizedHeader into warning. Pending test failures in add.…
rmohan20 Jul 26, 2022
9b5a49d
Removing unused imports to fix add command
rmohan20 Jul 26, 2022
51284f4
Removing unused file
rmohan20 Jul 26, 2022
bae4ff4
Test changes
rmohan20 Jul 26, 2022
875aff1
Merge pull request #773 from forcedotcom/rm/jsonFormatIssue-3.x
rmohan20 Jul 26, 2022
acce981
Don't throw UserAction error when stripInaccessible() is executed on …
rmohan20 Jul 28, 2022
be3c1e7
Merge pull request #780 from forcedotcom/rm/customValueUserAction
rmohan20 Jul 29, 2022
db14f0d
Skip info logs from dependency
rmohan20 Jul 29, 2022
b6b1a61
Merge pull request #784 from forcedotcom/rm/containJorjeLogs
rmohan20 Jul 29, 2022
34a0e55
Create Unresolved CRUD/FLS violation when SFGE is unable to resolve a…
rmohan20 Aug 1, 2022
3c0a94f
Merge pull request #785 from forcedotcom/rm/dmlVariableExpr
rmohan20 Aug 1, 2022
2b5753f
@W-11446192@: checks if any files are processed by both eslint and es…
gkjung Jul 29, 2022
e81a3bd
Merge pull request #782 from forcedotcom/d/W-11446192
gkjung Aug 4, 2022
bffcf01
@W-11567651@: Updating PMD to v6.48.0.
jfeingold35 Aug 10, 2022
005c044
@W-11567651@: Fixing issue with CPD output formatting.
jfeingold35 Aug 11, 2022
5d5dfea
@W-11567651@: Added comment describing change.
jfeingold35 Aug 11, 2022
219940f
Merge pull request #794 from forcedotcom/d/W-11567651-v3
jfeingold35 Aug 11, 2022
07bf137
Basic changes to bubble up realtime progress information
rmohan20 Aug 9, 2022
2def31f
Added more progress information and stats
rmohan20 Aug 10, 2022
56fed64
Config related changes
rmohan20 Aug 10, 2022
e97100d
Adding more tests + fixing minor issues
rmohan20 Aug 11, 2022
3b5a855
Improving javadocs
rmohan20 Aug 11, 2022
88bd84f
Modifying spinner message to display SFGE progress
rmohan20 Aug 15, 2022
978e49c
PR feedback + fixed end to end tests
rmohan20 Aug 15, 2022
fd3af9c
Reordered verbose test
rmohan20 Aug 15, 2022
8fd2044
remove conditional on handleLiveOut
rmohan20 Aug 15, 2022
5acf779
Minor changes
rmohan20 Aug 15, 2022
805ca8c
Fixing issues introduced in previous commit
rmohan20 Aug 15, 2022
6776803
Creating an alternate test provider for ProgressImpl
rmohan20 Aug 16, 2022
a995ba5
--verbose in test issue
rmohan20 Aug 16, 2022
566a0b6
Merge pull request #792 from forcedotcom/rm/returnTimelyResults
jfeingold35 Aug 16, 2022
b35438d
Redirecting ApexPathExpander logs to log file
rmohan20 Aug 16, 2022
79faf1f
Merge pull request #796 from forcedotcom/rm/fixForNoisyWarnings
rmohan20 Aug 16, 2022
805a8d2
@W-11606553@ Release version update, yarn lock update, RetireJS lates…
rmohan20 Aug 16, 2022
32ac240
Merge pull request #799 from forcedotcom/rm/release3.4.0-updates
rmohan20 Aug 16, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.Arrays;
import java.util.List;

import com.google.common.collect.Lists;
import com.google.gson.Gson;

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

private static final String REALTIME_START = "SFCA-REALTIME-START";
private static final String REALTIME_END = "SFCA-REALTIME-END";

/* Deprecated: Don't maintain state in a class that's essentially used as a utility.*/
@Deprecated
private static final List<Message> MESSAGES = new ArrayList<>();

/**
* Deprecated - switch to static invocation of {@link #postMessage(String, EventKey, String...)}
*/
@Deprecated
public static CliMessager getInstance() {
return LazyHolder.INSTANCE;
}
Expand All @@ -26,6 +36,7 @@ public static CliMessager getInstance() {
*
* @param exception to send to Typescript layer
*/
@Deprecated
public void addMessage(MessagePassableException exception) {
final EventKey eventKey = exception.getEventKey();
addMessage(
Expand All @@ -43,34 +54,59 @@ public void addMessage(MessagePassableException exception) {
* @param eventKey EventKey to display to user
* @param args String args passed to the EventKey to make the displayed message meaningful
*/
@Deprecated
public void addMessage(String internalLog, EventKey eventKey, String... args) {
// Developer error if eventKey was not added to exception and we'll get a bunch of NPEs
assert (eventKey != null);
// Confirm that the correct number of arguments for the message has been provided
// If this fails, this would be a developer error
assert (eventKey.getArgCount() == args.length);

final Message message = new Message(
eventKey.getMessageKey(),
Arrays.asList(args),
internalLog,
eventKey.getMessageType(),
eventKey.getMessageHandler(),
eventKey.isVerbose());
MESSAGES.add(message);
final Message message = createMessage(internalLog, eventKey, args);
MESSAGES.add(message);
}

/**
/**
* Publish formatted stdout message to pass onto Typescript layer.
* Make sure EventKey is updated with messages/EventKeyTemplates.json
* and has correct properties in the enum.
*
* @param internalLog Information for internal use. Will be logged but not displayed to user
* @param eventKey EventKey to display to user
* @param args String args passed to the EventKey to make the displayed message meaningful
*/
public static void postMessage(String internalLog, EventKey eventKey, String... args) {
final Message message = createMessage(internalLog, eventKey, args);
final List<Message> messages = Lists.newArrayList(message);

final String messageAsJson = new Gson().toJson(messages);
System.out.println(REALTIME_START + messageAsJson + REALTIME_END);
}

private static Message createMessage(String internalLog, EventKey eventKey, String[] args) {
// Developer error if eventKey was not added to exception and we'll get a bunch of NPEs
assert (eventKey != null);
// Confirm that the correct number of arguments for the message has been provided
// If this fails, this would be a developer error
assert (eventKey.getArgCount() == args.length);

final Message message = new Message(
eventKey.getMessageKey(),
Arrays.asList(args),
internalLog,
eventKey.getMessageType(),
eventKey.getMessageHandler(),
eventKey.isVerbose());
return message;
}

/**
* Convert all messages stored by the instance into a JSON-formatted string, enclosed in the start and end strings.
* Java code can use this method to log the messages to console, and TypeScript code can seek the start and stop
* strings to get an array of messages that can be deserialized.
* @return
*/
@Deprecated
public String getAllMessagesWithFormatting() {
final String messagesAsJson = getMessagesAsJson();
return START + messagesAsJson + END;
}

@Deprecated
private String getMessagesAsJson() {
return new Gson().toJson(MESSAGES);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

public enum EventKey {
// MAKE SURE `messageKey` OF EVERY VALUE ADDED HERE HAS AN ENTRY IN 'messages/EventKeyTemplates.js'!

/** PMD-CATALOGER RELATED **/
INFO_GENERAL_INTERNAL_LOG("info.generalInternalLog", 1, MessageType.INFO, MessageHandler.INTERNAL, true),
WARNING_INVALID_CAT_SKIPPED("warning.invalidCategorySkipped", 1, MessageType.WARNING, MessageHandler.UX, true),
WARNING_INVALID_RULESET_SKIPPED("warning.invalidRulesetSkipped", 1, MessageType.WARNING, MessageHandler.UX, true),
Expand All @@ -20,8 +22,23 @@ public enum EventKey {
ERROR_EXTERNAL_RECURSION_LIMIT("error.external.recursionLimitReached", 2, MessageType.ERROR, MessageHandler.UX, false),
ERROR_EXTERNAL_XML_NOT_READABLE("error.external.xmlNotReadable", 2, MessageType.ERROR, MessageHandler.UX, false),
ERROR_EXTERNAL_XML_NOT_PARSABLE("error.external.xmlNotParsable", 2, MessageType.ERROR, MessageHandler.UX, false),




/** SFGE RELATED **/
INFO_GENERAL("info.sfgeInfoLog", 1, MessageType.INFO, MessageHandler.UX, true),
INFO_META_INFO_COLLECTED("info.sfgeMetaInfoCollected", 2, MessageType.INFO, MessageHandler.UX, true),
INFO_COMPLETED_FILE_COMPILATION("info.sfgeFinishedCompilingFiles", 1, MessageType.INFO, MessageHandler.UX_SPINNER, false),
INFO_STARTED_BUILDING_GRAPH("info.sfgeStartedBuildingGraph", 0, MessageType.INFO, MessageHandler.UX_SPINNER, false),
INFO_COMPLETED_BUILDING_GRAPH("info.sfgeFinishedBuildingGraph", 0, MessageType.INFO, MessageHandler.UX_SPINNER, false),
INFO_PATH_ENTRY_POINTS_IDENTIFIED("info.sfgePathEntryPointsIdentified", 1, MessageType.INFO, MessageHandler.UX_SPINNER, false),
INFO_PATH_ANALYSIS_PROGRESS("info.sfgeViolationsInPathProgress", 4, MessageType.INFO, MessageHandler.UX_SPINNER, false),
INFO_COMPLETED_PATH_ANALYSIS("info.sfgeCompletedPathAnalysis", 3, MessageType.INFO, MessageHandler.UX_SPINNER, false),
WARNING_GENERAL("warning.sfgeWarnLog", 1, MessageType.WARNING, MessageHandler.UX, true),
WARNING_MULTIPLE_METHOD_TARGET_MATCHES("warning.multipleMethodTargetMatches", 3, MessageType.WARNING, MessageHandler.UX, false),
WARNING_NO_METHOD_TARGET_MATCHES("warning.noMethodTargetMatches", 2, MessageType.WARNING, MessageHandler.UX, false);
WARNING_NO_METHOD_TARGET_MATCHES("warning.noMethodTargetMatches", 2, MessageType.WARNING, MessageHandler.UX, false),
ERROR_GENERAL("error.internal.sfgeErrorLog", 1, MessageType.ERROR, MessageHandler.UX, false);

final String messageKey;
final int argCount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
public class Message {
final private String messageKey;
final private List<String> args;
final private String internalLog;
final private String internalLog;
final private MessageType type;
final private MessageHandler handler;
final private boolean verbose;
Expand Down Expand Up @@ -34,8 +34,25 @@ public String getInternalLog() {
return internalLog;
}

public MessageType getType() {
return type;
}

public MessageHandler getHandler() {
return handler;
}

public boolean isVerbose() {
return verbose;
}

public long getTime() {
return time;
}

enum MessageHandler {
UX,
UX_SPINNER,
INTERNAL
}

Expand Down
3 changes: 2 additions & 1 deletion messages/DefaultRuleManager.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module.exports = {
"warning": {
"targetSkipped": "Target: '%s' was not processed by any engines.",
"targetsSkipped": "Targets: '%s' were not processed by any engines."
"targetsSkipped": "Targets: '%s' were not processed by any engines.",
"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",
}
}
16 changes: 13 additions & 3 deletions messages/EventKeyTemplates.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@ module.exports = {
"customEslintHeadsUp": "About to run Eslint with custom config in %s. Please make sure your current directory has all the required NPM dependencies.",
"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.",
"pmdRuleSkipped": "Omitting results for PMD rule \"%s\". Reason: %s.",
"unmatchedPathExtensionCpd": "Path extensions for the following files will not be processed by CPD: %s"
"unmatchedPathExtensionCpd": "Path extensions for the following files will not be processed by CPD: %s",
"sfgeInfoLog": "%s",
"sfgeMetaInfoCollected": "Loaded %s: [ %s ]",
"sfgeFinishedCompilingFiles": "Compiled %s files.",
"sfgeStartedBuildingGraph": "Building graph.",
"sfgeFinishedBuildingGraph": "Added all compilation units to graph.",
"sfgePathEntryPointsIdentified": "Identified %s path entry point(s).",
"sfgeViolationsInPathProgress": "Detected %s violation(s) from %s path(s) on %s/%s entry point(s).",
"sfgeCompletedPathAnalysis": "Overall, analyzed %s path(s) from %s entry point(s). Detected %s violation(s)."
},
"warning": {
"invalidCategorySkipped": "Cataloger skipped invalid PMD Category file '%s'.",
Expand All @@ -20,15 +28,17 @@ module.exports = {
"unexpectedPmdNodeType": "Encountered unexpected PMD node of type '%s'",
"multipleMethodTargetMatches": "Total of %s methods in file %s matched name #%s",
"noMethodTargetMatches": "No methods in file %s matched name #%s()",
"pmdConfigError": "PMD failed to evaluate rule '%s'. Message: %s"
"pmdConfigError": "PMD failed to evaluate rule '%s'. Message: %s",
"sfgeWarnLog": "%s"
},
"error": {
"internal": {
"unexpectedError": "INTERNAL ERROR: Unexpected error occurred while cataloging rules: %s. Please log an issue with us at github.com/forcedotcom/sfdx-scanner.",
"mainInvalidArgument": "INTERNAL ERROR: Invalid arguments passed to Main. Details: %s. Please log an issue with us at github.com/forcedotcom/sfdx-scanner.",
"jsonWriteFailed": "INTERNAL ERROR: Failed to write JSON to file: %s. Please log an issue with us at github.com/forcedotcom/sfdx-scanner.",
"classpathDoesNotExist": "INTERNAL ERROR: Path does not exist: %s. Please log an issue with us at github.com/forcedotcom/sfdx-scanner.",
"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."
"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.",
"sfgeErrorLog": "%s"
},
"external": {
"errorMessageAbove": "Please see error details displayed above.",
Expand Down
4 changes: 2 additions & 2 deletions messages/common.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
FEEDBACK_SURVEY_BANNER: `We're constantly improving Salesforce Code Analyzer. Tell us what you think! Give feedback at https://research.net/r/SalesforceCA.`
};
surveyRequestMessage: `We're constantly improving Salesforce Code Analyzer. Tell us what you think! Give feedback at https://research.net/r/SalesforceCA.`
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@salesforce/sfdx-scanner",
"description": "Static code scanner that applies quality and security rules to Apex code, and provides feedback.",
"version": "3.3.0",
"version": "3.4.0",
"author": "ISV SWAT",
"bugs": "https://github.com/forcedotcom/sfdx-scanner/issues",
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion pmd-cataloger/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ group = "sfdx"
version = "1.0"

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