Eclipse count lines of code

后端 未结 10 1027
孤城傲影
孤城傲影 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: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.

提交回复
热议问题