Avoid having too many unused variables

Why you should care

Having too many variables that are unused somewhere in your software can make the software consume more memory than it should as the resource is allocated for each declared variable, whether it is use or not during the execution. It also doesn’t help developers get clear view on effectively used variables in a program.

Business Impacts

It is recommended to declare only variables that will be used. At large scale, having a lot of these pattern occurrences could prevent the code from being efficient and cost-effective.

5362

CAST Recommendations

CAST recommends declaring only variables that are effectively used in a program.

How we detect

This Code Insight counts one violation each time a variable 66, 77 or 88 declared in Working Storage section is never used in Procedure Division.
5362

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.