---
schema_version: "1"
id: 694a973a038397cba083992bb16c45142bd294b06bd204812ae0deff90d6f253
title: Regex Rules Reference
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/code-analyzer/salesforce-code-analyzer/guides/rules-regex.md
canonical_url: https://developer.salesforce.com/docs/platform/salesforce-code-analyzer/guide/rules-regex.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: df5139e50390baffa7925909c70df46d9064d25eb2eea04a8b3d22a39b70261b
products:
  - Salesforce Code Analyzer
---
# Regex Rules Reference

The Regex rules help you search for specific string patterns in your code. To select these rules, use `--rule-selector regex`. For example, to run all the Regex rules:

```bash
sf code-analyzer run --rule-selector regex
```

## AvoidGetHeapSizeInLoop

**Description:** Detects usage of the `Limits.getHeapSize()` Apex method in `for`, `while`, and `do-while` loops.

**Default Severity:** 2 (High)

**Default Tags:** `Recommended`, `Performance`, `Apex`

**Example(s):**

- [Bad] Code that causes a violation:

```apex
    public static void someMethodWithForLoop() {
        for (Integer i = 0, j = 0; i < 10; i++) {
            Limits.getHeapSize();
        }
    }
```

## AvoidOldSalesforceApiVersions

**Description:** Detects usage of Salesforce API versions that are 3 or more years old.

**Default Severity:** 2 (High)

**Default Tags:** `Recommended`, `Security`, `Xml`

## AvoidTermsWithImplicitBias

**Description:** Detects usage of terms that reinforce implicit bias.

**Default Severity:** 5 (Info)

**Default Tags:** `Recommended`, `BestPractices`

**More Information**: [Salesforce Updates Technical Language in Ongoing Effort to Address Implicit Bias](https://www.salesforce.com/news/stories/salesforce-updates-technical-language-in-ongoing-effort-to-address-implicit-bias/).

## MinVersionForAbstractVirtualClassesWithPrivateMethod

**Description:** Detects private methods within abstract or virtual Apex classes when the corresponding API version of the class is less than 61.0.

**Default Severity:** 2 (High)

**Default Tags:** `Recommended`, `BestPractices`, `Apex`

**Example(s):**

- [Bad] Code that causes a violation:

```apex
public abstract class SomeAbstractClass {
    public void somePublicMethod() {
        somePrivateMethod();
    }
    private void somePrivateMethod() {
        // ...
    }
}
```

With this metadata XML file:

```xml
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
    <!-- Here's a comment -->
    <apiVersion>60.0</apiVersion>
</ApexClass>
```

## NoTrailingWhitespace

**Description:** Detects trailing whitespace (tabs or spaces) at the end of lines of code and lines that are only whitespace.

**Default Severity:** 5 (Info)

**Default Tags:** `Recommended`, `CodeStyle`, `Apex`

## NoMixedIndentation

**Description:** Detect if tabs and spaces are mixed together. Mixing tabs and spaces can cause unexpected formatting issues, especially in the Developer Console.

**Default Severity:** Moderate (3)

**Default Tags:** `Recommended`

**Example(s):**

- [Bad] Code that causes a violation:

```
public class MyClass {
⇥   String msg = '''    // Tab + spaces
        Hello World
    ''';
}
```

- [Clean] Code:

```
public class MyClass {
    String msg = '''    // Only spaces
        Hello World
    ''';
}
```

```
public class MyClass {
⇥String msg = '''      // Only tabs
⇥⇥Hello World
⇥''';
}
```
