@@ -19,6 +19,10 @@ import {RuntimeSfgeWrapper, SfgeRuleInfo, SfgeRunOptions, SfgeRunResult} from ".
1919import { SfgeEngineConfig } from "./config" ;
2020
2121const SFGE_RELEVANT_FILE_EXTENSIONS = [ '.cls' , '.trigger' , '-meta.xml' , '.page' , '.component' ] ;
22+ // SFGE can only create entry points from Apex source files — filtering targets
23+ // to these extensions prevents SFGE from receiving non-Apex files as targets,
24+ // which would cause useless union() branches during static rule graph traversal.
25+ const SFGE_TARGET_FILE_EXTENSIONS = [ '.cls' , '.trigger' ] ;
2226const DEV_PREVIEW_TAG : string = 'DevPreview' ;
2327
2428export class SfgeEngine extends Engine {
@@ -68,8 +72,10 @@ export class SfgeEngine extends Engine {
6872 return { violations : [ ] } ;
6973 }
7074
71- // Get targeted files and return early if empty - prevents SFGE from analyzing all workspace files
72- const targetedFiles : string [ ] = await runOptions . workspace . getTargetedFiles ( ) ;
75+ // Get targeted files and filter to Apex source only (.cls and .trigger).
76+ // SFGE only creates entry points from Apex files; passing non-Apex targets
77+ // causes useless union() branches during graph traversal with no benefit.
78+ const targetedFiles : string [ ] = ( await runOptions . workspace . getTargetedFiles ( ) ) . filter ( isApexSourceFile ) ;
7379 if ( targetedFiles . length === 0 ) {
7480 this . emitRunRulesProgressEvent ( 100 ) ;
7581 return { violations : [ ] } ;
@@ -197,6 +203,10 @@ function isFileRelevantToSfge(fileName: string): boolean {
197203 return SFGE_RELEVANT_FILE_EXTENSIONS . some ( extension => fileName . toLowerCase ( ) . endsWith ( extension ) ) ;
198204}
199205
206+ function isApexSourceFile ( fileName : string ) : boolean {
207+ return SFGE_TARGET_FILE_EXTENSIONS . some ( extension => fileName . toLowerCase ( ) . endsWith ( extension ) ) ;
208+ }
209+
200210function toRuleDescription ( sfgeRuleInfo : SfgeRuleInfo ) : RuleDescription {
201211 const tags : string [ ] = [ DEV_PREVIEW_TAG , sfgeRuleInfo . category . replaceAll ( ' ' , '' ) ] ;
202212 tags . push ( COMMON_TAGS . LANGUAGES . APEX ) ;
0 commit comments