Why you should care
Certain built-in commands in VB/VB.net bring about unnecessary reliability risk to applications. This unexpected application or machine behavior occurs a result of awkward/unreliable methods of handling errors and interacting with memory - that includes using pointers, forcing garbage collection, unstructured exception handling etc.Business Impacts
The use of certain (unrecommended) built-in commands can increase the likelihood for applications to malfunction and fail in a production environment. Debugging and working with these commands can increase development time significantly.[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"][nz_btn text="Complexity" target="_self" animate="false" animation_type="ghost" color="mulled_wine" size="small" shape="rounded" type="ghost" hover_normal="opacity" hover_ghost="fill" link="http://casthighlight.wpengine.com/category/product/indicators-methodology/innovation/" icon="icon-block"]CAST recommendations
Identifying the built-in functions that can potentially cause reliability issues from the patterns above and encourage developers to seek alternatives to these risky commands. Documentation of most of these identified issues can be easily found online and in the references below.References
https://stackoverflow.com/questions/118633/whats-so-wrong-about-using-gc-collect http://www.vbforums.com/showthread.php?759361-RESOLVED-Need-Full-Understanding-of-VarPtr-StrPtr-ObjPtr https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/resume-statement https://stackoverflow.com/questions/29418248/what-does-the-vb-net-ubound-function-actually-do-and-why-does-the-msdn-document[nz_btn text="Style Guide" link="https://github.com/Kristories/awesome-guidelines" target="_self" icon="icon-book" animate="false" animation_type="ghost" color="turquoise" size="small" shape="rounded" type="ghost" hover_normal="fill" hover_ghost="fill"]How we detect
This code insight follows code which contains “system” and “gc“, count one violation each time “collect (” is encountered. Count one violation each time following patterns are encountered :- objptr
- strptr
- varptr
- ismissing
- as new
- resume
- for … lbound
- to … ubound
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_riskyfunctioncalls-avoid-using-risky-builtins/
https://doc.casthighlight.com/alt_riskyfunctioncalls-avoid-using-risky-builtins/
Comments