sf scanner rule add

Adds custom rules to Salesforce Code Analyzer’s registry so that you can run them along with the built-in rules. Compile and test custom rules separately before adding them. For more info, read Authoring Custom PMD Rules or Authoring Custom ESLint Rules.

Bundle custom PMD rules in JAR files. Follow PMD conventions, such as defining the custom rules in XML files under a /category directory. See the PMD documentation for more information on writing rules.

This example shows how to specify two JAR files directly. You can also specify a directory containing one or more JARs, all of which will be added.

  • {/Users/me/rules/Jar1.jar,/Users/me/rules/category/apex/MyRules.xml}: The path to your JAR files.

This example shows how to specify a directory that contains one or more JAR files, all of which are added to the registry.

  • apex: The language that your custom rules are to be evaluated against.
  • /Users/me/rules: The path to your JAR files.

sf scanner rule add

   -l LANGUAGE

   -p PATH_LIST

   [--json]

-l | --language LANGUAGE

Required

Language that the custom rules are evaluated against.

Type: option

-p | --path PATH_LIST

Required

One or more paths (such as a directory or JAR file) to custom rule definitions. Specify multiple values as a comma-separated list.

Type: option

--json

Optional

Format output as JSON.

Type: boolean