Project / Solution / Modules statistics

Questions and answers regarding the use of eclipse environment as seen in Servoy Developer

Project / Solution / Modules statistics

Postby deezzub » Sat Mar 01, 2014 7:21 pm

Is it possible to get statistics about a Servoy project, solution and module like lines of code? Is there a "metrics" plugin, that I can use for this?
Last edited by deezzub on Sat Mar 01, 2014 8:11 pm, edited 1 time in total.
Sebastian Schlatow
deezzub
 
Posts: 328
Joined: Tue May 28, 2013 3:02 pm
Location: Oldenburg, Germany

Re: Project / Solution / Modules statistics

Postby ROCLASI » Sat Mar 01, 2014 7:30 pm

Hi Sebastian,

I dunno about an Eclipse plugin but you could use the UNIX commandline for this.
Just navigate to your workspace and inside this workspace you run the following command:
Code: Select all
find . -name '*.js' | xargs wc -l

That will give you the amount of lines per .js file and total lines at the end

Hope this helps.
Robert Ivens
ROCLASI Software Solutions / JBS Group, Partner
SAN Developer / Servoy Valued Professional / Servoy Certified Developer
Twitter: @roclasi / @servoyforge
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5189
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: Project / Solution / Modules statistics

Postby deezzub » Sat Mar 01, 2014 8:09 pm

ROCLASI wrote:Just navigate to your workspace and inside this workspace you run the following command:
Code: Select all
find . -name '*.js' | xargs wc -l

That will give you the amount of lines per .js file and total lines at the end


Hi Robert, thanks that helps, really good. :) I improved it a little bit for my needs. ;)

Code: Select all
find . -name '*.js' | xargs wc -l | sort -k1n


If anyone knows about a good Eclipse plugin, please let me know.
Sebastian Schlatow
deezzub
 
Posts: 328
Joined: Tue May 28, 2013 3:02 pm
Location: Oldenburg, Germany

Re: Project / Solution / Modules statistics

Postby ROCLASI » Sat Mar 01, 2014 8:55 pm

Nice!
Although I don't see exactly the need for the -k1 flag.

Also if you don't want to see the files with no lines at all you can use the following command:
Code: Select all
find . -name '*.js' | xargs wc -l | awk -F ' ' {'if ($1 != 0) print$0'} | sort -n


As for Eclipse metric plugins, the ones I can find are very Java focused. I don't know how well they work with Servoy/Javascript projects/code.
Like this one: http://sourceforge.net/projects/metrics2/

Hope this gets you further.
Robert Ivens
ROCLASI Software Solutions / JBS Group, Partner
SAN Developer / Servoy Valued Professional / Servoy Certified Developer
Twitter: @roclasi / @servoyforge
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5189
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: Project / Solution / Modules statistics

Postby deezzub » Sun Mar 02, 2014 4:47 pm

ROCLASI wrote:Also if you don't want to see the files with no lines at all you can use the following command:
Code: Select all
find . -name '*.js' | xargs wc -l | awk -F ' ' {'if ($1 != 0) print$0'} | sort -n


I get different counts for the line numbers for the same files. Do you know why? How can I get the sorted line numbers, only for the solution / project folders?

ROCLASI wrote:As for Eclipse metric plugins, the ones I can find are very Java focused. I don't know how well they work with Servoy/Javascript projects/code.
Like this one: http://sourceforge.net/projects/metrics2/


I already tried that plugin. It seems, that it does not work with Serclipse.
Sebastian Schlatow
deezzub
 
Posts: 328
Joined: Tue May 28, 2013 3:02 pm
Location: Oldenburg, Germany

Re: Project / Solution / Modules statistics

Postby ROCLASI » Sun Mar 02, 2014 6:27 pm

Hi Sebastian,

deezzub wrote:I get different counts for the line numbers for the same files. Do you know why?

What do you mean ? You see different numbers each time you run it ? Or do you see the same file twice (or more) in the result list ?
I don't see either in my environment. Are you sure they are the same files ?

deezzub wrote:How can I get the sorted line numbers, only for the solution / project folders

You can sort over multiple fields by using the -k argument more than once. In this case I made it use the slash (-t'/') as the separator instead of the default space so I can make it sort on the project name first (-k2,2), then the line count (-k1,1) and then any subdirectory or file inside the project (-k3,3) like so:
Code: Select all
find . -name '*.js' | xargs wc -l | awk -F ' ' {'if ($1 != 0) print$0'} | sort -r -t'/' -k2,2 -k1,1 -k3,3

I added the -r so the biggest files show first in each project. Sadly it also means that the project name sort is reversed so project names starting with A will be at the bottom. I haven't found a way yet to set the sort order per field.

Hope this helps.
Robert Ivens
ROCLASI Software Solutions / JBS Group, Partner
SAN Developer / Servoy Valued Professional / Servoy Certified Developer
Twitter: @roclasi / @servoyforge
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5189
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: Project / Solution / Modules statistics

Postby ROCLASI » Sun Mar 02, 2014 9:56 pm

Hi Sebastian,

deezzub wrote:How can I get the sorted line numbers, only for the solution / project folders


After rereading your question I see that you actually wanted to get the totals per project itself, not per file.
That is a bit harder to do with a oneliner. I came up with the following shell script:
Code: Select all
#!/bin/bash
# Count Lines Of Code (in your Servoy workspace)
# Written by Robert Ivens

# Get passed argument and place it in a variable
Wrkspc=$1

# Check if there was an argument passed
if [ -z "$1" ]
then
        # No path given, lets assume the current one
        Wrkspc=$(pwd)
fi

# Get all directories in the workspace and loop through them
for Dir in $(find $Wrkspc/* -maxdepth 0 -type d );
do
        # Get the foldername only
        FolderName=$(basename $Dir)

        # Get the line count from all .js files inside this directory
        Count=$(( find $Dir -name '*.js' -print0 | xargs -0 cat ) | wc -l)

        # Print the Count and Foldername using a format
        printf "%10s %-100s\n" $Count $FolderName
done


Just run it inside your workspace or pass the path of your workspace as an argument.
The result list is unsorted but you can just pipe it into the sort command.

Hope this helps.
Robert Ivens
ROCLASI Software Solutions / JBS Group, Partner
SAN Developer / Servoy Valued Professional / Servoy Certified Developer
Twitter: @roclasi / @servoyforge
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5189
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium


Return to Eclipse Environment

Who is online

Users browsing this forum: No registered users and 1 guest

cron