Calculate the number of lines of code for the source repository
search cancel

Calculate the number of lines of code for the source repository

book

Article ID: 189915

calendar_today

Updated On:

Products

CA Harvest Software Change Manager CA Harvest Software Change Manager - OpenMake Meister

Issue/Introduction

Our customer would like to calculate the number of lines of code for the source repository.
Is there a way to output this info as a CSV file (and compute via pivot table) or get it via a Dashboard report?

Environment

Release : All versions

Component : CA Harvest Software Change Manager

Resolution

There are a couple of things that complicate this idea.  The first is that Harvest stores all the files checked in as "blob" or "raw" data inside the database.  There is no easy way to "look inside a file" while it's checked into the database. So the files would have to be checked out first, even if only to a temporary location.  The second is that in many cases, we would want to identify which files are source code and which are object files, properties files, or other types of supporting data.  No need to try to count lines of code in an exe or jpg file, for example. Usually, this second objective is done by targeting only specific file extensions to be checked out.

So, we would need to check out all the files we designate as source code files, then run some sort of script or app to count the lines in each of those files.  The first part is quickly done with a standard checkout command (or, if your source code is deployed to a server somewhere, it's already checked out there).  For the second part, I googled "program to count lines of code" and got several hits back for scripts, applications, and programs that others have created to do just that.

In the end, it can be done, but not with any out-of-the-box function inside Harvest.