Skip to content

Redundant Accessibility

Declarations that are marked public yet are not referenced from outside their home module are identified as having redundant public accessibility. In this scenario, the public annotation can be removed from the declaration.

Removing redundant public accessibility has a couple of benefits:

Disable this analysis with --disable-redundant-public-analysis, or set disable_redundant_public_analysis: true in your configuration.

An open class permits subclassing outside its defining module. When a class does not need that capability, Periphery reports redundant open accessibility and recommends replacing open with public. The class remains accessible to other modules and can still be subclassed within its own module.

Periphery preserves open when a class has a subclass in another scanned module, except when that subclass unconditionally uses @testable import for the superclass’s module. It also preserves an open superclass of an open subclass, as Swift requires that superclass to remain open. After changing the subclass to public, a subsequent scan can identify its superclass as redundant too.

Disable this analysis with --disable-redundant-open-analysis, or set disable_redundant_open_analysis: true in your configuration.