]> git.ozlabs.org Git - ccan/blob - tools/ccanlint/tests/info_summary_single_line.c
b98ab74e729cfeeee0393550788b4168b78c64e9
[ccan] / tools / ccanlint / tests / info_summary_single_line.c
1 #include <tools/ccanlint/ccanlint.h>
2 #include <tools/tools.h>
3 #include <stdio.h>
4 #include <ccan/talloc/talloc.h>
5 #include <ccan/str/str.h>
6
7 static void check_info_summary_single_line(struct manifest *m,
8                                            bool keep,
9                                            unsigned int *timeleft,
10                                            struct score *score)
11 {
12         struct list_head *infodocs = get_ccan_file_docs(m->info_file);
13         struct doc_section *d;
14
15         score->pass = true;
16         score->score = 1;
17
18         list_for_each(infodocs, d, list) {
19                 const char *after;
20
21                 if (!streq(d->type, "summary"))
22                         continue;
23
24                 /* line following summary line should be empty */
25                 after = m->info_file->lines[d->srcline+1];
26                 if (after && strspn(after, " *") != strlen(after)) {
27                         score->pass = false;
28                         score->score = 0;
29                         score_file_error(score, m->info_file, d->srcline+1,
30                                          m->info_file->lines[d->srcline]);
31                         score_file_error(score, m->info_file, d->srcline+2,
32                                          m->info_file->lines[d->srcline+1]);
33                 }
34         }
35 }
36
37 struct ccanlint info_summary_single_line = {
38         .key = "info_summary_single_line",
39         .name = "Module has a single line summary in _info",
40         .check = check_info_summary_single_line,
41         .needs = "info_exists"
42 };
43
44 REGISTER_TEST(info_summary_single_line);