Could you add a SLOCCount output?
An SLOCCount output would be extremely handy since some plugin (like Jenkins' SLOCCount Plugin) only support this output format.
Unfortunately, SLOCCount is written in C and thus it's not multi-platform and causes problems on my Jenkins server. However, this plugin is very cool and gives me detailed information how my code has evolved over time.
I know, there is a way to add CLOCK support to this plugin but I need to transform CLOC's XML output to the sc file using xsltproc and it may not work as expected (and I think it is annoying to add this xsl template to every project, especially since I'm only allowed to change certain parts of some project).
Anonymous
Attach an example of the kind of input accepted by the Jenkins plugin and I'll give it a shot.
The numbers are the lines of code. Java is the used language. The module ("Users") is a little bit buggy when using the cloc to SCLOCcount converter script.
In my case it should be "test" and "src" because I enter
cloc test/ src/
to generate the results and that's what SCLOCcount would've done, too. However, if only one dictionary was provided, SCLOCcount uses the following algorithm to determine what modules have been used:(copied from the man page).
I don't think this works very well (it creates very weird results for some of my projects). So, I'd suggest you just return one module if only one directory was given. You can implement this algorithm if you want the results to be close to the original SCLOCCount script but I don't think it's worth the time.
The last value is the absolute path to every single file. I've shorten with [...].
I also attached some results created by the original script. They aren't much different from the results above. However, one file shows what the results look like when no arguments were entered.
Let me know if the output of this is sufficient for your needs:
The grep commands don't work (grep version: grep (GNU grep) 2.5.1 on OS X 9). It seems that my grep doesn't understand -P).
The output without the grep commands is:
The first lines won't properly work and sloccount generates absolut paths. These paths are relative.
Last edit: Matteo Kloiber 2014-05-13
Interesting that the OS X version of GNU grep doesn't support the -P ("use Perl-style regular expressions") option; GNU grep 2.5.1 on Linux does.
Regarding relative v. absolute paths, if you give cloc absolute paths as inputs, it will print absolute paths in the output. However, absolute paths can be forced with the File::Spec-rel2abs() function.
This version uses grep without -P, removes the bad first line, and forces absolute paths:
True, it is not pretty, but should get the job done.
It works, thank you! :)