Skip to content

Latest commit

 

History

History
32 lines (23 loc) · 709 Bytes

UnnecessaryGetter.md

File metadata and controls

32 lines (23 loc) · 709 Bytes

Pattern: Unnecessary getter

Issue: -

Description

Checks for explicit calls to getter/accessor methods which can, for the most part, be replaced by property access. A getter is defined as a method call that matches get[A-Z] but not getClass() or get[A-Z][A-Z] such as getURL(). Getters do not take method arguments.

These bits of code produce violations:

x.getProperty()
x.getFirst()
x.getFirstName()
x.getA()

These bits of code do not:

x.property
x.first
x.firstName
x.a
x.getURL()
x.getClass()
x.getProperty('key')

Further Reading