Set Up Code Analyzer v5 (Beta)

This section describes how to get started with Code Analyzer v5 by installing the CLI plugin. You can install v5 of the plugin alongside v4 and use both sets of commands at the same time.

Code Analyzer v5 is a pilot or beta service that is subject to the Beta Services Terms at Agreements - Salesforce.com or a written Unified Pilot Agreement if executed by Customer, and applicable terms in the Product Terms Directory. Use of this pilot or beta service is at the Customer's sole discretion.

The Code Analyzer v5 Plugin includes these commands:

  • code-analyzer rules: List the rules that are available to analyze your code.
  • code-analyzer run: Analyze your code with a selection of rules to ensure good coding practices.
  • code-analyzer config: Display the Code Analyzer configuration state and optionally write it to a file.
  • Code Analyzer is a Salesforce CLI plugin, so you must install Salesforce CLI on your computer. See Install Salesforce CLI for details.

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

  • The Flowtest engine requires Python. If you plan to use the Flowtest engine, install Python version 3.10.0 or later.

    If you don't plan to use the Flowtest engine, and you don't want to install Python, be sure you explicitly disable the Flowtest engine by updating your Code Analyzer configuration file (code-analyzer.yml). Engines are typically enabled by default. For example:

Run this command to install the Code Analyzer v5 plugin:

To verify that you’ve installed it correctly, run this command:

The output shows all the core and user plugins currently installed in Salesforce CLI. If Code Analyzer v5 is installed, you see an entry like this in the output, although the version can be different:

Run this command to list the v5 commands:

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

You can also view the same information online in the Salesforce CLI Command Reference.

To view short help, use the -h flag:

To update Code Analyzer v5, rerun the installation command.

To uninstall Code Analyzer v5, run this command.