Permalink
Browse files

Display only diffs

  • Loading branch information...
1 parent 846dfda commit d27db6a0e0cac54c6b375cf0b893d81581bf27b4 @winks committed Mar 24, 2012
Showing with 20 additions and 4 deletions.
  1. +20 −4 src/jonase/kibit/reporters.clj
View
24 src/jonase/kibit/reporters.clj
@@ -16,6 +16,20 @@
(string/join "\n")
println)))
+(defn splitter [form]
+ (let [string-writer (StringWriter.)]
+ (pp/write form
+ :dispatch pp/code-dispatch
+ :stream string-writer
+ :pretty true)
+ (->> (str string-writer)
+ string/split-lines)))
+
+(defn diff-lists [a b]
+ (map #(str "" (string/trim %))
+ (filter string?
+ (map #(when-not (= %1 %2) %1) a b))))
+
(defn cli-reporter [check-map]
(let [{:keys [line expr alt]} check-map]
(do
@@ -27,12 +41,14 @@
;; This reporter writes Cinder's XML format
(defn xml-reporter [check-map]
- (let [{:keys [line expr alt]} check-map]
+ (let [{:keys [line expr alt]} check-map
+ expr-list (splitter expr)
+ alt-list (splitter alt)]
(do
(printf " <error line=\"%s\" column=\"0\" severity=\"warning\"" line)
(print " message=\"")
- (pprint-code alt)
- (printf "\" pattern=\"")
- (pprint-code expr)
+ (print (diff-lists alt-list expr-list))
+ (print "\" pattern=\"")
+ (print (diff-lists expr-list alt-list))
(print "\" />")
(newline))))

0 comments on commit d27db6a

Please sign in to comment.