Code Analyzer Command Reference

This command reference contains information about Salesforce Code Analyzer commands and their flags. Where there are differences between Code Analyzer v3.x (generally available) and v4.x (beta), they’re explicitly noted.

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.