Add the #DF24 Developer Keynote to your agenda. Join us in-person on 9/18 at 2:30 p.m. PT or on Salesforce+ at 5 p.m. PT for the must-see session built just for developers.

Code Analyzer Command Reference

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

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

  • sf scanner run --target somefile.js --outfile results.html
  • 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
  • /some/dir: The source code location.
  • cpd: The engine or engines to run.

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

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

  • sf scanner run dfa --target ./myproject/main/default/classes/*.cls --projectdir ./myproject/
  • ./myproject/main/default/classes/*.cls: The source code location.
  • ./myproject/: The root project directory.