Why is this an issue?
Since abstract
classes can’t be instantiated, there’s no point in their having public
or internal
constructors. If there is basic initialization logic that should run when an extending class instance is created, you can by all means put it in a
constructor, but make that constructor private
, private protected
or protected
.
Noncompliant code example
abstract class Base
{
public Base() // Noncompliant, should be private, private protected or protected
{
//...
}
}
Compliant solution
abstract class Base
{
protected Base()
{
//...
}
}