Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Clojure Linters
Search
Kent OHASHI
February 15, 2018
Programming
62
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Clojure Linters
Utilise linters for clean Clojure code (*> ᴗ •*)ゞ
Kent OHASHI
February 15, 2018
More Decks by Kent OHASHI
See All by Kent OHASHI
速習FP in Scala with Flix: Flix言語で親しむ純粋関数型のコード設計
lagenorhynque
0
44
"Simple Made Easy" Made Easier: Clojureに学ぶsimplicity
lagenorhynque
0
59
Property-Based Testing with test.check and clojure.spec
lagenorhynque
0
79
🐬の推し本紹介2025: 『コーディングを支える技術 ――成り立ちから学ぶプログラミング作法』
lagenorhynque
0
140
KotlinでミニマルなResult実装による関数型エラーハンドリング
lagenorhynque
0
88
Functional Calisthenics in Kotlin: Kotlinで「関数型エクササイズ」を実践しよう
lagenorhynque
1
510
関数型言語テイスティング: Haskell, Scala, Clojure, Elixirを比べて味わう関数型プログラミングの旨さ
lagenorhynque
1
330
純LISPから考える関数型言語のプリミティブ: Clojure, Elixir, Haskell, Scala
lagenorhynque
1
380
From Scala/Clojure to Kotlin
lagenorhynque
0
140
Other Decks in Programming
See All in Programming
なぜCTOを降りてFDEを選んだのか?〜なぜプロダクト企業がFDEで顧客の現場に踏み込むのか〜
gonta
1
200
contenteditable と日本語入力に向き合う
colorful12
0
200
UPDATE をやめる — EF Core でマスタをバージョン管理する
panda728
PRO
0
1.2k
phperだってパンチカードでコーディングしたい
o0h
PRO
0
320
R8 の設定見直しでアプリサイズ削減
andpad
0
220
RAG の “R” を Swift で覗いてみる 〜「意味から探す」検索の仕組み〜
nao_randd
0
160
パズルゲームの作り方 / how to make puzzle games
kaityo256
PRO
2
290
[ハンズオン]AIへの指示だけで「五目並べ」を作ってみよう
satoshi256kbyte
1
380
KiroのSpecで「五目並べ」を作ってみる
satoshi256kbyte
1
380
When benchmarks go bad - what I learned from measuring performance wrong
hollycummins
0
220
カツオ、ご期待ください
suneo3476
0
180
AmebaブログはKMPから卒業します
kmars0605
0
160
Featured
See All Featured
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
WENDY [Excerpt]
tessaabrams
14
40k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
520
Between Models and Reality
mayunak
4
500
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
640
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
890
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.4k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Ethics towards AI in product and experience design
skipperchong
2
430
The #1 spot is gone: here's how to win anyway
tamaranovitovic
4
1.2k
The Curse of the Amulet
leimatthew05
3
15k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
750
Transcript
Clojure Linters
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])
「Clojureをプロダクトに導⼊した話」
1. cljfmt: formatter 2. eastwood: linter 3. kibit: idiom checker
4. Example Usage 5. Other Tools
formatter cljfmt
What's the problem? (when something (something-else) )
$ lein cljfmt check (when something - (something-else) -) +
(something-else))
What's the problem? (when something something-else)
$ lein cljfmt check (when something - something-else) + something-else)
What's the problem? (filter even? (range 1 10))
$ lein cljfmt check (filter even? - (range 1 10))
+ (range 1 10))
What's the problem? (if something ala bala)
$ lein cljfmt check (if something - ala - bala)
+ ala + bala)
What's the problem? (or ala bala portokala)
$ lein cljfmt check (or - ala - bala -
portokala) + ala + bala + portokala)
linter eastwood
What's the problem? (ns linting-example.eastwood-target (:use [clojure.string]))
$ lein eastwood src/linting_example/eastwood_target.clj:2:10: unlimited-use: Unl imited use of ([clojure.string])
in linting-example.eastwood-tar get
What's the problem? (if-let [x []] (conj x 42) :falsy)
$ 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)
What's the problem? (defn f [x] (def y (* x
x)) (+ y 2))
$ lein eastwood src/linting_example/eastwood_target.clj:9:8: def-in-def: There i s a def
of y nested inside def f
What's the problem? (defn g [x] "blah blah blah." (*
x x))
$ 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."
What's the problem? (defn h [str] (str "Hello, " str
"!"))
$ lein eastwood src/linting_example/eastwood_target.clj:17:3: local-shadows-var: local: str invoked as function
shadows var: #'clojure.core/str
idiom checker kibit
What's the problem? (defn add-one [x] (+ x 1))
$ lein kibit At src/linting_example/kibit_target.clj:4: Consider using: (inc x) instead
of: (+ x 1)
What's the problem? (defn check-if-zero? [x] (== x 0))
$ lein kibit At src/linting_example/kibit_target.clj:7: Consider using: (zero? x) instead
of: (== x 0)
What's the problem? (defn zip-with-* [xs ys] (map #(* %1
%2) xs ys))
$ lein kibit At src/linting_example/kibit_target.clj:null: Consider using: * instead of:
#(* %1 %2)
What's the problem? (defn coll->vec [coll] (into [] coll))
$ lein kibit At src/linting_example/kibit_target.clj:13: Consider using: (vec coll) instead
of: (into [] coll)
What's the problem? (defn flat-map [f coll] (apply concat (map
f coll)))
$ lein kibit At src/linting_example/kibit_target.clj:16: Consider using: (mapcat f coll)
instead of: (apply concat (map f coll))
Example Usage
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`
$ 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
Other Tools
dependency lein deps :tree lein-ancient
namespace slamhound
dead code Yagni
vulnerability lein-nvd
test coverage cloverage
misc. lein-bikeshed
Utilise linters for clean Clojure code!
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