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