-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathloc_per_ns.clj
25 lines (23 loc) · 951 Bytes
/
loc_per_ns.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
(ns formatting-stack.linters.loc-per-ns
(:require
[clojure.string :as string]
[formatting-stack.protocols.linter]
[formatting-stack.util :refer [process-in-parallel!]]))
(defn overly-long-ns? [filename threshold]
(-> filename
slurp
(string/split #"\n")
(count)
(> threshold)))
(defrecord Linter [max-lines-per-ns]
formatting-stack.protocols.linter/Linter
(lint! [this filenames]
(let [max-lines-per-ns (or max-lines-per-ns 350)]
(->> filenames
(process-in-parallel! (fn [filename]
(when (overly-long-ns? filename max-lines-per-ns)
(println "Warning:"
filename
"is longer than"
max-lines-per-ns
"LOC. Consider refactoring."))))))))