Skip to content

Commit

Permalink
Add cinder support
Browse files Browse the repository at this point in the history
  • Loading branch information
winks committed Mar 24, 2012
1 parent c958baa commit 846dfda
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/jonase/kibit/reporters.clj
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,14 @@
(pprint-code expr)
(newline))))

;; This reporter writes Cinder's XML format
(defn xml-reporter [check-map]
(let [{:keys [line expr alt]} check-map]
(do
(printf " <error line=\"%s\" column=\"0\" severity=\"warning\"" line)
(print " message=\"")
(pprint-code alt)
(printf "\" pattern=\"")
(pprint-code expr)
(print "\" />")
(newline))))
30 changes: 30 additions & 0 deletions src/leiningen/kibit_xml.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
(ns leiningen.kibit_xml
(:require [clojure.tools.namespace :as clj-ns]
[clojure.java.io :as io]
[jonase.kibit.core :as kibit]
[jonase.kibit.reporters :as reporters]))

(defn- convert-to-path
"Converts namespace representation to file name"
[path]
(str "src/" (clojure.string/replace (str path) "." "/") ".clj"))

(defn kibit_xml
"Make kibit's findings available to Eclipse/CCW using the Cinder plugin"
[project]
(let [paths (or (:source-paths project) [(:source-path project)])
source-files (mapcat #(-> % io/file clj-ns/find-clojure-sources-in-dir)
paths)]
(do
(println "<cruisecontrol>")
(printf "<padawan>\n")
(doseq [source-file source-files]
(printf "<file name=\"%s\">\n"
(convert-to-path
(or (second (clj-ns/read-file-ns-decl source-file)) source-file)))
(kibit/check-file source-file :reporter reporters/xml-reporter)
(printf "</file>")
(newline)
(flush))
(println "</padawan>")
(println "</cruisecontrol>"))))

0 comments on commit 846dfda

Please sign in to comment.