Use CLI Commands to Analyze Your Code (Retired)

To get started using the Salesforce Code Analyzer CLI commands, complete the prerequisites and follow the installation instructions.

Prerequisites 

To set up Salesforce Code Analyzer, complete these prerequisites.

Java Platform, Standard Edition Development Kit 

Some Code Analyzer features depend on the Java Platform, Standard Edition Java Development Kit (JDK). Install JDK version 11 or later.

Salesforce CLI 

Code Analyzer is a Salesforce CLI plugin, so you must install Salesforce CLI on your machine. Then use Salesforce CLI to execute commands against Salesforce orgs and work with source files on your local computer.

For information about installing Salesforce CLI, read Install Salesforce CLI.

Install Salesforce Code Analyzer 

Complete the prerequisites before you install Salesforce Code Analyzer.

Note

Install Code Analyzer 

To install the Salesforce Code Analyzer plugin, run this command.

1sf plugins install @salesforce/sfdx-scanner

Check Code Analyzer Installation 

To check that Code Analyzer is installed, run this command.

1sf plugins --core

The output shows all the core and use plugins currently installed in Salesforce CLI. If Code Analyzer is installed, it’s listed like this.

1@salesforce/sfdx-scanner 4.3.0

Install a Specific Code Analyzer Version 

To install a specific Code Analyzer version, run this command.

1sf plugins install @salesforce/sfdx-scanner@v4.2.0

Display Code Analyzer Usage and Help 

To display a list of the top-level Code Analyzer commands and topics, run this command.

1sf scanner --help

To view the complete help about a specific command, including the full descriptions and examples, use the --help flag.

1sf scanner run --help

To view the short form of the help, use -h.

1sf scanner run -h

Update Code Analyzer 

To update Code Analyzer, rerun the installation command.

1sf plugins install @salesforce/sfdx-scanner

Uninstall Code Analyzer 

To uninstall Code Analyzer, run this command.

1sf plugins uninstall @salesforce/sfdx-scanner

Run the CLI Commands 

The Code Analyzer CLI commands fall into two groups:

  • Commands to scan your codebase, such as scanner run and scanner run dfa.
  • Commands to manage rules, such as scanner rule list and scanner rule add.

See the scanner Command Reference for a full list of CLI commands; each command page includes examples of how to run the commands.

See Also 

Retired

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