forcedotcom / sfdx-scanner

MIT License
208 stars 49 forks source link

NEW (GraphEngine): @W-15639963@: Caches tainted file to entry methods that have paths that taint the file. #1479

Closed rmohan20 closed 1 month ago

rmohan20 commented 1 month ago

Context: To implement delta runs, CLI or IDE needs to know which entry methods and corresponding paths are impacted when a given file is changed. This PR caches a mapping of tainted files to entry methods that lead to paths involving these files. By default, it creates a .sfge-cache directory on the location that executes the command and puts a fileToEntryMapData.json file with the mapping information.

Summary of changes:

  1. New path expansion observer, TaintedFileTracker, to note down files that each ApexPath originating from an entry method traverses.
  2. Changes to rule execution layers to return Result object instead of Set<Violations>. Result now includes FilesToEntriesMap data.
  3. CacheCreator to handle cache file creation.
  4. Two new environment variables to allow users to override cache directory and mapping filename.
  5. Tests to verify Result and Cache behaviors.
  6. File-based tests to verify that the file names and groupings are as expected. (See PathEntryCaptureTest.java)