5

Is there a pluging/feature to count the number of lines in a project?

PengOne
  • 48,188
  • 17
  • 130
  • 149
ahodder
  • 11,353
  • 14
  • 71
  • 114
  • 2
    possible duplicate of [Counting Line Numbers in Eclipse](http://stackoverflow.com/questions/1043666/counting-line-numbers-in-eclipse) – miku Jun 27 '11 at 23:46
  • Same question here check the answers: [counting-line-numbers-in-eclipse][1] http://stackoverflow.com/questions/1043666/counting-line-numbers-in-eclipse – user847988 Sep 05 '12 at 12:15

4 Answers4

6

This may be what you're looking for: http://metrics2.sourceforge.net/

PengOne
  • 48,188
  • 17
  • 130
  • 149
  • 1
    Too bad Metrics only appears to be compatible with Eclipse 3.4/3.5 and I sure ain't rolling back from 4.2 :P – arkon May 28 '13 at 09:52
4

A very simplistic way is to do a regular expression search for '\n' in your project. It will give you a good idea on the number of lines in your project without installing any extra plug-ins.

Deepak Azad
  • 7,903
  • 2
  • 34
  • 49
  • Indeed, and I thought about it. Maybe when I have more free time I'll get around to implementing one of my own, but for now I'm gonna have to go with metrics. It seems way more than I need but increbily useful. Thanks though. – ahodder Jun 28 '11 at 14:36
1

Instead of installing a new eclipse plugin; If you are on a linux system:

cd to the eclispe project source directory(workspace/project-name/src)

and enter in termianl:

wc -l *.java

This will show you total number of lines as well as number of lines in each file

Nullpointer
  • 1,086
  • 7
  • 20
  • 5
    it is pretty easy solution. also for recursive counting, "find . -name '*.java' | xargs wc -l" can be used – Adem May 17 '15 at 11:52
0

A quick way to do it is based on this tutorial I found: http://stephendnicholas.com/posts/eclipse-quick-line-count

To summarize, do the following (to use search in Eclipse press Ctrl+H):

  1. Find the total amount of lines: Search your code for \n using 'regular expression' under your code files (e.g. if you develop in java only then search only *.java files).
  2. Find the total amount of blank lines: Search your code for ^\s*\n
  3. Find the total amount of commented lines: search your code for //.*(\n{1})?

Finally: Get the total amount of lines of code by subtracting 2 and 3 from 1.

Eyal Gerber
  • 1,026
  • 10
  • 27