rspec/rules/S4275/description.adoc
2023-06-13 09:16:19 +02:00

8 lines
546 B
Plaintext

Getters and setters provide a way to enforce encapsulation by providing ``++public++`` methods that give controlled access to ``++private++`` fields. However, in classes with multiple fields, it is not unusual that copy and paste is used to quickly create the needed getters and setters, which can result in the wrong field being accessed by a getter or setter.
This rule raises an issue in any of these cases:
* A setter does not update the field with the corresponding name.
* A getter does not access the field with the corresponding name.