diff --git a/src/project_checkup/core.clj b/src/project_checkup/core.clj --- a/src/project_checkup/core.clj +++ b/src/project_checkup/core.clj @@ -18,16 +18,11 @@ (string/split (:out (shell/sh "chg" "st" "-u" "-n")) #"\n")) (if (contains? vcs-systems ".git") (string/split (:out (shell/sh "git" "ls-files" "--others" - "--exclude-standard")) #"\n"))] - ) - ) - + "--exclude-standard")) #"\n"))])) (defn gather-project-info "Creates a dictionary of project information." [] (let [all-files (map str (file-seq (clojure.java.io/file "."))) - ; files (string/split (:out (shell/sh "hg" "st" "-m" "-a" "-r" "-d" "-c" "-n" )) #"\n") - files (map #(clojure.string/replace % #"./(.*)" "$1") all-files ) ; file-set (set files) ;note that using some here means that if both are present, hg is @@ -37,8 +32,7 @@ :extensions (frequencies (map get-extension files )) :path (System/getProperty "user.dir") :untracked-files (gather-untracked vcs-systems) - :readme (if-let [filename (some #{"README.md" "README.txt" "README.mkd"} files)] (slurp filename) "") - }) ) + :readme (if-let [filename (some #{"README.md" "README.txt" "README.mkd"} files)] (slurp filename) "") }) ) (defn color [color string] (let [color-sequence (case color @@ -47,27 +41,26 @@ :blue "\u001B[34m" :red "\u001B[31m" :cyan "\u001B[36m" - :magenta "\u001B[35m" - ) - reset "\u001B[m" ] - (str color-sequence string reset)) ) + :magenta "\u001B[35m") + reset "\u001B[m"] + (str color-sequence string reset))) (defn check-vcs [project] (let [{files :files } project] - (boolean (some #{".git" ".hg"} files)) )) + (boolean (some #{".git" ".hg"} files)))) (defn check-readme [project] (let [{files :files } project] - (boolean (some #{"README.md" "README.txt" "README.mkd" "README"} files)) )) + (boolean (some #{"README.md" "README.txt" "README.mkd" "README"} files)))) (defn check-changelog [project] (let [{files :files } project] - (boolean (some #{"CHANGELOG.md" "CHANGELOG.txt" "CHANGELOG.mkd" "CHANGELOG"} files)) )) + (boolean (some #{"CHANGELOG.md" "CHANGELOG.txt" "CHANGELOG.mkd" "CHANGELOG"} files)))) (defn check-untracked [project] (let [{untracked :untracked-files } project] - (= (count untracked) 0)) ) + (= (count untracked) 0))) (defn check-taskpaper [project] (let [{extensions :extensions files :files } project] @@ -75,7 +68,7 @@ (some #{"TODO" "TODO.txt" } files)))) (defn check-readme-placeholders [project] - (= (count (re-find #"(FIXME|TODO)" (:readme project) )) 0)) + (= (count (re-find #"(FIXME|TODO)" (:readme project))) 0)) (defn check-license [project] @@ -87,11 +80,11 @@ :description "" :function check-vcs :level :error - :follow-up "Initialize a repository." } + :follow-up "Initialize a repository."} {:name "Always True" :function #(or true %) :level :error - :follow-up "This is a bug." } + :follow-up "This is a bug."} {:name "All files are tracked or ignored" :description "" :function check-untracked @@ -101,12 +94,12 @@ :function check-taskpaper :description "" :level :suggestion - :follow-up "Add a todo file using Taskpaper." } + :follow-up "Add a todo file using Taskpaper."} {:name "Project has a README" :function check-readme :description "Readme exists" :level :warning - :follow-up "Add a README." } + :follow-up "Add a README."} {:name "Project has a CHANGELOG" :function check-changelog :description "Changelog exists" @@ -116,8 +109,7 @@ :function check-readme-placeholders :description "No placeholders in README" :level :error - :follow-up "Address placeholders or convert them to tasks." - } + :follow-up "Address placeholders or convert them to tasks."} { :name "Project has a license" :function check-license :description "Project has a LICENSE file." @@ -125,8 +117,7 @@ :follow-up "Add a license to LICENSE. Consider using https://choosealicense.com/ for guidance." }]) (defn perform-check [check project] - (let [{check-name :name function :function follow-up :follow-up - level :level } check + (let [{check-name :name :keys [function follow-up level]} check result (function project) false-color (case level :suggestion :blue @@ -134,16 +125,16 @@ :error :red :red) prefix (case level - :suggestion "Suggested " - :warning "Recommended " - :error "Required " - "Follow-up" )] + :suggestion "Suggested " + :warning "Recommended " + :error "Required " + "Follow-up")] {:name check-name :result result :output (if result (color :green (str "✔" check-name "…passed!")) - (str (color false-color (str "❌" check-name "…failed!")) "\n\t" prefix " Follow up: " follow-up))})) - + (str (color false-color (str "❌" check-name "…failed!")) + "\n\t" prefix " Follow up: " follow-up))})) (defn -main "Run checks."