Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion packages/code-analyzer-sfge-engine/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@salesforce/code-analyzer-sfge-engine",
"description": "Plugin package that adds 'Salesforce Graph Engine' as an engine into Salesforce Code Analyzer",
"version": "0.18.0-SNAPSHOT",
"version": "0.19.0-SNAPSHOT",
"author": "The Salesforce Code Analyzer Team",
"license": "BSD-3-Clause",
"homepage": "https://developer.salesforce.com/docs/platform/salesforce-code-analyzer/overview",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ public final class EnvUtil {
// TODO: These should move to SfgeConfigImpl and this class should return Optionals
@VisibleForTesting
static final int DEFAULT_RULE_THREAD_COUNT =
Math.min(Runtime.getRuntime().availableProcessors(), 4);
Math.min(Runtime.getRuntime().availableProcessors(), 8);

@VisibleForTesting
static final long DEFAULT_RULE_THREAD_TIMEOUT =
TimeUnit.MILLISECONDS.convert(15, TimeUnit.MINUTES);
TimeUnit.MILLISECONDS.convert(30, TimeUnit.SECONDS);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the PR description we say we are keeping this as 3 mins but are changing this to 30 seconds here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated description


@VisibleForTesting static final boolean DEFAULT_RULE_DISABLE_WARNING_VIOLATION = false;
@VisibleForTesting static final boolean DEFAULT_LOG_WARNINGS_ON_VERBOSE = false;
Expand Down
4 changes: 2 additions & 2 deletions packages/code-analyzer-sfge-engine/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export const DEFAULT_SFGE_ENGINE_CONFIG: SfgeEngineConfig = {
java_command: DEFAULT_JAVA_COMMAND,
disable_limit_reached_violations: false,
java_max_heap_size: undefined,
java_thread_count: 4,
java_thread_timeout: 900000
java_thread_count: 8,
java_thread_timeout: 30000
};

export const SFGE_ENGINE_CONFIG_DESCRIPTION: ConfigDescription = {
Expand Down
14 changes: 12 additions & 2 deletions packages/code-analyzer-sfge-engine/src/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ import {RuntimeSfgeWrapper, SfgeRuleInfo, SfgeRunOptions, SfgeRunResult} from ".
import {SfgeEngineConfig} from "./config";

const SFGE_RELEVANT_FILE_EXTENSIONS = ['.cls', '.trigger', '-meta.xml', '.page', '.component'];
// SFGE can only create entry points from Apex source files — filtering targets
// to these extensions prevents SFGE from receiving non-Apex files as targets,
// which would cause useless union() branches during static rule graph traversal.
const SFGE_TARGET_FILE_EXTENSIONS = ['.cls', '.trigger'];
const DEV_PREVIEW_TAG: string = 'DevPreview';

export class SfgeEngine extends Engine {
Expand Down Expand Up @@ -68,8 +72,10 @@ export class SfgeEngine extends Engine {
return { violations: [] };
}

// Get targeted files and return early if empty - prevents SFGE from analyzing all workspace files
const targetedFiles: string[] = await runOptions.workspace.getTargetedFiles();
// Get targeted files and filter to Apex source only (.cls and .trigger).
// SFGE only creates entry points from Apex files; passing non-Apex targets
// causes useless union() branches during graph traversal with no benefit.
const targetedFiles: string[] = (await runOptions.workspace.getTargetedFiles()).filter(isApexSourceFile);
if (targetedFiles.length === 0) {
this.emitRunRulesProgressEvent(100);
return { violations: [] };
Expand Down Expand Up @@ -197,6 +203,10 @@ function isFileRelevantToSfge(fileName: string): boolean {
return SFGE_RELEVANT_FILE_EXTENSIONS.some(extension => fileName.toLowerCase().endsWith(extension));
}

function isApexSourceFile(fileName: string): boolean {
return SFGE_TARGET_FILE_EXTENSIONS.some(extension => fileName.toLowerCase().endsWith(extension));
}

function toRuleDescription(sfgeRuleInfo: SfgeRuleInfo): RuleDescription {
const tags: string[] = [DEV_PREVIEW_TAG, sfgeRuleInfo.category.replaceAll(' ', '')];
tags.push(COMMON_TAGS.LANGUAGES.APEX);
Expand Down
4 changes: 2 additions & 2 deletions packages/code-analyzer-sfge-engine/test/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ describe('SfgeEnginePlugin', () => {
java_command: resolvedConfig.java_command, // We just checked the Java Command above.
disable_limit_reached_violations: false,
java_max_heap_size: undefined,
java_thread_count: 4,
java_thread_timeout: 900000
java_thread_count: 8,
java_thread_timeout: 30000
});
});

Expand Down
Loading