Description:
Add license check.
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r15:a194dde39443 -

@@ -74,6 +74,12
74 74 (= (count (re-find #"(FIXME|TODO)" (:readme project) )) 0))
75 75
76 76
77 (defn check-license [project]
78 (let [{files :files } project]
79 (boolean (some #{"LICENSE" "LICENSE.txt" "LICENSE.md" "LICENSE.mkd"} files)) )
80 )
81
82
77 83 (def checks [{:name "Project is checked into revision control"
78 84 :description ""
79 85 :function check-vcs
@@ -93,7 +99,7
93 99 :description ""
94 100 :level :suggestion
95 101 :follow-up "Add a todo file using Taskpaper." }
96 {:name "Has README"
102 {:name "Project has a README"
97 103 :function check-readme
98 104 :description "Readme exists"
99 105 :level :suggestion
@@ -103,7 +109,12
103 109 :description "No placeholders in README"
104 110 :level :error
105 111 :follow-up "Address placeholders or convert them to tasks."
106 } ])
112 }
113 { :name "Project has a license"
114 :function check-license
115 :description "Project has a LICENSE file."
116 :level :warning ;going with warning because a project might not have a license before release.
117 :follow-up "Add a license to LICENSE. Consider using https://choosealicense.com/ if you need guidance. " }])
107 118
108 119 (defn perform-check [check project]
109 120 (let [{check-name :name function :function follow-up :follow-up
@@ -115,9 +126,9
115 126 :error :red
116 127 :red)
117 128 prefix (case level
118 :suggestion "Suggested follow-up"
119 :warning "Recommended follow-up"
120 :error "Required follow-up"
129 :suggestion "Suggested "
130 :warning "Recommended "
131 :error "Required "
121 132 "Follow-up" )]
122 133 {:name check-name
123 134 :result result
@@ -136,4 +147,4
136 147 (catch Exception ex
137 148 (.printStackTrace ex)
138 149 (str "caught exception: " (.getMessage ex)))
139 (finally (shutdown-agents) )) )
150 (finally (shutdown-agents))))
@@ -34,6 +34,18
34 34 (is (not (check-untracked {:untracked-files [".hg"]})))))
35 35
36 36
37 (deftest test-check-license
38 (testing "Ensure license is counted"
39 (is (check-license {:files ["LICENSE.mkd"]}))
40 (is (check-license {:files ["LICENSE"]})))
41 (testing "Ensure non-plain text licenses don't count."
42 (is (not (check-license {:files ["LICENSE.docx"]})))
43 (is (not (check-license {:files ["LICENSE.pdf"]}))))
44 (testing "Ensure blank is false."
45 (is (not (check-license {:files []})))
46 (is (not (check-license {})))
47 (is (not (check-license {:files ["licens" "README"]})))))
48
37 49 (deftest test-get-extension
38 50 (testing "test various paths with extensions"
39 51 (is (= (get-extension "test.txt") ".txt"))
You need to be logged in to leave comments. Login now