rspec/rules/S2933/why.adoc
Yassin Kammoun e8d14c4eb4
Modify S2933: Migrate to LayC (#3261)
## Review

A dedicated reviewer checked the rule description successfully for:

- [ ] logical errors and incorrect information
- [ ] information gaps and missing content
- [ ] text style and tone
- [ ] PR summary and labels follow [the
guidelines](https://github.com/SonarSource/rspec/#to-modify-an-existing-rule)

---------

Co-authored-by: Zsolt Kolbay <121798625+zsolt-kolbay-sonarsource@users.noreply.github.com>
2023-10-13 08:05:03 +02:00

4 lines
404 B
Plaintext

== Why is this an issue?
`readonly` fields can only be assigned in a class constructor. If a class has a field that's not marked `readonly` but is only set in the constructor, it could cause confusion about the field's intended use. To avoid confusion, such fields should be marked `readonly` to make their intended use explicit, and to prevent future maintainers from inadvertently changing their use.