Description:
Various improvements and refactorings.
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r4:b40528ad1820 -

@@ -1,4 +1,4
1 (defproject project-checkup "0.1.0-SNAPSHOT"
1 (defproject project-checkup "0.1.1-SNAPSHOT"
2 :description "FIXME: write description"
2 :description "FIXME: write description"
3 :url "http://example.com/FIXME"
3 :url "http://example.com/FIXME"
4 :license {:name "Eclipse Public License"
4 :license {:name "Eclipse Public License"
@@ -9,17 +9,28
9 (defn gather-project-info
9 (defn gather-project-info
10 "Creates a dictionary of project information"
10 "Creates a dictionary of project information"
11 []
11 []
12 (let [files (set (map str (file-seq (clojure.java.io/file "."))))]
12 (let [all-files (set (map str (file-seq (clojure.java.io/file "."))))
13 ; files (string/split (:out (shell/sh "hg" "st" "-m" "-a" "-r" "-d" "-c" "-n" )) #"\n")
14 files (map #(clojure.string/replace % #"./(.*)" "$1") all-files )
15
16 ]
13 {:files files
17 {:files files
14 :extensions (frequencies (map get-extension files ))
18 :extensions (frequencies (map get-extension files ))
15 :path (:out (shell/sh "pwd"))
19 :path (:out (shell/sh "pwd"))
16 :untracked-files (string/split (:out (shell/sh "hg" "st" "-u" "-n")) #"\n") }))
20 :untracked-files (string/split (:out (shell/sh "hg" "st" "-u" "-n")) #"\n")
21 :readme (if-let [filename (some #{"README.md" "README.txt" "README.mkd"} files)] (slurp filename) "")
22 })
23
24 )
17
25
18 (defn color [color string]
26 (defn color [color string]
19 (let [color-sequence (case color
27 (let [color-sequence (case color
20 :green "\u001B[32m"
28 :green "\u001B[32m"
21 :yellow "\u001B[33m"
29 :yellow "\u001B[33m"
22 :blue "\u001B[34m"
30 :blue "\u001B[34m"
31 :red "\u001B[31m"
32 :cyan "\u001B[36m"
33 :magenta "\u001B[35m"
23 )
34 )
24 reset "\u001B[m" ]
35 reset "\u001B[m" ]
25 (str color-sequence string reset)) )
36 (str color-sequence string reset)) )
@@ -27,19 +38,25
27
38
28 (defn check-vcs [project]
39 (defn check-vcs [project]
29 (let [{files :files } project]
40 (let [{files :files } project]
30 (boolean (some #{"./.git" "./.hg"} files)) ))
41 (boolean (some #{".git" ".hg"} files)) ))
31
42
32 (defn check-readme [project]
43 (defn check-readme [project]
33 (let [{files :files } project]
44 (let [{files :files } project]
34 (boolean (some #{"./README.md" "./README.txt" "./README.mkd"} files)) ))
45 (boolean (some #{"README.md" "README.txt" "README.mkd"} files)) ))
35
46
36 (defn check-untracked [project]
47 (defn check-untracked [project]
37 (let [{untracked :untracked-files } project]
48 (let [{untracked :untracked-files } project]
38 (= (count untracked) 0)) )
49 (= (count untracked) 0)) )
39
50
40 (defn check-taskpaper [project]
51 (defn check-taskpaper [project]
41 (let [{extensions :extensions } project]
52 (let [{extensions :extensions files :files } project]
42 (>= (get ".taskpaper" extensions 0) 1) ))
53 (or (>= (get ".taskpaper" extensions 0) 1)
54 (some #{"TODO" "TODO.txt" } files))))
55
56 (defn check-readme-placeholders [project]
57 (= (count (re-find #"(FIXME|TODO)" (:readme project) )) 0)
58 )
59
43
60
44 (def checks [{:name "Has VCS"
61 (def checks [{:name "Has VCS"
45 :description ""
62 :description ""
@@ -64,7 +81,13
64 :function check-readme
81 :function check-readme
65 :description "Readme exists"
82 :description "Readme exists"
66 :level :suggestion
83 :level :suggestion
67 :follow-up "Add a README." } ])
84 :follow-up "Add a README." }
85 {:name "README has no placeholders"
86 :function check-readme-placeholders
87 :description "No placeholders in README"
88 :level :error
89 :follow-up "Address placeholders or convert them to tasks."
90 } ])
68
91
69 (defn perform-check [check project]
92 (defn perform-check [check project]
70 (let [{check-name :name function :function follow-up :follow-up
93 (let [{check-name :name function :function follow-up :follow-up
@@ -83,8 +106,17
83
106
84
107
85 (defn -main
108 (defn -main
86 "I don't do a whole lot ... yet."
109 "Run checks."
87 [& args]
110 [& args]
111 (try
112
88 (doseq [check checks]
113 (doseq [check checks]
89 (println (:output (perform-check check (gather-project-info) ))))
114 (println (:output (perform-check check (gather-project-info) ))))
90 (shutdown-agents) )
115
116 (catch Exception ex
117 (.printStackTrace ex)
118 (str "caught exception: " (.getMessage ex)))
119 (finally (shutdown-agents) )
120 )
121
122 )
You need to be logged in to leave comments. Login now