---
schema_version: "1"
id: 87113107de134cba0b0e4a500c4403d71321aba079e163be59dec29014ef302f
title: sf scanner rule add (Retired)
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/code-analyzer/salesforce-code-analyzer/guides/v3x/command-reference/add.md
canonical_url: https://developer.salesforce.com/docs/platform/salesforce-code-analyzer/guide/add.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 0a3468e3ddf93aba73f87ce13899464e21b7532d71cc341a3dc6c4b01fde778b
products:
  - Salesforce Code Analyzer
---
# sf scanner rule add (Retired)

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](https://developer.salesforce.com/docs/platform/salesforce-code-analyzer/custom-configuration/pmd-config.md#authoring-custom-pmd-rules) or [Authoring Custom ESLint Rules](https://developer.salesforce.com/docs/platform/salesforce-code-analyzer/custom-configuration/eslint-config.md#authoring-custom-eslint-rules).

## Examples

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](https://pmd.github.io/pmd/index.html) for more information on writing rules.

### Specify JAR Files

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.

```
  $ sf scanner rule add --language apex --path {/Users/me/rules/Jar1.jar,/Users/me/rules/category/apex/MyRules.xml}
         Successfully added rules for apex.
         2 path(s) added:
         /Users/me/rules/Jar1.jar,/Users/me/rules/category/apex/MyRules.xml
```

#### Replace this value:

- `{/Users/me/rules/Jar1.jar,/Users/me/rules/category/apex/MyRules.xml}`: The path to your JAR files.

### Specify a Directory

This example shows how to specify a directory that contains one or more JAR files, all of which are added to the registry.

```
  $ sf scanner rule add --language {apex} --path /Users/me/rules
         Successfully added rules for apex.
         2 path(s) added:
         /Users/me/rules/SomeJar.jar,/Users/me/rules/category/apex/MyRules.xml
```

#### Replace these values:

- `apex`: The language that your custom rules are to be evaluated against.
- `/Users/me/rules`: The path to your JAR files.

## Usage

`sf scanner rule add `

&nbsp;&nbsp; `-l` LANGUAGE

&nbsp;&nbsp; `-p` PATH_LIST

&nbsp;&nbsp; [`--json`]


## Flags

`-l` <b>|</b> `--language` LANGUAGE

> Required
>
> Language that the custom rules are evaluated against.
>
> Type: option

`-p` <b>|</b> `--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

