score:96
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.
score:0
ProjectCodeMeter counts LLOC (logical lines of code) exactly as you described (only effective lines). it integrates into eclipse as external code metrics tool, it's not real-time though, it generates a report.actually it counts many source code metrics such as complexity, arithmetic intricacy, hard coded strings, numeric constants.. even estimates development time in hours.
score:0
For static analysis, I've used and recommend SonarQube which runs just about all the metrics you could possibly want on a wide range of languages, and is free in the basic version (you have to pay to analyse the sorts of languages I'd only code in with a gun to my head).
You have to install it as a web-app running the analysis off your source code repository, but it also has an Eclipse plugin.
It's overkill if you just want to know, as a one-off, how many lines of code there are in your project. If you want to track metrics through time, compare across projects, fire warnings when a threshold is exceeded, etc., it's fantastic.
Disclosure: I have no financial relationship with SonarSource.
score:0
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.
score:1
I created a Eclipse plugin, which can count the lines of source code. It support Kotlin, Java, Java Script, JSP, XML, C/C++, C#, and many other file types.
Please take a look at it. Any feedback would be appreciated!
score:7
Another tool is Google Analytix, which will also allow you to run metrics even if you can`t build the project in case of errors
score:8
Another way would by to use another loc utility, like LocMetrics for instance.
It also lists many other loc tools.
The integration with Eclipse wouldn't be always there (as it would be with Metrics2, which you can check out because it is a more recent version than Metrics), but at least those tools can reason in term of logical lines (computed by summing the terminal semicolons and terminal curly braces).
You can also check with eclipse-metrics is more adapted to what you expect.
score:13
One possible way to count lines of code in Eclipse:
using the Search / File... menu, select File Search tab, specify \n[\s]* for Containing text (this will not count empty lines), and tick Regular expression.
Hat tip: www.monblocnotes.com/node/2030
score:23
If on OSX or *NIX use
Get all actual lines of java code from *.java files
find . -name "*.java" -exec grep "[a-zA-Z0-9{}]" {} \; | wc -l
Get all lines from the *.java files, which includes empty lines and comments
find . -name "*.java" -exec cat | wc -l
Get information per File, this will give you [ path to file + "," + number of lines ]
find . -name "*.java" -exec wc -l {} \;
score:281
There's always the "brute force":
Search->File
Type the following in "Containing text" ->
^.*$
. Then check the "Regular Expression" checkboxType the following in "File name patterns" ->
*.java
Click "Search"
Check the number of matches in the "Search" Tab.
Source: stackoverflow.com
Related Query
- Eclipse count lines of code
- Lines of Code count for Flex in Eclipse
- How to count code lines automaticly in Eclipse IDE?
- Eclipse Pydev: Run selected lines of code
- Eclipse plugin for measuring lines of code
- Remove empty lines in eclipse code editor by find/replace (Ctrl+F)
- Eclipse marks lines as dead code
- Lines of Code in Eclipse PyDev Projects
- Is there a limit on the number of lines of code you can put in an Eclipse java doument
- Eclipse Plugin for counting lines of code (Eclipse Juno)
- Eclipse tool that shows which lines of code were hit throughout an execution?
- Count for the selected lines in eclipse editor
- Eclipse EcLemma number of covered instructions more than lines of code
- Find/Replace multiple lines of code in Eclipse
- Eclipse code formatter: do not wrap lines on method call
- Eclipse remove error text from code lines
- Eclipse - How to format selected code from multiple lines to a single line?
- Write default code in lines in Java Eclipse on creating new project
- How to create exportable links to code lines using eclipse
- Stop Eclipse from cutting code lines on clean up
- Eclipse typing code on multiple lines
- eclipse gdb - how to step into a MACRO containing lines of code
- Code cleanup in Eclipse - How can I preserve blank lines in non-javadoc comments?
- How to left-justify lines of code to the left edge of the window in eclipse
- what does the following lines of code mean in eclipse plugin.xml?
- How to write few lines code on top of all jsp pages in ECLIPSE
- how to know what are the lines covered in the code for a particular point of execution in eclipse
- All my lines of code in my 'src' folder have errors in Eclipse
- Eclipse Class Count Lines Plugin?
- Eclipse force code onto 2 lines
More Query from same tag
- Easiest way to Filter Eclipse Console Output text
- I can't find source and design tab in eclipse kepler
- Android SDK eclipse installation not working properly
- How to set GCP credential in Eclipse to run Dataflow pipeline
- Thymeleaf: org.thymeleaf.exceptions.TemplateInputException
- no activity found to handle intene (act=Main)
- Launch an Eclipse Run Configuration from ANT
- unable to use com.google.android.maps in the xml file
- Android, Eclipse, Google_Play_Services_Lib - trying to import the project and getting errors
- Maven compilation failes (but compilation under Eclipse is successful)
- Exception in hibernate
- jboss tools installation error in eclipse
- eclipse can't find main method when I make a jar
- an error has occurred.see log file. workspace .metadata .log eclipse
- not able to connect bluetooth devices
- Calling custom class/method in android
- How to references correctly Java Projects into Web Dynamic Project
- how to let eclipse java ingore codes after return
- Showing listfragment in action bar
- can not run kotlin project in eclipse java.lang.ClassNotFoundException
- How many multiple "Eclipse Projects" is considered too excessive for one actual development project?
- Flash Builder (ecplise) syntax coloring not working
- How to show arguments of java function in vim + eclim?
- Eclipse project linked resources by environment variable
- Android xml graphical layout is not working for eclipse IDE
- Eclipse: dynamic web project, where to put my download jQuery API
- Remote Development Workflow with Tomcat and Eclipse
- How do I export a SimpleSwingApplication as an executable JAR with Eclipse?
- How to run a Lucene 4.9 IndexFiles?
- How can I take eclipse out of MDI mode?