Code Count - Scans Libraries and Objects to Report Code Metrics

John Fauss
CODE AUTHOR
Posts: 11
 1 month 2 weeks ago -  4 weeks 2 days ago #626 by John Fauss
John Fauss created the code: Code Count - Scans Libraries and Objects to Report Code Metrics

The Code Count utility is a small, single-window app that scans the objects in any or all of the libraries within a Workspace Target or Solution Project and produces reports which tell you several metrics about the source code, such as:

 

  • The name of each object
  • The date and time when each object was modified.
  • The size of each object (as reported by PowerBuilder).
  • The total number of source lines in each object, and a breakdown of lines of code, comment lines and empty lines.
  • The number of events in each object.
  • The number of functions in each object.
  • The number of subroutines (functions that do not return a value) in each object.
  • The number of external function declarations in each object.
  • The descriptive comment property of each object.

 

The utility was developed and tested using PB 2017, but it has also been successfully tested in PB versions 2019, 2021, 2022 and 2025. Regardless of which version you use to run and/or build the Code Count utility, it can successfully scan application code in either Workspace or Solution formats from any Appeon-provided version of PowerBuilder. The scanning of libraries from versions of PowerBuilder preceding version 2017 has been tested successfully in a very limited manner, so I am unable to state that it will always work on pre-2017 libraries.

 

Here's a screen shot of the Code Count window:

 

Code Count application window

 

You have the ability to select any or all of the ten PowerBuilder object types:

 

Code Count object type selection

 

If you are not concerned about determining line count metrics, you can disable the collection of object size and/or line counts. Scans run markedly faster when line counts are disabled. You can choose from several report views or switch views after a scan has completed. The views by Object Type are useful in determining the total number of each type of object within the selected libraries. For example, if you wish to quickly determine the number of DataWindows in your application, uncheck all object types except for "DataWindow", uncheck the "Lines of Code" checkbox (shown below), and select all libraries.

 

Code Count scanning and report options

 

Click the "Target..." command button to choose the Workspace Target or Solution Project to be scanned. After the target or project has been selected, a list of all of the libraries in its Library List are shown:

 

Code Count library selection list

 

All libraries in the target or project are selected automatically. Extended row selection (example shown above) actions are supported, such as (Ctrl+click) to select/de-select a single row and (Ctrl+Shift+click) to select/de-select a range of rows. When some or all libraries are not selected, the "Select All" button will ensure all libraries are selected. This button changes to "Unselect All" when all libraries are selected.

 

An example of the "PBL and Object type (without comments)" report view is shown in the full window snapshot.

 

Below the report are command buttons to (1) save the report data in one of PowerBuilder's supported formats, (2) print the report, and (3) close the application.

The status area to the right of the Print button shows which library and object is being scanned while the scan runs. The status area displays a scan summary when the scan has finished, as shown below:

 

Code Count report actions and status area

 

I hope you find the Code Count utility useful. Your feedback is welcomed and appreciated!

 

This message has an attachment file.
Please log in or register to see it.

Last Edit: 4 weeks 2 days ago by  Aubrey Lin @Appeon

Please Log in or Create an account to join the conversation.

John Fauss
CODE AUTHOR
Posts: 11
 11 hours 37 minutes ago #634 by John Fauss
John Fauss replied the code: Code Count - Scans Libraries and Objects to Report Code Metrics

Thank you, Ludek, for letting me know about these issues!

In regards to the first issue where the comment line was flagged, would it be possible for you to provide the exported source for this Function object? If not, could you at least provide me with a portion of exported source around the line that was mentioned in the error? I really need to be able to see where this comment line appears in relation to other code blocks within the exported source in order to properly diagnose and correct the issue.

As for the second error, it would be helpful to know if the 2025 application code is in Workspace/pbl's format or in a Solution/file format. In the meantime, I will look into this error to try and determine what caused the array boundary to be exceeded.

Please Log in or Create an account to join the conversation.

Ludek Nesnidal
Posts: 1
 14 hours 46 minutes ago -  14 hours 43 minutes ago #633 by Ludek Nesnidal
Ludek Nesnidal replied the code: Code Count - Scans Libraries and Objects to Report Code Metrics

This is great tool, however while testing on my project it reported some errors (17 in total) ...

 

And while testing on other project written in PB2025 got this ...

 

 

Other that this it works nicely.

THX

Last Edit: 14 hours 43 minutes ago by  Ludek Nesnidal

Please Log in or Create an account to join the conversation.

John Fauss
CODE AUTHOR
Posts: 11
 1 month 4 days ago -  4 weeks 2 days ago #631 by John Fauss
John Fauss replied the code: Code Count - Scans Libraries and Objects to Report Code Metrics

Thank you, David! You're probably right, as the Print command button was a late addition to the window. I'll check and make the fix. 

 

I've also incorporated the use of a blob with the LibraryExport PowerScript function, so as to be able to successfully create exported syntax strings having a length in excess of 32K. I'll get that in a refresh of the app as well.

 

* Updated 2025-Dec-29 *

The original app has been updated with the minor fixes/improvements listed above.

Last Edit: 4 weeks 2 days ago by  John Fauss

Please Log in or Create an account to join the conversation.