Why you should care
Global variables should be encapsulated in a class and doing so can make code more productive.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/risk/" icon="icon-office"]CAST Recommendations
References
https://stackoverflow.com/questions/9765942/space-after-function-name-is-wrong[nz_btn text="Style Guide" target="_self" animate="false" animation_type="ghost" color="turquoise" size="small" shape="rounded" type="ghost" hover_normal="fill" hover_ghost="screen" link="https://github.com/Kristories/awesome-guidelines" icon="icon-book"]How we detect
This code insight counts a violation each time there are too many global variables int m_iGlobal = 0; void m() { m_iGlobal = 1; // VIOLATION } Remedy Create a static data member in the appropriate class to replace the global variable.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_applicationglobalvariables-the-code-contains-too-many-implied-global-variables-to-prevent-conflicts-in-global-scope-all-variables-should-be-explicitely-declared-and-if-possible-not-in-global-sco/
https://doc.casthighlight.com/alt_applicationglobalvariables-the-code-contains-too-many-implied-global-variables-to-prevent-conflicts-in-global-scope-all-variables-should-be-explicitely-declared-and-if-possible-not-in-global-sco/
Comments