Do you like to get statistics on your code?

Someone asked me if I could add a feature to Arbed to provide some simple stats about a project, such as the number of total lines of code.

I could do better - Arbed’s rich scripting feature allowed me to write a script that collects the code stats in just a few minutes.

Currently, it counts:

  • Total number of methods (including Event handlers)
  • Total number of code lines
  • Total number of comment lines
  • Total number of empty code lines

To try it out, launch Arbed (get the latest beta if you’re using Xojo), open a project of yours in Arbed and then open and run this script:

http://files.tempel.org/Arbed/beta/1.7.0/b18/Statistics.arbs

How does that work for you?

Update: Now it also counts the number of distint lines (i.e. the same line in several methods count as one).

Oh, and here’s the stats of my biggest projects:

  • Find Any File: 20000 code lines (11000 distinct ones)
  • iBored: 19000 code lines (10000 distinct ones)
  • iClip: 26000 code lines (14000 distinct ones)
  • Arbed: 55000 code lines (31000 distinct ones)

Obviously we use http://www.bkeeney.com/rb-code-reports/. Our latest Web Edition consulting project has over 300 WebPages, 250 WebContainers, 150 non-UI classes, and over 97,000 lines of non-comment code. :slight_smile:

Just for perspective if you think Arbed is big & complex

The IDE metrics
Methods: 18744
Code lines: 181979

No wonder we have a hard time finding leaks :stuck_out_tongue:

Yeah, but I’ve been writing all this code by myself :stuck_out_tongue: (oh, not in iClip’s case, there I’ve taken over and only wrote about a third new myself)

Rather than try to prove how big our code is, I’ll just say thanks to both Thomas and Bob for providing the functionality!

Thomas, the script works nicely, but for some reason, I am unable to quite Arbed either from the menu or command key. Must force-quit. Mac OS X 10.8.5,

Thomas, This sounds cool - I tried Arbed for the first time, but it choked on my .rbvcp format project. I emailed you the log.

My apologies for corrupting Thomas’ thread. Was just throwing statistics of one of our really big projects that’s been over a year in development.

Didn’t mean to be snarky, Bob; just (trying to be) amusing…

you might want to enhance this to recognize “.XOJO_XML_PROJECT” as a valid extension… just an idea.

It’s on the list. :slight_smile:

Great addition Thomas! I didn’t realize that I leave too many spaces in my code for ease of reading… :slight_smile: Its nice to see all of the stats built into to Arbed since I use your tool everyday.

Thanks

Dammit. Is this with b18?
Are you on Windows? Others have reported this as well, and some of it was due to leaks, but I thought I’ve found them all.

Would you please do some more tests for me:

  • Can you reproduce it? If you did more than just open the project and run the script, then one of those other steps might be the reason for the issue.
  • Does it happen with other projects as well?

strange… i have the same Mac OSX 10.8.5 and don’t have problem quitting Arbed.

Oh, did Peter write he was using OSX? I should read more carefully. Always getting too excited when hearing about those pesky bugs.

Usually, quitting shouldn’t be a problem. In fact, my app uses “App.Autoquit = true”, and I assume that in Peter’s case all windows are already closed, yet the program won’t quit, right? I’ve seen this happening a few times myself, but there’s simply nothing I can do about it, because my program wants to quit but something in Xojo’s Runtime prevents it. And it’s not like I can just write a bug report that this doesn’t work reliably. I need a reproducible method for this, and then probably spend hours on reducing my code that I can send to Xojo, and then wait another releases or two until it gets fixed. Sigh.

What the difference between “Code lines” and the parenthetical “distinct ones”?

great, it works well :slight_smile:
(Xojo 2013 3.2.1 Binary project Mac OS X 10.8.5)

there is a feature to find unused methods? (and isolate / remove)

Methods: 12833
Code lines: 360739 (153900 distinct ones)

Isn’t this explanation clear?

Distinct lines means lines that are distinct from other lines.

Example:

a = 0 a = 1 a = 0

This containts two distinct lines. Makes sense? If distinct is not the right term, what is?

Dirk, jackpot! :slight_smile:

Olivier, the “find unused methods” has to be put on the back burner after all the work I had to do recently to support Xojo and the constant VCP format changes. It’ll be a while (months) before I get back to it, I’m afraid.