How can I generate LoC (line of code) metrics for my Delphi (pascal) project? Is there a built-in way to do this?
-
5Delphi contains a built in tool to generate these things, and I edited this question so it is not asking for a recommendation, but rather a way to accomplish a task, which is on topic. This question is valuable and should not be closed (on hold), especially not 4 years after it was asked. StackOverflow continues to head down the over-mod road. Nice. – Warren P May 21 '14 at 12:58
-
nloc.sourceforge.net - works with Pascal (and alike) and C++ – Gabriel Jun 13 '19 at 11:23
8 Answers
I don't use them. LOC metrics have one problem: they encourage writing code like this.

- 5,475
- 1
- 22
- 29
-
1Mason, thank you for the link! What a great way for a software pro to beat a stupid system. – azheglov Sep 14 '09 at 14:59
-
@azheglov Only if you're paid by the number of lines.. and who does that. – Tony_Henrich Apr 03 '15 at 21:00
-
There are multiple reasons for which you want to know the SLOC. You are only enumerate one. So, your answer is from a limited point of view. You wouldn't want anyway to work in a company that pays you by line of code. – Gabriel Jun 13 '19 at 11:20
Recent Versions of Delphi, from Pro and Up, include some basic metrics, including LOC metrics, and other similarly useless metrics, as built in feature. Enterprise and Architect include a larger set of metrics, and audits.
Notably the results are displayed in an inscrutable mess of a grid, with no help and no hints.
In fact, there's nothing in the help to help you either. However before you run the metrics, there is some description of what the various cryptic things mean, here is a list of the free built in ones:
CIW - Class Interface Width
LOC - Lines of Code
NAM - Number of Accessor Methods
NOA - Number of Attributes
NOC - Number of Classes
NOIS - Number of Import Statements
NOM - Number of Members
NOP - Number of Parameters
NOPA - Number of Public Attributes
PIS - Package Interface Size
PS - Package Size

- 65,725
- 40
- 181
- 316
You can generate Line of Code metrics using Pascal Analyzer as well as many other metrics, and hints (lint) style information.
Delphi itself also has a built-in metric feature, including LoC, in Pro and higher skus.

- 65,725
- 40
- 181
- 316

- 7,110
- 4
- 42
- 64
-
Thanks to everyone, this seems to be a good metrics tool. Gotta check it out. ps. and yes LoC measuring alone is a useless metric. Though one justs wants to learn how big it is(!), for vanity you know :) – utku_karatas Sep 14 '09 at 17:08
-
Pascal Analyzer is a commercial tool. It can analyze single files or projects, but not directory contents. [Migrated 3 year old answer to this comment] – Thomas Weller May 21 '14 at 13:16
SourceMonitor calculates a series of metrics and among others there is LOC. Besides C++, C, C#, VB.NET, Java, VB6 it works for Delphi too.

- 7,087
- 2
- 36
- 44
Don't use it because it's an old, useless metric.
-
It's not intended to be a metric of Developer Productivity but it can be a way of figuring out which units might be too large and might need a bit of breaking down. Large is not good, it's bad. – Warren P Nov 20 '17 at 20:32
-
1It is not a useless metric because we are short of better alternatives. However, it shouldn't be used wrongly because it could be cheated. – magallanes Mar 11 '18 at 03:22
Build-All, then note down the approximate number of lines.
Unfortunately this metric isn't very useful other than to possibly impress non programmers where a large statistic thrown out can make the department look impressive. The reality is that a ten thousand line program can be five times more complex than one in the tens of millions. Its not the lines of code that make the product, its the engineering that put the lines together.

- 15,366
- 2
- 36
- 53
CodeHealer gives you lots of different metrics, including lines of code.

- 15,076
- 6
- 55
- 70
-
Sadly code-healer's authors have no interest in updating it for proper support for XE5 and XE6, so let's call it dead, Jim. – Warren P May 21 '14 at 13:01
-
That would be a shame. CodeHealer points out some really sneaky code problems. – Bruce McGee May 21 '14 at 16:40
-
1They've announced support for Delphi 10, Berlin and Tokyo. So @WarrenP and Bruce, apparently they are updating it. – LMSingh Nov 20 '17 at 19:59
-
2While they are at it can they fix their dumb "let's break on purpose each time the new delphi version is released until you buy it again from us, but hey, we didn't feel like releasing an update, so sorry, you're hooped" philosophy? Unlike CodeHealder, Pascal Analyzer keeps working by default when a new Delphi version ships. – Warren P Nov 20 '17 at 20:30
-
@WarrenP some business models are just destined to bomb themselves. – Sherlock70 Nov 29 '18 at 10:52