I have a Java project in Eclipse with ~10 packages and ~10 class files per package. Is there a way to determine total lines of code for the whole project from within Eclipse? I am familiar with other tools (e.g., Code Analyzer, wc, etc.) but I want to know if there is a way to do this within Eclipse (or get confirmation that there is no way to do it).
Here's a good metrics plugin that displays number of lines of code and much more:
http://metrics.sourceforge.net/
It says it requires Eclipse 3.1, although I imagine they mean 3.1+
Here's another metrics plugin that's been tested on Ganymede:
Search
> File Search
Check the Regular expression
box.
Use this expression:
\n[\s]*
Select whatever file types (*.java
, *.xml
, etc..) and working sets are appropriate for you.
check off
you mean, make sure it is checked
. Note that this method does not count empty lines. –
Isochronize \n[^\n]*
–
Feedback \n[^!//][\s]*
–
Hop Here's a good metrics plugin that displays number of lines of code and much more:
http://metrics.sourceforge.net/
It says it requires Eclipse 3.1, although I imagine they mean 3.1+
Here's another metrics plugin that's been tested on Ganymede:
Under linux, the simpler is:
- go to the root folder of your project
- use
find
to do a recursive search of *.java files - use
wc -l
to count lines:
To resume, just do:
find . -name '*.java' | xargs wc -l
For eclipse(Indigo), install (codepro).
After installation:
- Right click on your project
- Choose codepro
tools --> compute metrics
- And you will get your answer in a Metrics tab as Number of Lines.
Are you interested in counting the executable lines rather than the total file line count? If so you could try a code coverage tool such as EclEmma. As a side effect of the code coverage stats you get stats on the number of executable lines and blocks (and methods and classes). These are rolled up from the method level upwards, so you can see line counts for the packages, source roots and projects as well.
You could use a batch file with the following script:
@echo off
SET count=1
FOR /f "tokens=*" %%G IN ('dir "%CD%\src\*.java" /b /s') DO (type "%%G") >> lines.txt
SET count=1
FOR /f "tokens=*" %%G IN ('type lines.txt') DO (set /a lines+=1)
echo Your Project has currently totaled %lines% lines of code.
del lines.txt
PAUSE
I think if you have MyEclipse, it adds a label to the Project Properties page which contains the total number of source code lines. Might not help you as MyEclipse is not free though.
Unfortunately, that wasn't enough in my case so I wrote a source analyzer to gather statistics not gathered by other solutions (for example the metrics mentioned by AlbertoPL).
A very simple plugin for counting actual lines of source code is step counter eclipse plugin. Please download and try.
Place the downloaded jar file under eclipse\plugin folder and restart eclipse.
Rightclick and select step counter
You could use former Instantiations product CodePro AnalytiX. This eclipse plugin provides you suchlike statistics in code metrics view. This is provided by Google free of charge.
© 2022 - 2024 — McMap. All rights reserved.