Code Analyzer Command Reference (Retired)

This command reference contains information about Salesforce Code Analyzer commands and their flags.

Get Started 

To scan your code and output any violations found to a results file, run:

  • sf scanner run --target somefile.js --outfile results.html

Replace these values: 

  • somefile.js: The source code location.
  • results.html: The output format.

To scan your code with a specific engine, run

  • sf scanner run --target /some/dir --engine cpd

Replace these values: 

  • /some/dir: The source code location.
  • cpd: The engine or engines to run.

CI/CD Integration 

To continuously improve your code, integrate Code Analyzer results into your CI/CD tool. Your tool can interpret those violations and act on them.

Graph Engine 

To scan your code with Graph Engine data-flow analysis, run:

  • sf scanner run dfa --target ./myproject/main/default/classes/*.cls --projectdir ./myproject/

Replace these values: 

  • ./myproject/main/default/classes/*.cls: The source code location.
  • ./myproject/: The root project directory.

Retired

As of August 2025, Salesforce Code Analyzer v4 is retired and no longer supported. Use Code Analyzer v5 instead.