Skip to content
Fallow home
All docs pages

Docs home

Unused protected class members

What an unused-protected-class-member finding of fallow dead-code means, why it matters and how to fix it.

What it reports

Protected class member is never referenced.

Dead code explains how fallow finds it.

Why it matters

Class methods and properties with the protected modifier that neither the class nor a subclass reads. A read through this or super in the class or in a subclass counts as a use. A subclass override counts as used when the base class calls the member. Classes of the public API of a package are not checked, because a consumer can subclass them. Production mode ignores reads in test files. Defaults to off. Known limits: a read through a string key (this["member"]()) gives no credit, and a constructor parameter property (constructor(protected readonly x: X)) is not checked.

Example

class Shape declares protected unusedHelper(), and neither Shape nor a subclass calls this.unusedHelper() or super.unusedHelper().

Fix

Remove the member, or make it private when only the class reads it. If a subclass outside the project reads it, suppress the line with // fallow-ignore-next-line unused-protected-class-member.

Facts

FactValue
Issue typeunused-protected-class-member
Rule id in SARIF outputfallow/unused-protected-class-member
Commandfallow dead-code
Default severityoff
Config key in rulesunused-protected-class-members
Filter option--unused-protected-class-members
Suppression comment// fallow-ignore-next-line unused-protected-class-member
Fixable with fallow fixNo
Opt-inYes