Description:
Various improvements and refactorings.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
@@ -1,4 +1,4 | |||
|
1 |
(defproject project-checkup "0.1. |
|
|
1 | (defproject project-checkup "0.1.1-SNAPSHOT" | |
|
2 | 2 | :description "FIXME: write description" |
|
3 | 3 | :url "http://example.com/FIXME" |
|
4 | 4 | :license {:name "Eclipse Public License" |
@@ -9,17 +9,28 | |||
|
9 | 9 | (defn gather-project-info |
|
10 | 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 | 17 | {:files files |
|
14 | 18 | :extensions (frequencies (map get-extension files )) |
|
15 | 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 | 26 | (defn color [color string] |
|
19 | 27 | (let [color-sequence (case color |
|
20 | 28 | :green "\u001B[32m" |
|
21 | 29 | :yellow "\u001B[33m" |
|
22 | 30 | :blue "\u001B[34m" |
|
31 | :red "\u001B[31m" | |
|
32 | :cyan "\u001B[36m" | |
|
33 | :magenta "\u001B[35m" | |
|
23 | 34 | ) |
|
24 | 35 | reset "\u001B[m" ] |
|
25 | 36 | (str color-sequence string reset)) ) |
@@ -27,19 +38,25 | |||
|
27 | 38 | |
|
28 | 39 | (defn check-vcs [project] |
|
29 | 40 | (let [{files :files } project] |
|
30 |
(boolean (some #{". |
|
|
41 | (boolean (some #{".git" ".hg"} files)) )) | |
|
31 | 42 | |
|
32 | 43 | (defn check-readme [project] |
|
33 | 44 | (let [{files :files } project] |
|
34 |
(boolean (some #{" |
|
|
45 | (boolean (some #{"README.md" "README.txt" "README.mkd"} files)) )) | |
|
35 | 46 | |
|
36 | 47 | (defn check-untracked [project] |
|
37 | 48 | (let [{untracked :untracked-files } project] |
|
38 | 49 | (= (count untracked) 0)) ) |
|
39 | 50 | |
|
40 | 51 | (defn check-taskpaper [project] |
|
41 | (let [{extensions :extensions } project] | |
|
42 |
(>= (get ".taskpaper" extensions 0) 1) |
|
|
52 | (let [{extensions :extensions files :files } project] | |
|
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 | 61 | (def checks [{:name "Has VCS" |
|
45 | 62 | :description "" |
@@ -64,7 +81,13 | |||
|
64 | 81 | :function check-readme |
|
65 | 82 | :description "Readme exists" |
|
66 | 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 | 92 | (defn perform-check [check project] |
|
70 | 93 | (let [{check-name :name function :function follow-up :follow-up |
@@ -83,8 +106,17 | |||
|
83 | 106 | |
|
84 | 107 | |
|
85 | 108 | (defn -main |
|
86 | "I don't do a whole lot ... yet." | |
|
109 | "Run checks." | |
|
87 | 110 | [& args] |
|
111 | (try | |
|
112 | ||
|
88 | 113 | (doseq [check checks] |
|
89 | 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