Eclipse counts lines of code

I tried the Metrics plugin , and although that’s good and that’s all, this is not what my boss is looking for. He counts a string with only one } as a string, and he doesn't want this to be considered "his not a line, her choice of style." I also need to generate a performance report. Are there any good tools for this?

+85
eclipse metrics
Aug 03 2018-11-11T00:
source share
9 answers

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

You can adjust code line metrics by ignoring blank lines and only comment lines, or excluding Javadoc if you want. To do this, check the tab in Preferences -> Metrics -> LoC .

What is it. There is no special option to exclude curly braces {} .

The plugin offers an alternative metric for LoC, called the Number of applications . About this, the author should say about this:

This metric represents the number of statements in a method. I find this a more reliable measure than lines of code, as the latter is fragile in relation to various formatting conventions.

Edit:

After you clarified your question, I understand that you need an idea of ​​real-time violations, such as compiler warnings or errors. You also need a reporting feature to create reports for your boss. The plugin described above is intended for reports because you must export indicators when you want to see them.

+82
Aug 03 2018-11-11T00:
source share

There is always "brute force":

  • Search-> File

  • Type the following into "Contains Text" → ^.*$ . Then check the box next to Regular Expression

  • Type the following into Filename Templates → *.java

  • Click Search

  • Check the number of matches on the Search tab.

+200
Apr 15 '13 at 11:50
source share

If on OSX or * NIX use

Get all actual java code lines from * .java files

 find . -name "*.java" -exec grep "[a-zA-Z0-9{}]" {} \; | wc -l 

Get all lines from * .java files that include empty lines and comments

 find . -name "*.java" -exec cat | wc -l 

Get the information in the file, this will give you [file path + "," + number of lines "

 find . -name "*.java" -exec wc -l {} \; 
+19
Aug 16 2018-12-12T00:
source share

Another way would be to use another loc utility, for example LocMetrics .
It also lists many other search tools . Integration with Eclipse would not always be there (as it would be with Metrics2 , which you can check because it is later than Indicators ), but at least these tools can be justified in terms of logical strings (calculated by summing endpoints semicolons and trailing braces).
You can also check with eclipse-metrics more suited to what you expect.

+7
Aug 03 '11 at 9:25 a.m.
source share

Another Google Analytix tool that will also allow you to perform metrics, even if you cannot build a project in case of errors

+7
Oct 23 '12 at 7:17
source share

One possible way to count lines of code in Eclipse:

using the "Search / File ..." menu, select the "Search for file" tab, specify \ n [\ s] * for the containing text (this will not be considered empty lines) and check "Regular expression".

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

+3
Jan 16 '15 at 20:54
source share

I created an Eclipse plugin that can count lines of source code. It supports Kotlin, Java, Java Script, JSP, XML, C / C ++, C # and many other file types.

Please take a look at this. Any feedback would be appreciated!

here is the git-hub repository

+1
Jun 14. '16 at 0:50
source share

ProjectCodeMeter calculates LLOC (logical lines of code) exactly as you described (effective lines only). it integrates into eclipse as a tool for evaluating external codes , but not in real time, it generates a report. In fact, it counts many indicators of the source code, such as complexity, arithmetic complexity, hard-coded strings, numerical constants .. even estimates the development time in hours.

0
Oct 06 '11 at 11:12
source share

For static analysis, I used and recommend SonarQube, which runs almost all the indicators you might want , in a wide range of languages , and it is free in the basic version (you need to pay to analyze the types of languages ​​that I only wrote code with a gun on the head).

You should install it as a web application that analyzes from your source code repository, but it also has an Eclipse plugin .

This is unnecessary if you just want to know how one-time how many lines of code are in your project. If you want to track indicators over time, compare projects, warn about a fire when a threshold value is exceeded, etc. This is fantastic.

Disclosure: I do not have a financial relationship with SonarSource.

0
Oct 21 '13 at 12:41
source share



All Articles