info_summary_single_line.c 1.1 KB

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