Using "is" for anything but singleton can increase costs
Count one violation each time one of the operand of is (or is not) is not None, True or False.Why you should care
Testing the identity of two objects can be achieved in python with a special operator calledis. Most prominently it is used to check whether an variable points to None. But the operator can examine any kind of identity. This often leads to confusion because equality of two different objects will return False .
forgiveness : As some exception can be tolerated, a few percentage of "is" for checking identity of two objects other than singleton should be allowed in the model.
Business Impacts
It is recommended to avoid these in order to ensure the code is more readable and cost effective.
[nz_btn text="Cost" target="_self" animate="false" animation_type="ghost" color="green" 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
https://www.quantifiedcode.com/knowledge-base/readability/%60not%20...%20is%60%20used%20instead%20of%20%60is%20not%60/4ORGpHyxAbout 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_instanceof-avoid-using-is-for-anything-else-than-singleton/
https://doc.casthighlight.com/alt_instanceof-avoid-using-is-for-anything-else-than-singleton/
Comments