From d2b14d0cb51e4f5098c65329ecd09d4c52fa84fb Mon Sep 17 00:00:00 2001 From: anatoly Date: Mon, 4 Jan 2016 12:22:52 -0500 Subject: [PATCH] boot-check to 0.1.1 + fixing what it caught --- build.boot | 3 ++- src/mount/core.cljc | 20 ++++++++++---------- src/mount/tools/graph.cljc | 2 +- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/build.boot b/build.boot index ecd0a4c..8f8aabc 100644 --- a/build.boot +++ b/build.boot @@ -25,7 +25,7 @@ [adzerk/bootlaces "0.1.13" :scope "test"] [adzerk/boot-logservice "1.0.1" :scope "test"] [adzerk/boot-test "1.0.6" :scope "test"] - [tolitius/boot-check "0.1.0-SNAPSHOT" :scope "test"] + [tolitius/boot-check "0.1.1" :scope "test"] ;; boot cljs [adzerk/boot-cljs "1.7.170-3" :scope "test"] @@ -96,6 +96,7 @@ (set-env! :source-paths #(conj % "dev/clj" "dev/cljs" "test/core" "test/clj" "test/cljs")) ;; (load-data-readers!) (comp + (check/with-bikeshed) (check/with-eastwood) ;; (check/with-yagni) ;; yagni does not yet support (throws on) "cljc" (check/with-kibit))) diff --git a/src/mount/core.cljc b/src/mount/core.cljc index d872eb3..4882ab3 100644 --- a/src/mount/core.cljc +++ b/src/mount/core.cljc @@ -19,16 +19,16 @@ (or (:order (@meta-state state)) (swap! state-seq inc))) -(deftype NotStartedState [state] - Object - (toString [this] +(deftype NotStartedState [state] + Object + (toString [this] (str "'" state "' is not started (to start all the states call mount/start)"))) ;;TODO validate the whole lifecycle (defn- validate [{:keys [start stop suspend resume] :as lifecycle}] - (cond + (cond (not start) (throw-runtime "can't start a stateful thing without a start function. (i.e. missing :start fn)") - (and suspend + (and suspend (not resume)) (throw-runtime "suspendable state should have a resume function (i.e. missing :resume fn)"))) (defn- with-ns [ns name] @@ -98,7 +98,7 @@ (defn- down [state {:keys [stop status] :as current} done] (when (some status #{:started :suspended}) - (when stop + (when stop (on-error (str "could not stop [" state "] due to") (record! state stop done))) (alter-state! current (NotStartedState. state)) ;; (!) if a state does not have :stop when _should_ this might leak @@ -113,7 +113,7 @@ (alter-state! current s))) (update-meta! [state :status] #{:suspended}))) -(defn- sigcont [state {:keys [resume status] :as current} done] +(defn- sigcont [state {:keys [resume status] :as current} done] (when (:suspended status) (let [s (on-error (str "could not resume [" state "] due to") (record! state resume done))] @@ -198,7 +198,7 @@ (defn- bring [states fun order] (let [done (atom [])] - (as-> states $ + (as-> states $ (map var-to-str $) (select-keys @meta-state $) (sort-by (comp :order val) order $) @@ -206,13 +206,13 @@ @done)) (defn- merge-lifecycles - "merges with overriding _certain_ non existing keys. + "merges with overriding _certain_ non existing keys. i.e. :suspend is in a 'state', but not in a 'substitute': it should be overriden with nil however other keys of 'state' (such as :ns,:name,:order) should not be overriden" ([state sub] (merge-lifecycles state nil sub)) ([state origin {:keys [start stop suspend resume status]}] - (assoc state :origin origin + (assoc state :origin origin :status status :start start :stop stop :suspend suspend :resume resume))) diff --git a/src/mount/tools/graph.cljc b/src/mount/tools/graph.cljc index 9113c4e..d84031a 100644 --- a/src/mount/tools/graph.cljc +++ b/src/mount/tools/graph.cljc @@ -8,7 +8,7 @@ deps (->> (filter (comp any val) refers) (map (comp str second)) set)] - (assoc (dissoc state :ns) + (assoc (dissoc state :ns) :deps deps)))) #?(:clj