Avoid using complex operands

Why you should care

This code insight sanctions data accesses in operands having a too high level of indirection. The level of indirection is determined by the path you need to go through in order to get your data from an object (e.g. myObject.a.b.c.myData). Too many occurrences of this pattern generally decreases readability of the code, especially when indirection layer names are not meaningful. It may also reveal a lack of Oriented-Object encapsulation.
5362

CAST Recommendations

CAST recommends reducing the level of indirection when possible, whether by creating a variable that accesses to intermediate levels or by using Getters.

How we detect

This Code Insight counts the level of indirection found in operands.
5362

About CAST and Highlight’s Code Insights

Over the last 25 years, CAST has leveraged unique knowledge on software quality measurement by analyzing thousands of applications and billions of lines of code. Based on this experience and community standards on programming best practices, Highlight implements hundreds of code insights across 15+ technologies to calculate health factors of a software.