info_summary_single_line.c 1.1 KB

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