Skip to content

Commit

Permalink
Remove Clojure dependencies from being counted as outdated
Browse files Browse the repository at this point in the history
Remove Clojure dependencies before counting stats on whether they are up
to date or not.

There are lots of reasons why a project doesn't have the latest Clojure
version, and there is nothing particularly wrong with that dep being out
of date, as a user's own Clojure will take precedence over the one in
the dep.

- Update Clojure to 1.8
- Add sift function to simplify the stats calculation code

Fixes hashobject#28
  • Loading branch information
danielcompton committed May 12, 2016
1 parent 9dbc514 commit 5b7c85f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:min-lein-version "2.0.0"
:dependencies [[org.clojure/clojure "1.7.0"]
:dependencies [[org.clojure/clojure "1.8.0"]
[compojure "1.4.0"]
[hiccup "1.0.5"]
[ring/ring-defaults "0.1.5"]
Expand Down
27 changes: 23 additions & 4 deletions src/jarkeeper/statuses.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
[clojure.string :as str]
[clj-http.client :as client]
[clojure.tools.logging :as log]
[ancient-clj.core :as anc])
[ancient-clj.core :as anc]
[clojure.string :as string])

(:import (java.io PushbackReader)))

Expand All @@ -15,6 +16,20 @@
read-string
number?))

(defn sift
"Takes a predicate and a seq, returns two seqs being respectively the elements for which pred
returned truthy and falsey."
;; From https://github.com/jaunt-lang/jaunt/blob/7c7b55633/src/clj/clojure/core.clj#L4597-L4610
[pred coll]
(loop [t []
f []
[e & coll' :as coll] coll]
(if (empty? coll)
[t f]
(if (pred e)
(recur (conj t e) f coll')
(recur t (conj f e) coll')))))

(defn read-file
"Reads all forms in a file lazily."
[r]
Expand Down Expand Up @@ -63,10 +78,14 @@
(defn check-deps [deps]
(map #(conj % (anc/artifact-outdated? % {:snapshots? false :qualified? false})) deps))

(defn clojure-dependency? [dep]
(if (or (= (first dep) "org.clojure/clojure")
(= (first dep) "org.clojure/clojurescript"))))

(defn calculate-stats [deps]
(let [up-to-date-deps (remove nil? (map (fn [dep] (if (nil? (last dep)) dep nil)) deps))
out-of-date-deps (remove nil? (map (fn [dep] (if (nil? (last dep)) nil dep)) deps))
stats {:total (count deps)
(let [filtered-deps (remove clojure-dependency? deps)
[up-to-date-deps out-of-date-deps] (sift (fn [dep] (nil? (last dep))) filtered-deps)
stats {:total (count filtered-deps)
:up-to-date (count up-to-date-deps)
:out-of-date (count out-of-date-deps)}]
stats))
Expand Down

0 comments on commit 5b7c85f

Please sign in to comment.