Question
· Aug 17, 2022

Counting line of code in all classes

Hi Guys,

is there an easy way to count all line of codes in all classes in a namespace ?

I've been asked to give the total lines of code in all our system and we have over 3000 classes, so opening each one of them to check total line would take a long time.

 

Thanks

Product version: Caché 2014.1
Discussion (10)1
Log in or sign up to continue

Seems like a pointless exercise to me. A question to ask is what is the objective for this?

There is a quick way to do this but it depends on how accurate you want the count to be. In the Management Portal, under System Explorer, Classes there is the option to export classes to an external XML file; there is also the option to include/exclude system classes and select individual or all classes.

This will export the classes into an XML file which you can open in a text file editor to get the number of lines. Note though, the XML export adds additional lines for tags to differentiate the code sections so the count will be greater than the actual lines shown when actually editing the code in the usual editor. 

But it could be an option for you.

Hi Rochdi,

If you have a look at class ompare.SourceHandler.Class, in Open Exchange app https://openexchange.intersystems.com/package/ompare.

It has a range of functionality for decomposing classes into their different components.

Extracting functional lines of source code but discarding comments and empty lines.

It could be enhanced to add a counter to method lines extracted in the profile class.

The schedule also happily jumps namespaces to build report information for multiple namespaces in an environment.

Kind regards,

Alex