info_summary_single_line.c 1.1 KB

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