Counting lines of code

Does anyone know a way to count the lines code in a package
excluding comments? The following are commenting styles:
* comment1
-- comment 2
/* comment 3 */
comment 4

CREATE OR REPLACE PROCEDURE count_code(p VARCHAR2) Is
CURSOR c1 IS SELECT * FROM user_source WHERE name=UPPER(P);
l_count number :=0;
l_tot_count number:=0;
comment_flag boolean:=false;
BEGIN
for crec in c1 loop
l_tot_count := l_tot_count+1;
IF substr(trim(crec.text),1,2) not IN ('--','/*') and not
comment_flag THEN
l_count := l_count+1;
ELSIF substr(trim(crec.text),1,2)='/*' THEN
comment_flag := true;
end if;
IF comment_flag and instr(trim(crec.text),'*/')>0 THEN
comment_flag:=false;
end if;
END LOOP;
dbms_output.enable(100000);
dbms_output.put_line('Object
Name : '||p);
dbms_output.put_line('Total number of lines
Code : '||l_tot_count);
dbms_output.put_line('Total number of lines Code with out
comments : '||l_count);
END;
Suresh Vemulapalli

Similar Messages

  • Count lines of code present in methods of a class

    Hi Friends,
    Can anyone suggest how to count lines of abap code in methods of a class?I have used the function module  'SEO_CLASS_GET_INCLUDE_SOURCE' but this function module doesnt counts the code for methods of a class.
    Kindly help.
    Regards
    ST

    Hi siji,
    once try the below info.
    data: itab type table of string.
    data: w_lines type i.
    read report <reportname> into itab.
    describe table itab lines w_lines.
    write: / 'Report lines:', w_lines.
    It is however important to find the exact report name.
    For standard ABAP reports it is easy, it is the name of the report itself.
    For classes and function modules this is somewhat different.
    Correct report name for function modules can be found as follows :
    Use table TFDIR, field FUNCNAME is your function module.
    PNMAME contains the main program name of the function group, not of the function module.
    Function module report can be created as follows PNAME+3 concatenated with 'U' and field INCLUDE.
    Example for the function module RFC_PING this will be
    'LSRFC' + 'U' + 07 = report name LSRFCU07
    Also take a look at the function module FUNCTION_INCLUDE_CONCATENATE
    Hint: lines( ) is a built-in (system class) static function returning the number of lines in a given internal table. You will like it much better than old-fashioned DESCRIBE TABLE statement where you make us of a count variable an need one more statement for the summing up.
    Note:  If you dont want to count blank line and comments, try this code
         delete itab where table_line is initial or table_line(1) = '*'.
           add lines( itab ) to total_linecount.
    Regards,
    Ravi

  • Count lines of code in WDA component

    Is there a way to count the lines of own code (or otherwise measure the "size") in a WDA component on a 7.01 system? Please don't make me go through every single method one by one

    If you load the Web Dynpro Component in SE80 and then choose Web Dynpro Component->Check->Generation Limits, this will give you the load size in bytes of the WD Component. It also has some breakdown liek the number of variables declared.  However nothing that gives you the exact lines of code.
    The source code of all WD methods is stored in table WDY_CTLR_COMPO, so I supposed if if you really needed to you could write a small program to count the number of lines of code or the number of characters.

  • Counting lines in a text/csv file.

    Can you advice me, how I can get the total number of lines in a text/csv file please using java code.
    I will get the text/csv file content in a string variable not as a file.
    EX: string var = "123\n234\n123\n3456\nsdfsd\n" here \n is in the new line.
    for this I have to get the total lines as 5.
    Please advice.
    Thanks.

    Kayaman wrote:
    user12679330 wrote:
    Oh ok.. ignore the last one, Any idea on this please.Count the newline characters like morgarl told you. You're being very difficult to help for such a simple problem.Thats because nobody has posted the code yet dude ;)
    I'm pretty sure that once the OP finally takes the hint and writes the two lines of code needed to solve this question, he'll come up with something that sometimes gives the correct answer and other times gives a count that is one-off.

  • Total number of lines of code in a  project

    Hi All,
    We had developed a project in oracle adf using jdeveloper Version 11.1.1.4.0.Is there any way to find how many lines of code we had wriiten in the entire project.
    Regards,
    Smaran

    Hi,
    NOS stands from Number Of Statements and is a bit different than nloc (line of codes) that is count the statements rather than lines, thus independent from coding styles. As for V(G), it's the cyclomatic complexity, also known as McCabe.
    Regards,
    ~ Simon

  • Count lines in table

    hallow
    i have internal table and i wont to count lines with key
    example
    data
    001
    001
    002
    003
    001
    i wont in some fiels to now how much number of 001 i have here 3
    regards

    Hi Shnya,
    first sort the internal table based on the field that u want to have count...
    Example: lets suppose that the field name itself is data and the internal table name is l_itab and it has the values that u have given in your post...
    Sample code:
    sort l_itab by data.
    loop at l_itab into wa_itab.
      lv_counter = lv_counter + 1.
      at end of data.
      Each time it triggers, lv_counter will be having the *   value for a particular value in data field.. for the *   first time it will be having counter for 001, second *   time 002 and so on...
      write code according to your requirement.. and then *   clear lv_counter...  
      endat.
    endloop.
    Hope this helps u...
    Regards,
    Phani.

  • Error highlighted no lines of code to be corrected just the error code

    When I run the macro I get this error:
    "The attempted operation failed.  An object could not be found."
    The error highlighted no lines of code to be corrected just the error code.
    Dim OLapp As New Outlook.Application
    Dim OLns As Outlook.NameSpace
    Dim Inbox As Outlook.MAPIFolder
    Dim Bills As Outlook.MAPIFolder
    Set OLns = OLapp.GetNamespace("MAPI")
    Set PersonalFolder = OLns.GetDefaultFolder(olPublicFoldersAllPublicFolders)
    Set Inbox = OLns.GetDefaultFolder(olFolderInbox)
    Set BillsFolder = PersonalFolder.Folders("Bills")
    If Inbox.Items.Count = 0 Then Exit Sub
    For iLoop = Inbox.Items.Count To 1 Step -1
    Set obj = Inbox.Items(iLoop)
    If obj.SenderEmailAddress = "[email protected]" Then obj.Move BillsFolder
    Set obj = Nothing
    Next iLoop
    Set BillsFolder = Nothing
    Set PersonalFolder = Nothing
    Set Inbox = Nothing
    Set OLns = Nothing

    Are you sure a folder named Bills exists in the PF store?
    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

  • Counting lines problem. Please help!!

    Hi all,
    I just have a small problem i cannot resolve, here it is: I read through a file and i like to count the lines of the file there is before a special word.
    E.g
    My file contains:
    "hi
    how are you
    my name is john
    and i live
    britain"
    I'd like to count how much lines there are in the file before the word LIVE ==> result would be 4.
    I proceed with StreamTokenizer, but i don't knor how to specify the word. Here is my code:
         try {FileReader fr = new FileReader("test2.dat");
                   BufferedReader br = new BufferedReader(fr);
                   StreamTokenizer stk = new StreamTokenizer(br);
                   do {
                   n = stk.nextToken();
                   li = stk.lineno();
                   if (n == stk.TT_NUMBER) {
                        n = stk.nextToken();
                   if (n == stk.TT_EOL) {
                        li++;
                        n = stk.nextToken();
                   if (n == stk.TT_WORD) {
                        String str = stk.sval;
                        if ("entier".equals(str)) {
                             System.out.println(li);
                        else {
                             n = stk.nextToken();
                   while (??????????????);
    I want here to specify the word "entier" but how to do this??
    Thanks very much for your precious help....

A: Counting lines problem. Please help!!

Use LineNumberReader, which counts lines for you. Here's a complete program in 16 lines:
import java.io.*;
public class test4 {
  public static void main(String[] argv) {
    if (argv.length < 2) { System.err.println("no arg"); System.exit(0); }
    try {
      LineNumberReader in = new LineNumberReader(new FileReader(argv[1]));
      String line;
      while((line = in.readLine()) != null)
        if (line.indexOf(argv[0]) != -1)
          System.out.println("Found match at line " + in.getLineNumber());
    } catch (IOException e) {
      e.printStackTrace();
}If you want case insensitivity, you can make both lines lower-case before searching. Or you can use regular expressions.

Use LineNumberReader, which counts lines for you. Here's a complete program in 16 lines:
import java.io.*;
public class test4 {
  public static void main(String[] argv) {
    if (argv.length < 2) { System.err.println("no arg"); System.exit(0); }
    try {
      LineNumberReader in = new LineNumberReader(new FileReader(argv[1]));
      String line;
      while((line = in.readLine()) != null)
        if (line.indexOf(argv[0]) != -1)
          System.out.println("Found match at line " + in.getLineNumber());
    } catch (IOException e) {
      e.printStackTrace();
}If you want case insensitivity, you can make both lines lower-case before searching. Or you can use regular expressions.

  • Typelag happens in big projects. AKA 38,325 lines of code.

    My machine runs very fast in all other applications, it is a gaming computer that runs Starcraft 2 smoothly on the highest settings.
    I'm writing a very big application in Flash.  It is well on its way to being a MMORPG.  I have hundreds of classes, but my biggest class has really off the charts type lag.  My biggest class is 38,325 lines of code.
    Now every time I type, it tries to highlight words in grey for some reason.  I think every letter I type, it searches the entire 38,325 lines of code for that word in order to highlight all cases of it.
    take a look at this picture and how "hud" is highlighted
    LINK: http://www.goodnewsjim.com/images/slowdown_FB4.png
    As I move the cursor around and edit, I often times get 1-5 seconds of slowdown, sometimes I even get 20 seconds of type lag where the Flash Builder temporarily says "Not Responding in the window bar".  This happens all of the results of me typing letters, moving arrow keys or pressing delete or backspace.
    For small edits, I can wait 20 seconds to edit one word, but when I work a lot on my code, I have to open an external editor like Scite, but the alt-tabbing consumes time, and there is a mouseclick to reload the .as file.  I would like to use Flash Builder 4 for editing my code, after all that is what an IDE should be able to do if anything.  An IDE should at the very least be no worse than a generic text editor.
    Please tell me how I can disable Flash Builder 4 from trying to highlight words in grey. I think this is what is causing my typelag.  I've turned off code hints.

    Anirudh,
    Thank you again for your quick response.
    1) I already disabled Code assist completely in Window -> Preferences -> Flash Builder -> Editors.
    2) Ok, I did toggle mark occurances off.
    The problem still persists.  I still have type lag. 
    ,Jim

  • Total number of lines of code in a class.

    Dear Experts,
    Given a class, I want to find out the total number of lines of code in all of its methods.  Following sub-parts are derived.
    1.  Find out all the methods of the class
    2.  Find out the number of lines for each of these methods and finally add the total number.
    Can you kindly let me know how I can do this?  Thanks a lot !
    Best Regards, Vikram

    Be aware that a 2D array is an array of arrays, which don't necessarily have to be the same length. e.g.int[][] a = new int[2][];
    a[0] = new int[10];
    a[1] = new int[20];
    /* a.length == 2
       a[0].length == 10
       a[1].length == 20*/

  • White lines of code on black background upon starting up

    I recently sent my Macbook in due to problems with the screen going dark for no reason. Upon recieving the laptop back, I noticed problems upon starting. When I restart my laptop, there are white lines of code on a black background. I called in to support, but my support expired and here I am searching for help. They told me that I needed to try and reset my drivers, or my HDD is bad. To reset my drivers they gave me a combination of keys to press upon restarting, but I don't remember the combination of keys. I have repaired my disk using the install CD, but still am having problems.
    It's crazy that I send my laptop in and get it back with other problems... Any help is appreciated becuase Apple surely isn't helping.
    Macbook   Mac OS X (10.4.8)   Core Duo w/ Bootcamp

    Turn the computer off. Wait one minute. Restart. If you are still booting into single-user mode (black screen with white print) then at the prompt enter:
    reboot
    Then press return. If this does not start you up into OS X then there's a system problem. You will need to reinstall OS X. You can do this using the Archive and Install option that does not require you to erase the hard drive. Your old system will be archived in a Previous System Folder at the root of the hard drive.
    Before performing the Archive and Install you should do the following:
    Repairing the Hard Drive and Permissions
    Boot from your OS X Installer disc. After the installer loads select your language and click on the Continue button. Then select Disk Utility from the Installer menu (Utilities menu for Tiger.) After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list. In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive. If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported then quit DU and return to the installer. Now proceed with the OS X installation.
    If DU reports errors it cannot fix, then you will need Disk Warrior (4.0 for Tiger) and/or TechTool Pro (4.5.2 for Tiger) to repair the drive. If you don't have either of them or if neither of them can fix the drive, then you will need to reformat the drive and reinstall OS X.
    Why reward points?(Quoted from Discussions Terms of Use.)
    The reward system helps to increase community participation. When a community member gives you (or another member) a reward for providing helpful advice or a solution to their question, your accumulated points will increase your status level within the community.
    Members may reward you with 5 points if they deem that your reply is helpful and 10 points if you post a solution to their issue. Likewise, when you mark a reply as Helpful or Solved in your own created topic, you will be awarding the respondent with the same point values.

  • What is the error in this one line of code!

    s=s-(s/28)*[1-(s/28)*(29/s+1)*(21-q/11)];
    I am using this line of code in my programe but i am getting the following error.
    C:\shahzad\Easter.java:28: illegal start of expression
    s=s-(s/28)*[1-(s/28)*(29/s+1)*(21-q/11)];
    Please help me solvingg this problem
    thanks.

    s=s-(s/28)*[1-(s/28)*(29/s+1)*(21-q/11)];
    [] brakets ae used to index arrays, are you using an array somewhere????
    arr=5; for example....
    in either event youl need to make changes.
    assuming no array is involved simply change [] to ()
    if still causing problems try adding extara()
    s= (s-(s/28))*( (1-(s/28)) * ( (29/s)+1) * (21-(q/11)) );

  • Thousands of blank lines in code view? Where did they come from?

    I have an older DW site, that for some reason when I open certain pages in code view show literally thousands of blank lines.  So line 1, code, line 2-15 are blank, then what used to be line 2 of the code, is now line 16. All the way down the line.  This one page literally has THOUSANDS of blank lines in it:
    Aurora Prom Corsages, Boutonnieres, Flowers, School Dance Flowers-Yorkville, Osego Illinois
    page renders, edits and looks fine in DW, browsers, etc. 
    My client edits it with Contribute. I use DW.
    There are certain pages he opens regularly, never saw the lines, other pages, just opens once a year, lines all over again.
    We can't find any rhyme or reason to it.
    Has anyone ever seen this?

    Try opening one of those pages in DW and then go to Commands > Apply Source Formatting and see if that cleans them out.
    I've heard of a bug where adding html comments can cause added blank lines in certain versions, I've never seen it myself though.

  • ABAP Methods _ 50 lines of code or less recommendation

    Hi,
    I'm looking for a document that I recall seeing that recommends that an ABAP method should have only around 50 lines of code. Can anyone recall this document and where to get it? Not sure if it was a blog or pdf paper by someone.
    Thanks,
    Ken Murray

    Hi,
    Please refer link and page number 8.
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/4fbafc9e-0e01-0010-dea9-9d23d1b269fb
    Generally, limited lines are useful for effective modularisation and easier maintanance.
    Thanks,
    Chetan Shah

  • Is it too much lines of code inside a class file?

    Hi,
    I was wondering about how many lines can be considered too much in a java class file. I saw some class files with more the two thousand lines of code and even more than three thousand lines. When we have so many lines in the code I've realized that the file becomes slow for edition and it's not readable as it should be. So, as a best practice, or even due to technical issues, in average how many lines of code we'd write in order to keep the readability and avoid compile and build issues? How many lines a class should have without putting our code and performance at risk ?
    thanks a lot

    My general rule of thumb--in a class everything shold be very consistent, that is to say: you should be focusing on 1 idea in your class. IMO: If you have a class for users, you need to consistent in just what that class does. When the class becomes large, then look for related themes that run through methods of that class, and if here are many, you should make a "related class" that does satelite functions of the "core" offered in the main user class.
    Thousands of lines do not a good class make, I break in to related categories of classes long before then, and as a rule I keep under 500 lines in a class--usually under 300. In any case, no more lines of code need go into a class than that to implement the core features in the main idea for that class--and no less lines of code than is needed too, don't religate a method to another class just becasue you feel it would make the class it belongs too big.
    Along the idea of the user class:
    Storage for the user data
    Home information
    Work information
    physical information
    tastes and preferences
    family
    and etc
    all of these could be a class in and of themselves, but definetely are closely related to the user class.

  • Maybe you are looking for

    • Mouse cursor disappears in GNOME 3.2

      Hi all, I have been having this issue recently with GNOME.  I never had this problem in Gnome 3.0 before i upgraded, but now I'm having it almost every day.  After the screen turns off, i can't get a mouse cursor anymore. I can see things react when

    • CPIC-CALL: 'ThSAPCMRCV'

      Hi All, During the implementation of support packages on our new Solution Manager 4.0, we get the following error during the 'import proper': Error RFCIO_ERROR_MESSAGE in abrfcio.c : 1801    > RFC MESSAGE/ERROR : 104 RFC_ERROR_SYSTEM_FAILURE CPIC-CAL

    • EXC_BAD_ACCESS...What is it and what is it doing in my program?

      As a basic exercise, I was working on this function: void PrintIntrospectionInfo () // function definition for section 4 // code for printing "introspection info" NSString *s1 = [NSString stringWithString: @"Assignment"]; NSString *s2 = [NSString str

    • The last version had a bar where you could download and play, its gone

      On the last mozilla firefox I had a bar at bottom of screen with a download and player function for downloading videos etc. Its now gone since I downloaded new version

    • How do you add minimal numbers in a loan form?

      How do you add minimal numbers in a loan form as in: http://screencast.com/t/KcE65bHCG?