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
| Fact | Value |
|---|---|
| Issue type | unused-protected-class-member |
| Rule id in SARIF output | fallow/unused-protected-class-member |
| Command | fallow dead-code |
| Default severity | off |
Config key in rules | unused-protected-class-members |
| Filter option | --unused-protected-class-members |
| Suppression comment | // fallow-ignore-next-line unused-protected-class-member |
Fixable with fallow fix | No |
| Opt-in | Yes |