Hi! 

I struggled to use clojure.data.zip.xml in the absence of a root node.  My 
XML looks like this:

<pmd version="5.1.2" timestamp="2014-07-22T13:36:59.377">
<file 
name="E:\workspace-sdlc\javancss\src\main\java\javancss\AsciiFormatter.java">
<violation beginline="40" endline="355" begincolumn="1" endcolumn="1" 
rule="TooManyMethods" ruleset="Code Size" package="javancss" 
class="AsciiFormatter" 
externalInfoUrl="http://pmd.sourceforge.net/pmd-5.1.2/rules/java/codesize.html#TooManyMethods";
 
priority="3">
This class has too many methods, consider refactoring it.
</violation>
</file>
<file 
name="E:\workspace-sdlc\javancss\src\main\java\javancss\XmlFormatter.java">
<violation beginline="40" endline="458" begincolumn="1" endcolumn="1" 
rule="TooManyMethods" ruleset="Code Size" package="javancss" 
class="XmlFormatter" 
externalInfoUrl="http://pmd.sourceforge.net/pmd-5.1.2/rules/java/codesize.html#TooManyMethods";
 
priority="3">
This class has too many methods, consider refactoring it.
</violation>
<violation beginline="65" endline="181" begincolumn="13" endcolumn="5" 
rule="ExcessiveMethodLength" ruleset="Code Size" package="javancss" 
class="XmlFormatter" 
externalInfoUrl="http://pmd.sourceforge.net/pmd-5.1.2/rules/java/codesize.html#ExcessiveMethodLength";
 
priority="3">
Avoid really long methods.
</violation>
</file>

... more ...

I want to extract ExcessiveMethodLength violations, and then calculate the 
difference between the beginline and endline attributes.  Here's what I 
came up with:

(for [x pmd-seq :when (and 
                        (= :violation (:tag x)) 
                        (= "ExcessiveMethodLength" (:rule (:attrs x))) )]  
   (- (read-string (:endline (:attrs x))) (read-string (:beginline (:attrs 
x)))  ))


It does the job, but I feel that zip xml would have been better, but I 
could not figure out how to filter the data.

Any insights appreciated.

Thanks
Adrian


-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to