summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--guix/scripts/lint.scm8
-rw-r--r--tests/lint.scm8
2 files changed, 15 insertions, 1 deletions
diff --git a/guix/scripts/lint.scm b/guix/scripts/lint.scm
index 7f5915ba2e..35ab9aaf69 100644
--- a/guix/scripts/lint.scm
+++ b/guix/scripts/lint.scm
@@ -131,6 +131,12 @@ by two spaces; possible infraction~p at ~{~a~^, ~}"
                       "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 @@ by two spaces; possible infraction~p at ~{~a~^, ~}"
                     '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)))
diff --git a/tests/lint.scm b/tests/lint.scm
index 2f62adc39f..9a043c4b59 100644
--- a/tests/lint.scm
+++ b/tests/lint.scm
@@ -194,6 +194,14 @@
                           (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