joker

Discuss all things joker, the Clojure interpreter/linter on top of Go. https://github.com/candid82/joker
ddrbt 2019-03-27T11:26:22.056100Z

Hi Joker users, I've been using Joker through it's flycheck package (it's great!) and I'm interested in plugging it into CI jobs. How are people integrating joker into their CI? Anyone have a script they'd be willing to share?

nate 2019-03-27T15:41:42.056800Z

I just enabled joker linting, and it is just wonderful, thank you for building a super fast linter

👍 1
Candid 2019-03-27T20:55:02.057500Z

here is the script we use to lint pull requests:

(require '[joker.os :refer [sh]])
(require '[joker.string :as s])

(defn lint-file?
  [filename]
  (and (or (s/ends-with? filename ".clj")
           (s/ends-with? filename ".edn")
           (s/ends-with? filename ".cljs"))
       (not (s/ends-with? filename "/user.clj"))
       (not (s/ends-with? filename "/repl.clj"))
       (not (s/ends-with? filename "/project.clj"))))

(defn remove-noise
  [output]
  (let [lines (s/split-lines output)
        filtered-lines (remove (fn [line]
                                 (or (s/blank? line)
                                     (s/includes? line "WARNING")))
                               lines)]
    (s/join "\n" filtered-lines)))

(let [branch (s/replace (:out (sh "git" "merge-base" "origin/master" "HEAD")) "\n" "")
      changed-files (s/split-lines (:out (sh "git" "diff" "--name-only" "--diff-filter=ACRM" (str branch "..HEAD"))))
      output (with-out-str
               (doseq [filename (filter lint-file? changed-files)
                       :let [out (:err (sh "joker" "--lint" filename))]]
                 (print out)))
      filtered-output (remove-noise output)]
  (when-not (s/blank? filtered-output)
    (println-err "-----BEGIN LINTER OUTPUT-----")
    (println-err filtered-output)
    (println-err "-----END LINTER OUTPUT-----")
    (joker.os/exit 1)))