Abstract class declares no abstract or virtual member
ID |
apex.maintainability.abstract_to_concrete |
Severity |
low |
Remediation Complexity |
medium |
Remediation Risk |
low |
Remediation Effort |
low |
Resource |
Api Design |
Language |
Apex |
Description
Reports a class declared abstract whose body contains neither an abstract method nor a virtual method, so there is nothing for a subclass to implement or override. A class that implements an interface is not reported: the members it leaves unimplemented are the extension point.
Rationale
abstract is a contract with the subclass: it says "this type is incomplete, and here is the part you must supply". When no member is abstract or virtual, the keyword only blocks instantiation while promising an extension point that does not exist. A developer who subclasses it to fill in the missing piece finds nothing to override, and a developer who wants to use it directly cannot - which is the worst of both designs.
The following code illustrates the pattern detected by this rule:
// FLAGGED: Abstract class declares no abstract or virtual member
public abstract class PaymentBase {
public void charge(Decimal amount) {
System.debug(amount);
}
}