Empty and Implicit Returns cause resiliency issues.
This code insight Counts one violation each time a function has at least one significant return (expression different from nothing, none or false) and in the same time :- at least one empty return OR
- an implicit return in place of the last statement.
Why you should care
Be consistent in return statements. Either all return statements in a function should return an expression, or none of them should. If any return statement returns an expression, any return statements where no value is returned should explicitly state this as return None , and an explicit return statement should be present at the end of the function (if reachable).Business Impacts
[nz_btn text="Production Risk" target="_self" animate="false" animation_type="ghost" color="pink" size="small" shape="rounded" type="normal" hover_normal="opacity" hover_ghost="fill" link="http://casthighlight.wpengine.com/category/product/indicators-methodology/innovation/" icon="icon-office"]CAST recommendations
References
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.
For reference only. For the complete details please refer the original article
https://doc.casthighlight.com/alt_unsignificantreturn-avoid-empty-and-implicit-return/
https://doc.casthighlight.com/alt_unsignificantreturn-avoid-empty-and-implicit-return/
Comments