Description:
Refactor and cleanup.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
@@ -18,16 +18,11 | |||
|
18 | 18 | (string/split (:out (shell/sh "chg" "st" "-u" "-n")) #"\n")) |
|
19 | 19 | (if (contains? vcs-systems ".git") |
|
20 | 20 | (string/split (:out (shell/sh "git" "ls-files" "--others" |
|
21 | "--exclude-standard")) #"\n"))] | |
|
22 | ) | |
|
23 | ) | |
|
24 | ||
|
21 | "--exclude-standard")) #"\n"))])) | |
|
25 | 22 | (defn gather-project-info |
|
26 | 23 | "Creates a dictionary of project information." |
|
27 | 24 | [] |
|
28 | 25 | (let [all-files (map str (file-seq (clojure.java.io/file "."))) |
|
29 | ; files (string/split (:out (shell/sh "hg" "st" "-m" "-a" "-r" "-d" "-c" "-n" )) #"\n") | |
|
30 | ||
|
31 | 26 | files (map #(clojure.string/replace % #"./(.*)" "$1") all-files ) |
|
32 | 27 | ; file-set (set files) |
|
33 | 28 | ;note that using some here means that if both are present, hg is |
@@ -37,8 +32,7 | |||
|
37 | 32 | :extensions (frequencies (map get-extension files )) |
|
38 | 33 | :path (System/getProperty "user.dir") |
|
39 | 34 | :untracked-files (gather-untracked vcs-systems) |
|
40 | :readme (if-let [filename (some #{"README.md" "README.txt" "README.mkd"} files)] (slurp filename) "") | |
|
41 | }) ) | |
|
35 | :readme (if-let [filename (some #{"README.md" "README.txt" "README.mkd"} files)] (slurp filename) "") }) ) | |
|
42 | 36 | |
|
43 | 37 | (defn color [color string] |
|
44 | 38 | (let [color-sequence (case color |
@@ -47,27 +41,26 | |||
|
47 | 41 | :blue "\u001B[34m" |
|
48 | 42 | :red "\u001B[31m" |
|
49 | 43 | :cyan "\u001B[36m" |
|
50 | :magenta "\u001B[35m" | |
|
51 | ) | |
|
52 | reset "\u001B[m" ] | |
|
53 | (str color-sequence string reset)) ) | |
|
44 | :magenta "\u001B[35m") | |
|
45 | reset "\u001B[m"] | |
|
46 | (str color-sequence string reset))) | |
|
54 | 47 | |
|
55 | 48 | |
|
56 | 49 | (defn check-vcs [project] |
|
57 | 50 | (let [{files :files } project] |
|
58 |
(boolean (some #{".git" ".hg"} files)) |
|
|
51 | (boolean (some #{".git" ".hg"} files)))) | |
|
59 | 52 | |
|
60 | 53 | (defn check-readme [project] |
|
61 | 54 | (let [{files :files } project] |
|
62 |
(boolean (some #{"README.md" "README.txt" "README.mkd" "README"} files)) |
|
|
55 | (boolean (some #{"README.md" "README.txt" "README.mkd" "README"} files)))) | |
|
63 | 56 | |
|
64 | 57 | (defn check-changelog [project] |
|
65 | 58 | (let [{files :files } project] |
|
66 |
(boolean (some #{"CHANGELOG.md" "CHANGELOG.txt" "CHANGELOG.mkd" "CHANGELOG"} files)) |
|
|
59 | (boolean (some #{"CHANGELOG.md" "CHANGELOG.txt" "CHANGELOG.mkd" "CHANGELOG"} files)))) | |
|
67 | 60 | |
|
68 | 61 | (defn check-untracked [project] |
|
69 | 62 | (let [{untracked :untracked-files } project] |
|
70 |
(= (count untracked) 0)) |
|
|
63 | (= (count untracked) 0))) | |
|
71 | 64 | |
|
72 | 65 | (defn check-taskpaper [project] |
|
73 | 66 | (let [{extensions :extensions files :files } project] |
@@ -75,7 +68,7 | |||
|
75 | 68 | (some #{"TODO" "TODO.txt" } files)))) |
|
76 | 69 | |
|
77 | 70 | (defn check-readme-placeholders [project] |
|
78 |
(= (count (re-find #"(FIXME|TODO)" (:readme project) |
|
|
71 | (= (count (re-find #"(FIXME|TODO)" (:readme project))) 0)) | |
|
79 | 72 | |
|
80 | 73 | |
|
81 | 74 | (defn check-license [project] |
@@ -87,11 +80,11 | |||
|
87 | 80 | :description "" |
|
88 | 81 | :function check-vcs |
|
89 | 82 | :level :error |
|
90 |
:follow-up "Initialize a repository." |
|
|
83 | :follow-up "Initialize a repository."} | |
|
91 | 84 | {:name "Always True" |
|
92 | 85 | :function #(or true %) |
|
93 | 86 | :level :error |
|
94 |
:follow-up "This is a bug." |
|
|
87 | :follow-up "This is a bug."} | |
|
95 | 88 | {:name "All files are tracked or ignored" |
|
96 | 89 | :description "" |
|
97 | 90 | :function check-untracked |
@@ -101,12 +94,12 | |||
|
101 | 94 | :function check-taskpaper |
|
102 | 95 | :description "" |
|
103 | 96 | :level :suggestion |
|
104 |
:follow-up "Add a todo file using Taskpaper." |
|
|
97 | :follow-up "Add a todo file using Taskpaper."} | |
|
105 | 98 | {:name "Project has a README" |
|
106 | 99 | :function check-readme |
|
107 | 100 | :description "Readme exists" |
|
108 | 101 | :level :warning |
|
109 |
:follow-up "Add a README." |
|
|
102 | :follow-up "Add a README."} | |
|
110 | 103 | {:name "Project has a CHANGELOG" |
|
111 | 104 | :function check-changelog |
|
112 | 105 | :description "Changelog exists" |
@@ -116,8 +109,7 | |||
|
116 | 109 | :function check-readme-placeholders |
|
117 | 110 | :description "No placeholders in README" |
|
118 | 111 | :level :error |
|
119 | :follow-up "Address placeholders or convert them to tasks." | |
|
120 | } | |
|
112 | :follow-up "Address placeholders or convert them to tasks."} | |
|
121 | 113 | { :name "Project has a license" |
|
122 | 114 | :function check-license |
|
123 | 115 | :description "Project has a LICENSE file." |
@@ -125,8 +117,7 | |||
|
125 | 117 | :follow-up "Add a license to LICENSE. Consider using https://choosealicense.com/ for guidance." }]) |
|
126 | 118 | |
|
127 | 119 | (defn perform-check [check project] |
|
128 |
(let [{check-name :name function |
|
|
129 | level :level } check | |
|
120 | (let [{check-name :name :keys [function follow-up level]} check | |
|
130 | 121 | result (function project) |
|
131 | 122 | false-color (case level |
|
132 | 123 | :suggestion :blue |
@@ -134,16 +125,16 | |||
|
134 | 125 | :error :red |
|
135 | 126 | :red) |
|
136 | 127 | prefix (case level |
|
137 |
|
|
|
138 |
|
|
|
139 |
|
|
|
140 |
|
|
|
128 | :suggestion "Suggested " | |
|
129 | :warning "Recommended " | |
|
130 | :error "Required " | |
|
131 | "Follow-up")] | |
|
141 | 132 | {:name check-name |
|
142 | 133 | :result result |
|
143 | 134 | :output (if result |
|
144 | 135 | (color :green (str "✔" check-name "…passed!")) |
|
145 |
(str (color false-color (str "❌" check-name "…failed!")) |
|
|
146 | ||
|
136 | (str (color false-color (str "❌" check-name "…failed!")) | |
|
137 | "\n\t" prefix " Follow up: " follow-up))})) | |
|
147 | 138 | |
|
148 | 139 | (defn -main |
|
149 | 140 | "Run checks." |
You need to be logged in to leave comments.
Login now