---
schema_version: "1"
id: b91ac6cc8be3cb4e8b914a30f6e29be0504ce4ed0f3783b68ced95738b423455
title: RemoveUnusedMethod Rule (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/salesforce-graph-engine/removeunusedmethod-rule.md
canonical_url: https://developer.salesforce.com/docs/platform/salesforce-code-analyzer/guide/removeunusedmethod-rule.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 1355fe8c61622b8d8f61422191b5b28656403f26101f8bab90d677124e7e856f
products:
  - Salesforce Code Analyzer
---
# RemoveUnusedMethod Rule (Retired)

RemoveUnusedMethod is a path-based analysis rule that detects many methods contained in your code that aren’t invoked from any entry points that Graph Engine recognizes. It detects static methods and instance methods.

RemoveUnusedMethod recognizes these entry points.

- `@AuraEnabled`-annotated methods.
- `@InvocableMethod`-annotated methods.
- `@NamespaceAccessible`-annotated methods.
- `@RemoteAction`-annotated methods.
- Any method returning a `PageReference`` object.
- `Public`-scoped methods on Visualforce Controllers.
- `Global`-scoped methods on any class.
- `Messaging.InboundEmailResult handleInboundEmail()` methods on implementations of `Messaging.InboundEmailHandler`.
- Any method targeted during invocation.

## Definition

RemoveUnusedMethod uses sources like ApexFlsViolationRule does, but the RemoveUnusedMethod sinks are different. Instead of seeking DML operations that occur in the course of a path, RemoveUnusedMethod sinks track all method invocations that occur on that path and use that information to identify methods that are never invoked.

## Interpreting Results

Match any violation message that you receive with this case to understand more about the violation.

### Common Case

> Method %s in class %s isn’t used in any path from any recognized entry point.

Because no invocations of the indicated method were found in the paths originating from the identified entry points, the method is unnecessary and can be deleted.

## Limitations

- RemoveUnusedMethod works on static methods and instance methods. Constructors aren't detected.
- Global methods are intentionally excluded because their external usage is assumed.
- If the set of files included in `--target` is smaller than the files included in `--projectdir`, then RemoveUnusedMethod can return unexpected results. For that reason, we recommend running this rule against your whole codebase, not against individual files.
