mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-24 21:38:07 -05:00
lint: Improve check for synopses starting with package name.
* guix/scripts/lint.scm (package-name-regexp): New procedure. (check-synopsis-style)[check-start-with-package-name]: Use it instead of 'string-prefix-ci?'. * tests/lint.scm ("synopsis: start with package name prefix"): New test.
This commit is contained in:
parent
72b030c049
commit
17854ef91d
2 changed files with 15 additions and 1 deletions
|
@ -131,6 +131,12 @@ (define (check-inputs-should-be-native package)
|
|||
"pkg-config should probably be a native input"
|
||||
'inputs))))))
|
||||
|
||||
(define (package-name-regexp package)
|
||||
"Return a regexp that matches PACKAGE's name as a word at the beginning of a
|
||||
line."
|
||||
(make-regexp (string-append "^" (regexp-quote (package-name package))
|
||||
"\\>")
|
||||
regexp/icase))
|
||||
|
||||
(define (check-synopsis-style package)
|
||||
;; Emit a warning if stylistic issues are found in the synopsis of PACKAGE.
|
||||
|
@ -168,7 +174,7 @@ (define (check-proper-start synopsis)
|
|||
'synopsis)))
|
||||
|
||||
(define (check-start-with-package-name synopsis)
|
||||
(when (string-prefix-ci? (package-name package) synopsis)
|
||||
(when (regexp-exec (package-name-regexp package) synopsis)
|
||||
(emit-warning package
|
||||
"synopsis should not start with the package name"
|
||||
'synopsis)))
|
||||
|
|
|
@ -194,6 +194,14 @@ (define (call-with-warnings thunk)
|
|||
(check-synopsis-style pkg))))
|
||||
"synopsis should not start with the package name")))
|
||||
|
||||
(test-assert "synopsis: start with package name prefix"
|
||||
(string-null?
|
||||
(call-with-warnings
|
||||
(lambda ()
|
||||
(let ((pkg (dummy-package "arb"
|
||||
(synopsis "Arbitrary precision"))))
|
||||
(check-synopsis-style pkg))))))
|
||||
|
||||
(test-assert "inputs: pkg-config is probably a native input"
|
||||
(->bool
|
||||
(string-contains
|
||||
|
|
Loading…
Reference in a new issue