You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Yes, I've did not mentioned Law of Demeter because a rule checking it is fare more complicated than just calculating call chains length. For example a builder like MyObject().WithOption1().WithOption2() chains calls but it respects the Law of Demeter. To detect cases like that we need to typecheck and then control on the types in the call chain.
Most of the time, a simple call chain length is enough to point out aberrations like the ones I've used as example in the proposal.
Expressions that have too many indirections are hard to understand.
For example (from Kubernetes):
Other than hard to read, this kind of code is fragile (calls and slice accesses are chained without checking for nil returns nor empty slices)
I propose to create a rule that warns when an expression has too many indirections (too many must be configurable)
The text was updated successfully, but these errors were encountered: