From 508da791ba0651663375db03055e73847168b938 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Sat, 9 May 2026 17:12:45 +0200 Subject: [PATCH] DescriptionCheck: check for description repeating package name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Górny --- NEWS.rst | 3 +++ src/pkgcheck/checks/metadata.py | 7 ++++++- .../DescriptionCheck/BadDescription/expected.json | 1 + .../standalone/DescriptionCheck/BadDescription/fix.patch | 9 +++++++++ .../BadDescription/BadDescription-5.ebuild | 4 ++++ 5 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 testdata/repos/standalone/DescriptionCheck/BadDescription/BadDescription-5.ebuild diff --git a/NEWS.rst b/NEWS.rst index da11bf1ef..26608d932 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -17,6 +17,9 @@ pkgcheck 0.10.40 (unreleased) - DescriptionCheck: check for descriptions ending with a full-stop (Arthur Zamarin, Michał Górny, #472) +- DescriptionCheck: check for descriptions repeating package name (Michał + Górny, #2021) + **Packaging:** diff --git a/src/pkgcheck/checks/metadata.py b/src/pkgcheck/checks/metadata.py index 6eb528973..68f98392e 100644 --- a/src/pkgcheck/checks/metadata.py +++ b/src/pkgcheck/checks/metadata.py @@ -1523,10 +1523,15 @@ class DescriptionCheck(Check): def feed(self, pkg): desc: str = pkg.description s = desc.lower() + lower_pn = pkg.package.lower() if s.startswith("based on") and "eclass" in s: yield BadDescription("generic eclass defined description", pkg_desc=desc, pkg=pkg) - elif s in (pkg.package.lower(), pkg.key.lower()): + elif s in (lower_pn, pkg.key.lower()): yield BadDescription("generic package description", pkg_desc=desc, pkg=pkg) + elif s.startswith(lower_pn) and s.removeprefix(lower_pn).startswith( + (" is", " -", ":", ",") + ): + yield BadDescription("repeats package name", pkg_desc=desc, pkg=pkg) elif desc.endswith(tuple(".,:;")) and not desc.lower().endswith( ("etc.", "co.", "inc.", "ltd.", "...") ): diff --git a/testdata/data/repos/standalone/DescriptionCheck/BadDescription/expected.json b/testdata/data/repos/standalone/DescriptionCheck/BadDescription/expected.json index d8382e964..f70c1afef 100644 --- a/testdata/data/repos/standalone/DescriptionCheck/BadDescription/expected.json +++ b/testdata/data/repos/standalone/DescriptionCheck/BadDescription/expected.json @@ -3,3 +3,4 @@ {"__class__": "BadDescription", "category": "DescriptionCheck", "package": "BadDescription", "version": "2", "msg": "under 10 chars in length", "pkg_desc": "bad desc"} {"__class__": "BadDescription", "category": "DescriptionCheck", "package": "BadDescription", "version": "3", "msg": "generic package description", "pkg_desc": "BadDescription"} {"__class__": "BadDescription", "category": "DescriptionCheck", "package": "BadDescription", "version": "4", "msg": "over 80 chars in length", "pkg_desc": null} +{"__class__": "BadDescription", "category": "DescriptionCheck", "package": "BadDescription", "version": "5", "msg": "repeats package name", "pkg_desc": "badDESCRIPTION is a test ebuild"} diff --git a/testdata/data/repos/standalone/DescriptionCheck/BadDescription/fix.patch b/testdata/data/repos/standalone/DescriptionCheck/BadDescription/fix.patch index 85a917c24..7c33edb4b 100644 --- a/testdata/data/repos/standalone/DescriptionCheck/BadDescription/fix.patch +++ b/testdata/data/repos/standalone/DescriptionCheck/BadDescription/fix.patch @@ -42,3 +42,12 @@ diff -Naur standalone/DescriptionCheck/BadDescription/BadDescription-4.ebuild fi HOMEPAGE="https://github.com/pkgcore/pkgcheck" LICENSE="BSD" SLOT="0" +diff -Naur standalone/DescriptionCheck/BadDescription/BadDescription-5.ebuild fixed/DescriptionCheck/BadDescription/BadDescription-5.ebuild +--- standalone/DescriptionCheck/BadDescription/BadDescription-5.ebuild 2019-11-28 00:33:38.457040594 -0700 ++++ fixed/DescriptionCheck/BadDescription/BadDescription-5.ebuild 2019-11-28 00:34:59.065514420 -0700 +@@ -1,4 +1,4 @@ +-DESCRIPTION="badDESCRIPTION is a test ebuild" ++DESCRIPTION="Test ebuild" + HOMEPAGE="https://github.com/pkgcore/pkgcheck" + LICENSE="BSD" + SLOT="0" diff --git a/testdata/repos/standalone/DescriptionCheck/BadDescription/BadDescription-5.ebuild b/testdata/repos/standalone/DescriptionCheck/BadDescription/BadDescription-5.ebuild new file mode 100644 index 000000000..857f42cb9 --- /dev/null +++ b/testdata/repos/standalone/DescriptionCheck/BadDescription/BadDescription-5.ebuild @@ -0,0 +1,4 @@ +DESCRIPTION="badDESCRIPTION is a test ebuild" +HOMEPAGE="https://github.com/pkgcore/pkgcheck" +LICENSE="BSD" +SLOT="0"