I'm trying to use sloccount
from within hudson to gather statistics on our codebase, however by default sloccount
collects information on all files, even those which are "hidden" (eg. .hideme
). This means the statistics are skewed since they include numbers from files within the .svn
directories.
Is there any way I can tell sloccount
to correctly ignore any files/directories which start with a .
?
This syntax is easier to maintain and to extend (which is highly important when you need to exclude several directories):
sloccount --duplicates --wide --details . | grep -v -e '.svn' > sloccount.sc
Example of exclusions chain:
sloccount --duplicates --wide --details . | grep -v -e '.svn' -e 'thirdparty' > sloccount.sc
NB: I use it and it works on my Jenkins
You could edit the source code of sloccount to not search in directories that begin with a period. Otherwise, here is something I cooked up on the command line. Basically, you can specify a list of file paths on the command line as arguments to sloccount and it will analyze only those files. So this will find all files under PWD, excluding hidden files, and then pass them as argument to sloccount.
find . \( ! -regex '.*/\..*' \) -type f | \
tr '\n' ' ' | \
xargs sloccount
My final approach was to remove the .svn
directories from the sed output:
sloccount --wide --details $DIR | sed "/\/\.svn\//d" > sloccount.sc
Use this:
find . -path '*/.*' -prune -o -type f -exec sloccount {} \+
-exec
avoids the xargs
hacks seen in some of the other replies. This is the find-included xargs support. No need to run regexps, globbing is enough. Pruning subdirs is also more efficient.
Update: also, you may want to upgrade to a more recent subversion. New checkout format (after svn upgrade
) uses only a single .svn
directory, so usually you can just do sloccount src
now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With