Simplified Lein reporting using the new reporting refactor
This commit is contained in:
parent
8a417bee3d
commit
297549d66f
1 changed files with 3 additions and 26 deletions
|
@ -1,24 +1,7 @@
|
|||
(ns leiningen.kibit
|
||||
(:require [clojure.string :as string]
|
||||
[clojure.tools.namespace :as clj-ns]
|
||||
(:require [clojure.tools.namespace :as clj-ns]
|
||||
[clojure.java.io :as io]
|
||||
[clojure.pprint :as pp]
|
||||
[jonase.kibit.core :as kibit])
|
||||
(:import [java.io StringWriter]))
|
||||
|
||||
;; A hack to get the code indented.
|
||||
(defn pprint-code [form]
|
||||
(let [string-writer (StringWriter.)]
|
||||
(pp/write form
|
||||
:dispatch pp/code-dispatch
|
||||
:stream string-writer
|
||||
:pretty true)
|
||||
(->> (str string-writer)
|
||||
string/split-lines
|
||||
(map #(str " " %))
|
||||
(string/join "\n")
|
||||
println)))
|
||||
|
||||
[jonase.kibit.core :as kibit]))
|
||||
|
||||
(defn kibit
|
||||
"Suggest idiomatic replacements for patterns of code."
|
||||
|
@ -29,11 +12,5 @@
|
|||
(doseq [source-file source-files]
|
||||
(printf "== %s ==\n"
|
||||
(or (second (clj-ns/read-file-ns-decl source-file)) source-file))
|
||||
(with-open [reader (io/reader source-file)]
|
||||
(doseq [{:keys [line expr alt]} (kibit/check-file reader)]
|
||||
(printf "[%s] Consider:\n" line)
|
||||
(pprint-code alt)
|
||||
(println "instead of:")
|
||||
(pprint-code expr)
|
||||
(newline)))
|
||||
(kibit/check-file source-file)
|
||||
(flush))))
|
||||
|
|
Loading…
Reference in a new issue