1 #include <tools/ccanlint/ccanlint.h>
2 #include <ccan/foreach/foreach.h>
12 #include <ccan/str/str.h>
14 static void check_license_comment(struct manifest *m,
15 unsigned int *timeleft, struct score *score)
17 struct list_head *list;
19 /* No requirements on public domain. */
20 if (m->license == LICENSE_PUBLIC_DOMAIN
21 || m->license == LICENSE_UNKNOWN) {
23 score->score = score->total;
27 foreach_ptr(list, &m->c_files, &m->h_files) {
30 list_for_each(list, f, list) {
32 char **lines = get_ccan_file_lines(f);
33 struct line_info *info = get_ccan_line_info(f);
34 bool found_license = false, found_flavor = false;
36 for (i = 0; lines[i]; i++) {
37 if (info[i].type == CODE_LINE)
39 if (strstr(lines[i], "LICENSE"))
42 licenses[m->license].shortname))
45 if ((!found_license || !found_flavor)
46 && !find_boilerplate(f, m->license)) {
47 score_file_error(score, f, lines[i] ? i : 0,
48 "No reference to license"
54 if (list_empty(&score->per_file_errors)) {
56 score->score = score->total;
60 struct ccanlint license_comment = {
61 .key = "license_comment",
62 .name = "Source and header files refer to LICENSE",
63 .check = check_license_comment,
64 .needs = "license_exists"
66 REGISTER_TEST(license_comment);