Explicit return in __init__ is Unproductive
This code insight counts one violation each time a return statement is encountered in a __init__ method.
Why you should care
__init__ is a special Python method that is automatically called when memory is allocated for a new object. The sole purpose of
__init__ is to initialize the values of instance members for the new object. Using
__init__ to return a value implies that a program is using
__init__ to do something other than initialize the object. This logic should be moved to another instance method and called by the program later, after initialization.
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.