Eclipse count lines of code

后端 未结 10 1039
孤城傲影
孤城傲影 2021-01-29 19:06

I\'ve tried the Metrics plugin and although it\'s nice and all, it\'s not what my boss is looking for. It counts a line with just one } as a line and he doesn\'t wa

相关标签:
10条回答
  • 2021-01-29 19:32

    ProjectCodeMeter counts LLOC (logical lines of code) exactly as you described (only effective lines). it integrates into eclipse as external code metrics tool, it's not real-time though, it generates a report.actually it counts many source code metrics such as complexity, arithmetic intricacy, hard coded strings, numeric constants.. even estimates development time in hours.

    0 讨论(0)
  • One possible way to count lines of code in Eclipse:

    using the Search / File... menu, select File Search tab, specify \n[\s]* for Containing text (this will not count empty lines), and tick Regular expression.

    Hat tip: www.monblocnotes.com/node/2030

    0 讨论(0)
  • 2021-01-29 19:35

    The first thing to do is to determine your definition of "line of code" (LOC). In both your question

    It counts a line with just one } as a line and he doesn't want that to count as "its not a line, its a style choice"

    and in the answers, e.g.,

    You can adjust the Lines of Code metrics by ignoring blank and comment-only lines or exclude Javadoc if you want

    you can tell that people have different opinions as to what constitutes a line of code. In particular, people are often imprecise about whether they really want the number of lines of code or the number of statements. For example, if you have the following really long line filled with statements, what do you want to report, 1 LOC or hundreds of statements?

    { a = 1; b = 2; if (a==c) b++; /* etc. for another 1000 characters */ }
    

    And when somebody asks you what you are calling a LOC, make sure you can answer, even if it is just "my definition of a LOC is Metrics2's definition". In general, for most commonly formatted code (unlike my example), the popular tools will give numbers fairly similar, so Metrics2, SonarQube, etc. should all be fine, as long as you use them consistently. In other words, don't count the LOC of some code using one tool and compare that value to a later version of that code that was measured with a different tool.

    0 讨论(0)
  • 2021-01-29 19:37

    Another tool is Google Analytix, which will also allow you to run metrics even if you can`t build the project in case of errors

    0 讨论(0)
提交回复
热议问题