From: stt@houdini.camb.inmet.com (Tucker Taft)
Subject: Re: Lines-Of-Code Utility?
Date: 1998/11/04
Date: 1998-11-04T00:00:00+00:00 [thread overview]
Message-ID: <F1wMEB.J78.0.-s@inmet.camb.inmet.com> (raw)
In-Reply-To: Auij4FgA#GA.64@samson.airnet.net
joecool (nobody@nowhere.com) wrote:
: Does anyone know if there is a utility that will run on NT 4.0 that can be
: run in batch mode to generate a report on the lines of code contained in Ada
: source files located within a directory tree (that is, it needs to
: recursively look for Ada source within a dir tree)? And if so, what is it
: capable of doing?
See below for an (n)awk script we use.
It counts totally blank lines, lines that consist of only a comment,
and all other lines. This corresponds with our definition of
line-of-code, which is non-comment, non-blank lines.
If you prefer a count of lines with semicolons, this counts
those as well, though because things like "if/elsif" and "case"
only add one semicolon no matter how long they are, our
experience is that semicolon counts are not as useful as lines
of non-comment, non-blank code for sizing development effort.
Of course comments involve some typing effort, but they generally
pay back in ease of debugging and understanding, so a comment
line if anything has a negative correlation with development time.
Similarly, well-placed blank lines can also speed development.
And the usual disclaimer applies that lines-of-code is not
a great indicator of development effort, though it is
generally better than nothing!
: Thanks.
: George
--
-Tucker Taft stt@inmet.com http://www.inmet.com/~stt/
Intermetrics, Inc. Burlington, MA USA
An AverStar Company
-----------------------------------------------
#!/bin/nawk -f
BEGIN {
tcmnt = 0; tsloc = 0; tblnk = 0; tmloc = 0; files = 0;
}
function show(fil,cmnt,sloc,blnk,mloc) {
printf("\nComment lines: %5d\n", cmnt);
printf("Blank lines: %5d\n", blnk);
printf("Ada lines: %5d\n", sloc);
printf("-----------------------\n");
printf("Total lines: %5d ", cmnt+sloc+blnk);
printf(fil, files);
printf("\n");
printf(" semis: %5d ", mloc);
printf("\n");
files++;
}
FNR == 1 { if (fil != "") show(fil,cmnt,sloc,blnk,mloc);
fil=FILENAME;
tcmnt += cmnt; tsloc += sloc; tblnk += blnk;
tmloc += mloc;
cmnt = 0; sloc = 0; blnk = 0; mloc = 0;
}
/;/ { mloc++; }
/^[ \t]*--/ { cmnt++; next; }
/^[ \t\r]*$/ { blnk++; next; }
/^*$/ { sloc++; next; }
END {
show(fil,cmnt,sloc,blnk,mloc);
tcmnt += cmnt; tsloc += sloc; tblnk += blnk;
tmloc += mloc;
if (files > 1)
show("Total for %d files",tcmnt,tsloc,tblnk,tmloc);
}
next prev parent reply other threads:[~1998-11-04 0:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <Auij4FgA#GA.64@samson.airnet.net>
[not found] ` <3642c88c.24407137@news.geccs.gecm.com>
1998-11-02 0:00 ` Lines-Of-Code Utility? joecool
1998-11-04 0:00 ` dewarr
1998-11-05 0:00 ` Marc A. Criley
1998-11-04 0:00 ` dennison
1998-11-05 0:00 ` Martin C. Carlisle
1998-11-04 0:00 ` Tucker Taft [this message]
1998-11-05 0:00 ` Stephen Leake
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox