From 334c43e35462f20d75f25a05e5b66095839d81c0 Mon Sep 17 00:00:00 2001 From: Eric Bavier Date: Wed, 22 Oct 2014 13:48:55 -0500 Subject: 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. --- guix/scripts/lint.scm | 14 ++++++++++++++ tests/lint.scm | 9 +++++++++ 2 files changed, 23 insertions(+) diff --git a/guix/scripts/lint.scm b/guix/scripts/lint.scm index 7b530fa5ac..5f1675f83f 100644 --- a/guix/scripts/lint.scm +++ b/guix/scripts/lint.scm @@ -82,6 +82,12 @@ (define (start-with-capital-letter? s) (define (check-description-style 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) (unless (start-with-capital-letter? description) (emit-warning package @@ -110,6 +116,7 @@ (define (check-end-of-sentence-space description) (let ((description (package-description package))) (when (string? description) (begin + (check-not-empty description) (check-starts-with-upper-case description) (check-end-of-sentence-space description))))) @@ -128,6 +135,12 @@ (define (check-inputs-should-be-native package) (define (check-synopsis-style 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) ;; Synopsis should not end with a period, except for some special cases. (when (and (string-suffix? "." synopsis) @@ -164,6 +177,7 @@ (define (check-start-with-package-name synopsis) (let ((synopsis (package-synopsis package))) (begin + (check-not-empty synopsis) (check-synopsis-start-upper-case synopsis) (check-final-period synopsis) (check-start-article synopsis) diff --git a/tests/lint.scm b/tests/lint.scm index b013231b29..b732a1826a 100644 --- a/tests/lint.scm +++ b/tests/lint.scm @@ -45,6 +45,15 @@ (define (call-with-warnings thunk) (thunk)) (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" (->bool (string-contains (call-with-warnings -- cgit v1.2.3