guix: lint: Check for empty synopses and descriptions.

* guix/scripts/lint.scm (check-description-style,
  check-synopsis-style): New emptiness checks.
* tests/lint.scm: Test them.
This commit is contained in:
Eric Bavier 2014-10-22 13:48:55 -05:00
parent 574e847b8e
commit 334c43e354
2 changed files with 23 additions and 0 deletions

View File

@ -82,6 +82,12 @@
(define (check-description-style package) (define (check-description-style package)
;; Emit a warning if stylistic issues are found in the description of PACKAGE. ;; Emit a warning if stylistic issues are found in the description of PACKAGE.
(define (check-not-empty description)
(when (string-null? description)
(emit-warning package
"description should not be empty"
'description)))
(define (check-starts-with-upper-case description) (define (check-starts-with-upper-case description)
(unless (start-with-capital-letter? description) (unless (start-with-capital-letter? description)
(emit-warning package (emit-warning package
@ -110,6 +116,7 @@ by two spaces; possible infraction~p at ~{~a~^, ~}"
(let ((description (package-description package))) (let ((description (package-description package)))
(when (string? description) (when (string? description)
(begin (begin
(check-not-empty description)
(check-starts-with-upper-case description) (check-starts-with-upper-case description)
(check-end-of-sentence-space description))))) (check-end-of-sentence-space description)))))
@ -128,6 +135,12 @@ by two spaces; possible infraction~p at ~{~a~^, ~}"
(define (check-synopsis-style package) (define (check-synopsis-style package)
;; Emit a warning if stylistic issues are found in the synopsis of PACKAGE. ;; Emit a warning if stylistic issues are found in the synopsis of PACKAGE.
(define (check-not-empty synopsis)
(when (string-null? synopsis)
(emit-warning package
"synopsis should not be empty"
'synopsis)))
(define (check-final-period synopsis) (define (check-final-period synopsis)
;; Synopsis should not end with a period, except for some special cases. ;; Synopsis should not end with a period, except for some special cases.
(when (and (string-suffix? "." synopsis) (when (and (string-suffix? "." synopsis)
@ -164,6 +177,7 @@ by two spaces; possible infraction~p at ~{~a~^, ~}"
(let ((synopsis (package-synopsis package))) (let ((synopsis (package-synopsis package)))
(begin (begin
(check-not-empty synopsis)
(check-synopsis-start-upper-case synopsis) (check-synopsis-start-upper-case synopsis)
(check-final-period synopsis) (check-final-period synopsis)
(check-start-article synopsis) (check-start-article synopsis)

View File

@ -45,6 +45,15 @@
(thunk)) (thunk))
(get-output-string port))) (get-output-string port)))
(test-assert "description: not empty"
(->bool
(string-contains (call-with-warnings
(lambda ()
(let ((pkg (dummy-package "x"
(description ""))))
(check-description-style pkg))))
"description should not be empty")))
(test-assert "description: does not start with an upper-case letter" (test-assert "description: does not start with an upper-case letter"
(->bool (->bool
(string-contains (call-with-warnings (string-contains (call-with-warnings