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*/

Similar Messages

  • 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

  • Total Number of line items in FBL3N

    Hi,
    I would like to have total number of open items (entries) as on  12/31/2008 for all B/S accounts. I just want the number.
    I can go in BSIS and click on number of entris but I have 1000's of Gl account to know the total number of line item.
    Is there any way I can get the number of open entries for too many GL account.
    -JR

    Hello
    In the selection parameters choose / enter all open item managed B/S GL accounts and choose the report as below
    1 GL Account Balances (Totals & Balances )             S_ALR_87012301
    3.  GL Line Items                                        S_ALR_87012282
    4.  Statements for GL Accounts, Customers & Vendors      S_ALR_87012332
    5.  Document Journal                                     S_ALR_87012287
    6.  Compact Document Journal                             S_ALR_87012289
    7.  Line Item Journal                                    S_ALR_87012291
    8.  Display of Changed Documents                         S_ALR_87012293
    9.  Invoice Numbers assigned Twice                       S_ALR_87012341
    10. Gaps in Document Number Assignments                  S_ALR_87012342
    11. Posting Totals Document Type wise                    S_ALR_87012344
    12. Recurring Entry Documents                            S_ALR_87012346
    Reg
    suresh

  • How can i know total number of lines in a smartform page?

    Hello All,
    1. How to find the total number of lines that can be printed on a smartform page?
    2. Need to determine the current line on which the text is goint to printed
    Depending upon the no of lines left for printing i need to call a new page explicitly?
    Answers will be rewared...
    Thanks and Regards,
    Josin George
    Edited by: Bhuvaneswari Mathuraiveeran on Jan 1, 2009 1:02 PM

    hi ,
    I think u have to decide no of lines by trial error menthod only ...
    u can use SY-TABIX  to decide , which line its printing ...
    hope its helps .....

  • Total no of lines of code

    Hi,
    How to find the total no of lines of code in plsql.
    is there any sql query.
    Reg.
    aak.

    So, I am truly curious ... what would this be used for?Me too! However a little story unrelated to oracle. A friend of mine is a translator and he charges per sentence translated. Maybe the programmer is a freelancer that charges per line of code! lol

  • BPM: How to return the total number of lines in Multiline Container Element

    Hi all:
    I am trying to follow the following blog to do message splitting:
    /people/narendra.jain/blog/2005/12/30/various-multi-mappings-and-optimizing-their-implementation-in-integration-processes-bpm-in-xi
    In the blog, total number of messages for Message1 was returned to Count in Message 2.
    If I do not want to create message 2, if there any way to return total number lines in multiline elements ? Because this number need to be used to specify in loop condition:
    While Indxe != TotalNumberOfLines
    Thanks
    Liang

    Hi, Matias:
    For the loop block option, your answer is passing message count in different message type is best option !
    I really do not know why SAP does not deliver a build-in function to return the number of items in multiline element at run time ?
    Now the question for the second option: ForEach block:
    When I leave current line of block properties empty, the compile does not pass
    I have to input a another element (Var_Cur) in current line
    Inside my block, I have one send step, it will send Var_Dest[Index],  followed by a container operation step to increment Index by 1.
    With above setup, I compile it, compile passed, but it says:
    "Container Element Var_Cur in Step Block1 is initialized but not used"
    then I added another containter operation step in block:
    Var_Cur = Var_Dest[Index]
    I modified send step to send Var_Cur rather than Var_Dest.
    Up to now, I can compile it without any warnings.
    But when I send message to IE, the message pass pipe line, but it seems does not pass the BPE.
    When I go to SXI_CACHE, to check the return code for my Integration process is 0, means no error.
    But my message does not reach my target system.
    Where do you think I made wrong ?
    Thanks
    Liang

  • Add a count to an ALV grid of the total number of lines

    Hi There
    I have a really long ALV report which prints lots of records. How can I add a total number of records count to appear in the header?
    I use the Grid display function to call the ALV grid.
    Any help appreciated

    Hi,
    You can do as below :
    call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program      = gd_repid
                i_callback_top_of_page   = 'TOP-OF-PAGE'  "see FORM
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
                i_save                  = 'X'
           tables
                t_outtab                = it_ekko
           exceptions
                program_error           = 1
                others                  = 2.
    * Form  TOP-OF-PAGE                                                 *
    * ALV Report Header                                                 *
    Form top-of-page.
    *ALV Header declarations
    data: t_header type slis_t_listheader,
          wa_header type slis_listheader,
          t_line like wa_header-info,
          ld_lines type i,
          ld_linesc(10) type c.
    * Title
      wa_header-typ  = 'H'.
      wa_header-info = 'EKKO Table Report'.
      append wa_header to t_header.
      clear wa_header.
    * Date
      wa_header-typ  = 'S'.
      wa_header-key = 'Date: '.
      CONCATENATE  sy-datum+6(2) '.'
                   sy-datum+4(2) '.'
                   sy-datum(4) INTO wa_header-info.   "todays date
      append wa_header to t_header.
      clear: wa_header.
    * Total No. of Records Selected
      describe table it_ekko lines ld_lines.
      ld_linesc = ld_lines.
      concatenate 'Total No. of Records Selected: ' ld_linesc
                        into t_line separated by space.
      wa_header-typ  = 'A'.
      wa_header-info = t_line.
      append wa_header to t_header.
      clear: wa_header, t_line.
      call function 'REUSE_ALV_COMMENTARY_WRITE'
           exporting
                it_list_commentary = t_header.
    *            i_logo             = 'Z_LOGO'.
    endform.
    Thanks,
    Sriram Ponna.

  • How to Access Total Number Of Pages inside code

    Hi All,
    I would like to get the total number of pages in the report,inside the trigger.
    How can i access this value inside code.
    Pls Help me
    Thanks and Regards
    Binu

    I think this is not possible inside the code, because this value is deteremined after the code is executed and during the formatting of the report.

  • 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.

  • How many number of lines of code Java File can have?

    Hi ALL
    Is there any limit on java source file code length?
    does more code (say more than 4000 line) impact on performace?
    Is there any recomendation on code length and file size?
    Thanks

    Hi ALL
    Is there any limit on java source file code length? There are some (VM) limitations but I have only hit that one when I had some generated code.
    does more code (say more than 4000 line) impact on
    performace?No, but you probably have a stupid design if you have 4000 lines in one file.
    Is there any recomendation on code length and file
    size?You should usually only have one top level clas per file, and you should try to have less than 1000 lines in one class.
    Kaj

  • Want to know the number of lines executed in my code

    Hi,
        I want to know the total number of lines of code executed by Flex in my application which includes the code generated while converting mxml to .as .Like for example with help of Trace class.

    Hi,
    Please go through following links which i am providing :
    1) http://www.adobe.com/devnet/flash-builder/articles/ascode-coverage.html
    2) http://opensource.adobe.com/wiki/display/flexpmd/FlexPMD
    3) http://opensource.adobe.com/wiki/display/flexpmd/FlexMetrics
    Thanks and Regards,
    Vibhuti Gosavi | [email protected] | www.infocepts.com

  • Finding the number of lines of a project in Eclipse

    Not strictly a java question, but does anyone know how you can get the total number of lines of code in a java project in eclipse?
    Kind regards,
    Eskil

    What operating system are you using? Unix has easy ways of counting line numbers in files (and will also give the total). For example, the "wc" command. Of course, that is just physical lines. Often when you count SLOC (source lines of code), you count lines differently from physical lines (e.g., you might ignore blanks or comments [and/or report them separately], or you might split statements up differently from the way they are formatted on physical lines).

  • Total number lines, in an alv (REUSE_ALV_GRID_DISPLAY)

    Hi,
    i want to know, if it´s possible to show the total number of lines displayed in an alv. I´not not sure if that, is an event of the table gt_events[] (maybe the end_of_list one???)
    I would like to show this total, like an status message...
    Thanks in advance
    Carles

    report  ztest_alv1                              .
    type-pools: slis.
    data:
      ls_fieldcat type slis_fieldcat_alv,
      lt_fieldcat type slis_t_fieldcat_alv,
      lt_sort     type slis_t_sortinfo_alv,
      ls_sort     type slis_sortinfo_alv.
    data: v_line type i,
          lines(3) type c.
    DATA: GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.
    data: it_events type slis_t_event,
          x_events type slis_alv_event.
    data: begin of itab occurs 0,
           vbeln like vbak-vbeln,
           posnr like vbap-posnr,
          end of itab.
    itab-vbeln  = '12345'.
    itab-posnr = '10'.
    append itab.
    clear itab.
    itab-vbeln = '12345'.
    itab-posnr = '11'.
    append itab.
    clear itab.
    itab-vbeln = '12345'.
    itab-posnr = '12'.
    append itab.
    clear itab.
    itab-vbeln = '12356'.
    itab-posnr = '10'.
    append itab.
    clear itab.
    itab-vbeln = '12356'.
    itab-posnr = '11'.
    append itab.
    clear itab.
    itab-vbeln = '12356'.
    itab-posnr = '12'.
    append itab.
    clear itab.
    describe table itab lines v_line.
    lines = v_line.
    PERFORM E04_COMMENT_BUILD  USING GT_LIST_TOP_OF_PAGE[].
    x_events-name = 'TOP_OF_PAGE'.
    x_events-form = 'TOP_OF_PAGE'.
    append x_events to it_events.
    call function 'REUSE_ALV_FIELDCATALOG_MERGE'
      exporting
        i_program_name         = sy-repid
        i_internal_tabname     = 'ITAB'
        i_inclname             = sy-repid
      changing
        ct_fieldcat            = lt_fieldcat
      exceptions
        inconsistent_interface = 1
        program_error          = 2
        others                 = 3.
    if sy-subrc <> 0.
      message id sy-msgid type sy-msgty number sy-msgno
              with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.
    ls_sort-fieldname = 'VBELN'.
    ls_sort-up        = 'X'.
    *ls_sort-group = 'UL'.
    append ls_sort to lt_sort.
    clear ls_sort.
    ls_sort-fieldname = 'POSNR'.
    ls_sort-up        = 'X'.
    *ls_sort-group = '*'.
    append ls_sort to lt_sort.
    call function 'REUSE_ALV_GRID_DISPLAY'
      exporting
        it_fieldcat = lt_fieldcat
        it_sort     = lt_sort
        it_events   = it_events
      tables
        t_outtab    = itab.
    FORM E04_COMMENT_BUILD USING E04_LT_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.
      DATA: LS_LINE TYPE SLIS_LISTHEADER.
      CLEAR LS_LINE.
      LS_LINE-TYP  = 'S'.
      LS_LINE-KEY  = 'NO of lines'.
      LS_LINE-INFO = lines.
      APPEND LS_LINE TO E04_LT_TOP_OF_PAGE.
    ENDFORM.
    * FORM TOP_OF_PAGE *
    form top_of_page.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
           EXPORTING
                I_LOGO             = 'ENJOYSAP_LOGO'
                IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.
    endform.                    "top_of_page
    check this code..
    regards
    vijay

  • Total no. of lines in JTextPane document and Increment them on "ENTER" key

    hello,
    I wanted to know the total number of lines that a document has. I.e for example when I open a .java into my JTextPane, I wanted to know the total no. of lines the file has and I wanted to increment them when I press the enter key.
    2. Even it is a plain document, i.e just typing in the JTextPane and when I press enter key the number of lines should get incrementing.
    I am using this method , but un successful. Can any one help me?
    public int getLines()
              Document doc = text.getDocument();
              Element map = doc.getDefaultRootElement();
              int n = map.getElementCount();
              Element lastLine = map.getElement(n-1);
              if ((lastLine.getEndOffset() - lastLine.getStartOffset()) > 1)
                   return n;
              return n - 1;
    where text = JTextPane
    Any example source will be helpful.
    Thanks

    Your code looks correct. Here is the program I used to test it. You must be calling the getLines() method BEFORE the document is being updated.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.text.*;
    public class TestTextArea extends JFrame
         public TestTextArea()
              JPanel panel = new JPanel();
              setContentPane( panel );
              panel.setLayout( new BorderLayout() );
              final JTextPane textArea = new JTextPane();
              JScrollPane scrollPane = new JScrollPane( textArea );
              panel.add( scrollPane );
              JButton button = new JButton("Display Lines");
              panel.add( button, BorderLayout.SOUTH );
              button.addActionListener( new ActionListener()
                   public void actionPerformed(ActionEvent e)
                        Document doc = textArea.getDocument();
                        Element map = doc.getDefaultRootElement();
                        int n = map.getElementCount();
                        Element line = map.getElement(n-1);
                        if (line.getEndOffset() - line.getStartOffset() == 1)
                             n--;
                        System.out.println( n );
                        textArea.requestFocus();
         public static void main(String[] args)
              TestTextArea frame = new TestTextArea();
              frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
              frame.pack();
              frame.setVisible(true);
    }

  • Count the number of Lines with in a method

    I am trying to write a program that will report back the number of methods/types/names and proxies as well as the number of lines of code in each method... I can not figure out how to count each methods line of code separately thanks. each method is commented by
    /* PROXY proxyname type */
    /* METHOD method name*/
    public class Assignment3
    private static BufferedReader userInput = new BufferedReader (new InputStreamReader (System.in));
         * @param args
         * @throws IOException
         * @param args
         * @throws IOException
         public static void main(String[] args) throws IOException
              System.out.print("Enter the .java file name: ");
         String input = userInput.readLine();
         while (!input.equalsIgnoreCase("stop"))
              System.out.println("Total Number of Lines: " + LOC(input) + "\n" + Method(input) + "\n" + Type(input));
              System.out.print("\nEnter file name to search again or \"stop\" to terminate the program: ");
              input = userInput.readLine();
    public static int LOC(String inputFile) throws IOException, FileNotFoundException
         int numLines = 0;
         try
                        FileReader FileIn = new FileReader(inputFile);
                        Scanner scanLines = new Scanner (FileIn);
                        String line;
                             while (scanLines.hasNext())
                                  line = scanLines.nextLine();
                                  if (line.startsWith("/*"))
                                       numLines--;
                                  else if(!line.equals(" "))
                                       numLines++;
                             FileIn.close();
              catch(IOException IOE)
                   System.out.println("\nFile Not Found!");
                   return numLines;
    public static int MethodLOC(String inputFile) throws IOException, FileNotFoundException
         File FileIn = new File(inputFile);
         Scanner scanLines = new Scanner (FileIn);
         String line = null;
         int methodLOC = 0;
         while(scanLines.hasNext())
              line = scanLines.nextLine();
              if(!line.contains("/*"))
                   StringTokenizer st = new StringTokenizer(line, "\n");
                   methodLOC = st.countTokens();
         return methodLOC;
    public static String Method(String inputFile) throws IOException, FileNotFoundException
         String line = null;
         String name = null;
         String info = null;
         File FileIn = new File(inputFile);
         Scanner scanLines = new Scanner (FileIn);
         while(scanLines.hasNext())
              line = scanLines.nextLine();
         if(line.contains("METHOD"))
              StringTokenizer st = new StringTokenizer(line, " ");
              String proxy = st.nextToken();
              String method = st.nextToken();
              name = st.nextToken();
              info = "Name of Method: " + name;
    return info;
    public static String Type(String inputFile) throws IOException, FileNotFoundException
         String line = null;
         String name = null;
         String info = null;
         String count = null;
         File FileIn = new File(inputFile);
         Scanner scanLines = new Scanner (FileIn);
         while(scanLines.hasNext())
         if(line.contains("PROXY"))
              StringTokenizer st = new StringTokenizer(line, " ");
              String proxy = st.nextToken();
              String method = st.nextToken();
              name = st.nextToken();
              String type = st.nextToken();
              info = "Name of Proxy: " + name + "\n" + "Type of Proxy: " + type;
         count = info;
    return count;
    }

    Iterate through the lines and count the opening and closing curly braces. Whenever you see an opening one, increase the counter, when you see a closing one, decrease the counter. When the counter hits 0 again, you reached the end of the method.
    I assume you know how to count lines while moving through a text line by line.

Maybe you are looking for

  • ITines is not compatible with Windows Vista Ultimate

    I tried 3 times to install (re-install) iTunes 7.3 so I could activate my iPhone. iTunes kept returning a message to uninstall and re-install iTunes, since some unknown piece of software was needed to recognize the iPhone. When will Apple fix this pr

  • How to use   RLB_INVOICE standard print program

    my program is copy of  RLB_INVOICE when i press execute i m not getting any output how can i see print preview by executing print program.

  • CUCM Device Registration Search

    Was curious to know if it is possible to search using CCMadmin to search and see what devices are registered to which subscribers?  I have not found an easy search/filter in call managers UI to find what I am looking for.  All devices should be regis

  • Workflow ECC User name Issue

    Hi ! Work flow Experts! I am triggering work flow from crm to ECC vise versa,I am unable to get Initiator User name it shows only CRM user name (RFC USER). I want to get ECC server User names in CRM. I am running an remote function module  from  ECC

  • IDCS2 Screen Redraw issues

    We're having screen redraw issues when panning and zooming pages. Getting screen anomolies and jittery display performance. It only happens when using InDesign, no other apps exhibit similar issues. PC specs are: WinXP Prop SP2 Dell Optiplex GX620, 2