From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e5cbd8c12c7e53bc X-Google-Attributes: gid103376,public From: stt@houdini.camb.inmet.com (Tucker Taft) Subject: Re: Lines-Of-Code Utility? Date: 1998/11/04 Message-ID: #1/1 X-Deja-AN: 408325797 Sender: news@inmet.camb.inmet.com (USENET news) X-Nntp-Posting-Host: houdini.camb.inmet.com References: Organization: Intermetrics, Inc. Newsgroups: comp.lang.ada Date: 1998-11-04T00:00:00+00:00 List-Id: 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); }