Apex Interface Unused
Why is this an issue?
Unused interfaces add unnecessary complexity to your codebase. An interface that is never implemented:
Increases code maintenance burden without providing value
May indicate incomplete refactoring or abandoned features
Creates confusion about the intended design
Takes up space in deployment packages
This rule detects interfaces that are not implemented by any class in your codebase. Global interfaces are excluded since they may be implemented by external packages.
Examples
Example of incorrect code:
public interface OrderProcessor {
void processOrder(Order__c order);
}
// No class implements OrderProcessor
Example of correct code:
public interface OrderProcessor {
void processOrder(Order__c order);
}
public class StandardOrderProcessor implements OrderProcessor {
public void processOrder(Order__c order) {
// Implementation
}
}
How can I fix violations?
Either:
Implement the interface: Create a class that implements the interface
Remove the interface: If it's no longer needed, delete it
Make it global: If the interface is intended for external use (managed packages), mark it as
global
When should I disable this rule?
You may want to dismiss this issue if:
The interface is part of a framework being developed and implementations will come later
The interface is used via reflection or dynamic instantiation
You are building a managed package where the interface will be implemented by subscribers
Resources
