guix: lint: Allow digits at start of synopsis or description.
* guix/scripts/lint.scm (start-with-capital-letter?): Rename too... (properly-starts-sentence?): Rewrite with regex and add digits. (check-description-style, check-synopsis-style): Use it. * tests/lint.scm: Add tests.
This commit is contained in:
parent
334c43e354
commit
903581f971
|
@ -76,9 +76,8 @@
|
||||||
%checkers)
|
%checkers)
|
||||||
(exit 0))
|
(exit 0))
|
||||||
|
|
||||||
(define (start-with-capital-letter? s)
|
(define (properly-starts-sentence? s)
|
||||||
(and (not (string-null? s))
|
(string-match "^[[:upper:][:digit:]]" s))
|
||||||
(char-set-contains? char-set:upper-case (string-ref s 0))))
|
|
||||||
|
|
||||||
(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.
|
||||||
|
@ -88,10 +87,10 @@
|
||||||
"description should not be empty"
|
"description should not be empty"
|
||||||
'description)))
|
'description)))
|
||||||
|
|
||||||
(define (check-starts-with-upper-case description)
|
(define (check-proper-start description)
|
||||||
(unless (start-with-capital-letter? description)
|
(unless (properly-starts-sentence? description)
|
||||||
(emit-warning package
|
(emit-warning package
|
||||||
"description should start with an upper-case letter"
|
"description should start with an upper-case letter or digit"
|
||||||
'description)))
|
'description)))
|
||||||
|
|
||||||
(define (check-end-of-sentence-space description)
|
(define (check-end-of-sentence-space description)
|
||||||
|
@ -115,10 +114,9 @@ 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
|
(check-not-empty description)
|
||||||
(check-not-empty description)
|
(check-proper-start description)
|
||||||
(check-starts-with-upper-case description)
|
(check-end-of-sentence-space description))))
|
||||||
(check-end-of-sentence-space description)))))
|
|
||||||
|
|
||||||
(define (check-inputs-should-be-native package)
|
(define (check-inputs-should-be-native package)
|
||||||
;; Emit a warning if some inputs of PACKAGE are likely to belong to its
|
;; Emit a warning if some inputs of PACKAGE are likely to belong to its
|
||||||
|
@ -162,12 +160,11 @@ by two spaces; possible infraction~p at ~{~a~^, ~}"
|
||||||
"synopsis should be less than 80 characters long"
|
"synopsis should be less than 80 characters long"
|
||||||
'synopsis)))
|
'synopsis)))
|
||||||
|
|
||||||
(define (check-synopsis-start-upper-case synopsis)
|
(define (check-proper-start synopsis)
|
||||||
(when (and (not (string-null? synopsis))
|
(unless (properly-starts-sentence? synopsis)
|
||||||
(not (start-with-capital-letter? synopsis)))
|
(emit-warning package
|
||||||
(emit-warning package
|
"synopsis should start with an upper-case letter or digit"
|
||||||
"synopsis should start with an upper-case letter"
|
'synopsis)))
|
||||||
'synopsis)))
|
|
||||||
|
|
||||||
(define (check-start-with-package-name synopsis)
|
(define (check-start-with-package-name synopsis)
|
||||||
(when (string-prefix-ci? (package-name package) synopsis)
|
(when (string-prefix-ci? (package-name package) synopsis)
|
||||||
|
@ -176,14 +173,13 @@ by two spaces; possible infraction~p at ~{~a~^, ~}"
|
||||||
'synopsis)))
|
'synopsis)))
|
||||||
|
|
||||||
(let ((synopsis (package-synopsis package)))
|
(let ((synopsis (package-synopsis package)))
|
||||||
(begin
|
|
||||||
(check-not-empty synopsis)
|
|
||||||
(check-synopsis-start-upper-case synopsis)
|
|
||||||
(check-final-period synopsis)
|
|
||||||
(check-start-article synopsis)
|
|
||||||
(check-start-with-package-name synopsis)
|
|
||||||
(check-synopsis-length synopsis)))))
|
|
||||||
(when (string? synopsis)
|
(when (string? synopsis)
|
||||||
|
(check-not-empty synopsis)
|
||||||
|
(check-proper-start synopsis)
|
||||||
|
(check-final-period synopsis)
|
||||||
|
(check-start-article synopsis)
|
||||||
|
(check-start-with-package-name synopsis)
|
||||||
|
(check-synopsis-length synopsis))))
|
||||||
|
|
||||||
(define (check-patches package)
|
(define (check-patches package)
|
||||||
;; Emit a warning if the patches requires by PACKAGE are badly named.
|
;; Emit a warning if the patches requires by PACKAGE are badly named.
|
||||||
|
|
|
@ -63,6 +63,15 @@
|
||||||
(check-description-style pkg))))
|
(check-description-style pkg))))
|
||||||
"description should start with an upper-case letter")))
|
"description should start with an upper-case letter")))
|
||||||
|
|
||||||
|
(test-assert "description: may start with a digit"
|
||||||
|
(not
|
||||||
|
(string-contains (call-with-warnings
|
||||||
|
(lambda ()
|
||||||
|
(let ((pkg (dummy-package "x"
|
||||||
|
(description "2-component library."))))
|
||||||
|
(check-description-style pkg))))
|
||||||
|
"description should start with an upper-case letter")))
|
||||||
|
|
||||||
(test-assert "description: two spaces after end of sentence"
|
(test-assert "description: two spaces after end of sentence"
|
||||||
(->bool
|
(->bool
|
||||||
(string-contains (call-with-warnings
|
(string-contains (call-with-warnings
|
||||||
|
@ -100,6 +109,15 @@
|
||||||
(check-synopsis-style pkg))))
|
(check-synopsis-style pkg))))
|
||||||
"synopsis should start with an upper-case letter")))
|
"synopsis should start with an upper-case letter")))
|
||||||
|
|
||||||
|
(test-assert "synopsis: may start with a digit"
|
||||||
|
(not
|
||||||
|
(string-contains (call-with-warnings
|
||||||
|
(lambda ()
|
||||||
|
(let ((pkg (dummy-package "x"
|
||||||
|
(synopsis "5-dimensional frobnicator"))))
|
||||||
|
(check-synopsis-style pkg))))
|
||||||
|
"synopsis should start with an upper-case letter")))
|
||||||
|
|
||||||
(test-assert "synopsis: ends with a period"
|
(test-assert "synopsis: ends with a period"
|
||||||
(->bool
|
(->bool
|
||||||
(string-contains (call-with-warnings
|
(string-contains (call-with-warnings
|
||||||
|
|
Loading…
Reference in New Issue