eclipsemetricsline-count

Eclipse count lines of code


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 want that to count as "its not a line, its a style choice". I also need to generate some form of report about the metrics provided. Are there any good tools for this?


Solution

  • Install the Eclipse Metrics Plugin. To create a HTML report (with optional XML and CSV) right-click a project -> Export -> Other -> Metrics.

    You can adjust the Lines of Code metrics by ignoring blank and comment-only lines or exclude Javadoc if you want. To do this check the tab at Preferences -> Metrics -> LoC.

    That's it. There is no special option to exclude curly braces {}.

    The plugin offers an alternative metric to LoC called Number of Statements. This is what the author has to say about it:

    This metric represents the number of statements in a method. I consider it a more robust measure than Lines of Code since the latter is fragile with respect to different formatting conventions.

    Edit:

    After you clarified your question, I understand that you need a view for real-time metrics violations, like compiler warnings or errors. You also need a reporting functionality to create reports for your boss. The plugin I described above is for reporting because you have to export the metrics when you want to see them.