Description:
Add license check.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
@@ -74,6 +74,12 | |||||
|
74 | (= (count (re-find #"(FIXME|TODO)" (:readme project) )) 0)) |
|
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 | (def checks [{:name "Project is checked into revision control" |
|
83 | (def checks [{:name "Project is checked into revision control" |
|
78 | :description "" |
|
84 | :description "" |
|
79 | :function check-vcs |
|
85 | :function check-vcs |
@@ -93,7 +99,7 | |||||
|
93 | :description "" |
|
99 | :description "" |
|
94 | :level :suggestion |
|
100 | :level :suggestion |
|
95 | :follow-up "Add a todo file using Taskpaper." } |
|
101 | :follow-up "Add a todo file using Taskpaper." } |
|
96 |
{:name " |
|
102 | {:name "Project has a README" |
|
97 | :function check-readme |
|
103 | :function check-readme |
|
98 | :description "Readme exists" |
|
104 | :description "Readme exists" |
|
99 | :level :suggestion |
|
105 | :level :suggestion |
@@ -103,7 +109,12 | |||||
|
103 | :description "No placeholders in README" |
|
109 | :description "No placeholders in README" |
|
104 | :level :error |
|
110 | :level :error |
|
105 | :follow-up "Address placeholders or convert them to tasks." |
|
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 | (defn perform-check [check project] |
|
119 | (defn perform-check [check project] |
|
109 | (let [{check-name :name function :function follow-up :follow-up |
|
120 | (let [{check-name :name function :function follow-up :follow-up |
@@ -115,9 +126,9 | |||||
|
115 | :error :red |
|
126 | :error :red |
|
116 | :red) |
|
127 | :red) |
|
117 | prefix (case level |
|
128 | prefix (case level |
|
118 |
:suggestion "Suggested |
|
129 | :suggestion "Suggested " |
|
119 |
:warning "Recommended |
|
130 | :warning "Recommended " |
|
120 |
:error "Required |
|
131 | :error "Required " |
|
121 | "Follow-up" )] |
|
132 | "Follow-up" )] |
|
122 | {:name check-name |
|
133 | {:name check-name |
|
123 | :result result |
|
134 | :result result |
@@ -136,4 +147,4 | |||||
|
136 | (catch Exception ex |
|
147 | (catch Exception ex |
|
137 | (.printStackTrace ex) |
|
148 | (.printStackTrace ex) |
|
138 | (str "caught exception: " (.getMessage ex))) |
|
149 | (str "caught exception: " (.getMessage ex))) |
|
139 |
(finally (shutdown-agents) |
|
150 | (finally (shutdown-agents)))) |
@@ -34,6 +34,18 | |||||
|
34 | (is (not (check-untracked {:untracked-files [".hg"]}))))) |
|
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 | (deftest test-get-extension |
|
49 | (deftest test-get-extension |
|
38 | (testing "test various paths with extensions" |
|
50 | (testing "test various paths with extensions" |
|
39 | (is (= (get-extension "test.txt") ".txt")) |
|
51 | (is (= (get-extension "test.txt") ".txt")) |
You need to be logged in to leave comments.
Login now