Topic
3 replies Latest Post - ‏2007-03-18T16:53:18Z by SystemAdmin
SystemAdmin
SystemAdmin
210 Posts
ACCEPTED ANSWER

Pinned topic evaluating comments lines

‏2007-03-07T10:15:13Z |
Hello there,

Are you aware of an open source tool that would be able to calculate the number of comment lines of code in Java (ie : including lines containing both code and comments) ? i would appreciate whether it could drill down to method level, not only to a file level.

I've done a bit a searching, and it turns out that
  • JavaNCSS or SLOCCount do not give this information, only pure lines of code,
  • CCCC, CNCC, are at file level.
  • There are two plugins for famous IDE :
    • Metrics which is heavily dependent on Eclipse (I want to be able to run it using command line, without eclipse)
    • Metrics Reloaded, dependent on IdeaJ closed AST.
  • There are proprietary tools doing it, such as RSM, Krakatau, but I really want to avoid these closed source solutions.

Do you have any suggestion that would calculate comments ?
Thank you for your help.
Best regards,
RV
Updated on 2007-03-18T16:53:18Z at 2007-03-18T16:53:18Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    210 Posts
    ACCEPTED ANSWER

    Re: evaluating comments lines

    ‏2007-03-07T15:33:55Z  in response to SystemAdmin
    JavaNCSS does provide some level of comments reporting-- it'll report JavaDoc comments. It won't report lines that only contain a // style comment (hence NCSS); however, you could easily obtain this number via grep or awk. Doing so won't drill down to method level, but at least provide you an aggregate number for inline comments. Would that help?

    > Hello there,
    >
    > Are you aware of an open source tool that would be
    > able to calculate the number of comment lines of code
    > in Java (ie : including lines containing both code
    > and comments) ? i would appreciate whether it could
    > drill down to method level, not only to a file
    > level.
    >
    > I've done a bit a searching, and it turns out that
    > * JavaNCSS or SLOCCount do not give this information,
    > only pure lines of code,
    > * CCCC, CNCC, are at file level.
    > * There are two plugins for famous IDE :
    > ** Metrics which is heavily dependent on Eclipse (I
    > want to be able to run it using command line, without
    > eclipse)
    > ** Metrics Reloaded, dependent on IdeaJ closed AST.
    > * There are proprietary tools doing it, such as RSM,
    > Krakatau, but I really want to avoid these closed
    > source solutions.
    >
    > Do you have any suggestion that would calculate
    > comments ?
    > Thank you for your help.
    > Best regards,
    > RV
    • SystemAdmin
      SystemAdmin
      210 Posts
      ACCEPTED ANSWER

      Re: evaluating comments lines

      ‏2007-03-07T18:44:23Z  in response to SystemAdmin
      Hello Andy,

      > JavaNCSS does provide some level of comments
      > reporting-- it'll report JavaDoc comments. It won't
      > report lines that only contain a // style comment
      > (hence NCSS); however, you could easily obtain this
      > number via grep or awk. Doing so won't drill down to
      > method level, but at least provide you an aggregate
      > number for inline comments. Would that help?

      Thank you for your answer. My need is currently really at method level. I already made the kind of script you describe at global and file level ;-)

      What I want to do basically, is track down complex methods with not enough internal comments explaining the logic and the algorithm. Therefore Javadoc, located outside a method are out of scope. Let's say we have two methods of the same size, I expect the more complex one to have more comments ! Comments can be both /* */ or // style, on a line by itself or mixed with source code.

      Any leads or clues ?

      Thank you !
      • SystemAdmin
        SystemAdmin
        210 Posts
        ACCEPTED ANSWER

        Re: evaluating comments lines

        ‏2007-03-18T16:53:18Z  in response to SystemAdmin
        If the commenting search is attempting to locate complexity, perhaps you could use a different metric? While not directly related to what you're trying to achieve, you could find complex methods by evaluating CCN or method length. Thoughts?