Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Clojure Linters

Clojure Linters

Utilise linters for clean Clojure code (*> ᴗ •*)ゞ

Kent OHASHI

February 15, 2018
Tweet

More Decks by Kent OHASHI

Other Decks in Programming

Transcript

  1. Self-introduction /laʒenɔʁɛ̃k/ カマイルカ lagénorhynque (defprofile lagénorhynque :name "Kent OHASHI" :languages

    [Clojure Haskell Python Scala English français Deutsch русский] :interests [programming language-learning mathematics] :contributing [github.com/japan-clojurians/clojure-site-ja])
  2. $ lein cljfmt check (or - ala - bala -

    portokala) + ala + bala + portokala)
  3. $ lein eastwood src/linting_example/eastwood_target.clj:4:1: constant-test: Test expression is always logical

    true or always logical false: [] in form (if temp__5455__auto__ (clojure.core/let [x temp__5455__aut o__] (conj x 42)) :falsy)
  4. $ lein eastwood src/linting_example/eastwood_target.clj:12:7: misplaced-docstrin gs: Possibly misplaced docstring, g

    src/linting_example/eastwood_target.clj:12:1: unused-ret-vals: C onstant value is discarded: "blah blah blah."
  5. e.g. ↓↓↓ lagenorhynque/situated-program- challenge/rest-server/project.clj :plugins [[jonase/eastwood "0.2.5"] [lein-cljfmt "0.5.7"] [lein-kibit

    "0.1.6"]] :aliases {"lint" ^{:doc "Execute cljfmt check, eastwood and kibit."} ["do" ["cljfmt" "check"] ["eastwood" "{:source-paths [\"src\"]}"] ["kibit"]]} lein cljfmt check && lein eastwood <opts> && lein kibit = lein do cljfmt check, eastwood <opts>, kibit = lein lint # alias as `lint`
  6. $ lein lint All source files formatted correctly == Eastwood

    0.2.5 Clojure 1.9.0 JVM 9.0.1 Directories scanned for source files: src test == Linting rest-server.util == == Linting rest-server.boundary.db.core == == Linting rest-server.boundary.db.group == ... == Linting rest-server.handler.venue-test == == Linting rest-server.handler.meetup-test == == Linting rest-server.handler.member-test == == Warnings: 0 (not including reflection warnings) Exceptions thrown: 0
  7. Further Reading Clojure Code Quality Tools My Clojure Toolchain: Leiningen

    Automating Style In Clojure The state of code quality tools in Clojure clojure-style-guide