Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-10274

Can this plugin support CLOC for even more languages and better Windows support

    XMLWordPrintable

Details

    Description

      Can SLOCCount plugin supports CLOC?
      http://cloc.sourceforge.net/

      The LOC program is still in maintenance, and supports even more languages!

      Attachments

        Activity

          The tool cloc has an option to create xml output.
          This output can transformed via a short XSLT script into the sloccount format.
          Therefore, no changes are required within the sloccount source.
          Please, reject this change request!

          ben25 Karsten Brandt added a comment - The tool cloc has an option to create xml output. This output can transformed via a short XSLT script into the sloccount format. Therefore, no changes are required within the sloccount source. Please, reject this change request!

          Would you please upload the xslt script here?

          andrey_regentov andrey regentov added a comment - Would you please upload the xslt script here?
          ben25 Karsten Brandt added a comment - - edited

          @andrey: I've attached an example for you.

          ben25 Karsten Brandt added a comment - - edited @andrey: I've attached an example for you.

          It does not work for me, maybe I use wrong options? What I do is:

          • 1: run cloc:
            cloc.pl --by-file --exclude-dir=.svn,build --xml -out=build/cloc.xml mysourcedir
          • 2: run xsltproc using your example XML file:
            xsltproc sloccount.xsl build/cloc.xml
          • Result:
            compilation error: file /home/zoufala/Downloads/sloccount.xsl line 1 element stylesheet
            xsl:version: only 1.0 features are supported
            xmlXPathCompOpEval: function replace not found
            XPath error : Unregistered function
            xmlXPathCompiledEval: 2 objects left on the stack.
            runtime error: file /home/zoufala/Downloads/sloccount.xsl line 5 element variable
            Failed to evaluate the expression of variable 'file_path'.
            This report has been generated by cloc 1.56.
            For more details see: http://cloc.sourceforge.net

          Is there an obvious mistake in my usage?

          zoufala Andreas Zoufal added a comment - It does not work for me, maybe I use wrong options? What I do is: 1: run cloc: cloc.pl --by-file --exclude-dir=.svn,build --xml -out=build/cloc.xml mysourcedir 2: run xsltproc using your example XML file: xsltproc sloccount.xsl build/cloc.xml Result: compilation error: file /home/zoufala/Downloads/sloccount.xsl line 1 element stylesheet xsl:version: only 1.0 features are supported xmlXPathCompOpEval: function replace not found XPath error : Unregistered function xmlXPathCompiledEval: 2 objects left on the stack. runtime error: file /home/zoufala/Downloads/sloccount.xsl line 5 element variable Failed to evaluate the expression of variable 'file_path'. This report has been generated by cloc 1.56. For more details see: http://cloc.sourceforge.net Is there an obvious mistake in my usage?
          andrey_regentov andrey regentov added a comment - - edited

          @Andreas it is due to 1.0 limitation of xsltproc. This worked for me:

          --- sloccount.shouldbe
          +++ sloccount.xsl     
          @@ -1,8 +1,8 @@
          -<xsl:stylesheet version="1.0" xmlns:de="." xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
          +<xsl:stylesheet version="2.0" xmlns:de="." xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
           <xsl:output method="text" version="4.0" encoding="iso-8859-1" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
          
           <xsl:template match="file">
          -  <xsl:variable name="file_path" select="translate(@name,'\\','/')"/>
          +  <xsl:variable name="file_path" select="replace(@name,'\\','/')"/>
             <xsl:variable name="file_path_part1" select="substring-after($file_path,'/')"/>
             <xsl:variable name="module" select="substring-before($file_path_part1,'/')"/>
             <xsl:value-of select="@code"/>
          
          andrey_regentov andrey regentov added a comment - - edited @Andreas it is due to 1.0 limitation of xsltproc. This worked for me: --- sloccount.shouldbe +++ sloccount.xsl @@ -1,8 +1,8 @@ -<xsl:stylesheet version="1.0" xmlns:de="." xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> +<xsl:stylesheet version="2.0" xmlns:de="." xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text" version="4.0" encoding="iso-8859-1" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/> <xsl:template match="file"> - <xsl:variable name="file_path" select="translate(@name,'\\','/')"/> + <xsl:variable name="file_path" select="replace(@name,'\\','/')"/> <xsl:variable name="file_path_part1" select="substring-after($file_path,'/')"/> <xsl:variable name="module" select="substring-before($file_path_part1,'/')"/> <xsl:value-of select="@code"/>

          Thanks Andrey, I will give it a try the next days!

          zoufala Andreas Zoufal added a comment - Thanks Andrey, I will give it a try the next days!

          Yes indeed, it works very well! Thx

          zoufala Andreas Zoufal added a comment - Yes indeed, it works very well! Thx

          It doesn't appear this works for the current version. I'm using Cloc 1.58 with plugin version 1.8.

          I used the same method as the individuals above, and the output is not properly parsed by the sloccount plugin.

          westhusing Adam Westhusing added a comment - It doesn't appear this works for the current version. I'm using Cloc 1.58 with plugin version 1.8. I used the same method as the individuals above, and the output is not properly parsed by the sloccount plugin.

          Nevermind, I wasn't following the directions properly. Once I used xsltproc this worked as expected. Sorry!

          westhusing Adam Westhusing added a comment - Nevermind, I wasn't following the directions properly. Once I used xsltproc this worked as expected. Sorry!
          mixalturek Michal Turek added a comment -

          Closing old non-closed but resolved tasks. Cloc howto added to wiki.

          mixalturek Michal Turek added a comment - Closing old non-closed but resolved tasks. Cloc howto added to wiki.

          People

            npiguet npiguet
            beta Pei-Tang Huang
            Votes:
            2 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: