diff --git a/src/pkgcheck/checks/metadata.py b/src/pkgcheck/checks/metadata.py index 25bbfad0d..a6be2c4e9 100644 --- a/src/pkgcheck/checks/metadata.py +++ b/src/pkgcheck/checks/metadata.py @@ -1515,18 +1515,22 @@ class DescriptionCheck(Check): """DESCRIPTION checks. Check on length (<=80), too short (<10), or generic (lifted from eclass or - just using the package's name). + just using the package's name), or ending with a full stop. """ known_results = frozenset([BadDescription]) def feed(self, pkg): - desc = pkg.description + desc: str = pkg.description s = desc.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()): yield BadDescription("generic package description", pkg_desc=desc, pkg=pkg) + elif desc.endswith(tuple(".,:;")) and not desc.lower().endswith( + ("etc.", "co.", "inc.", "ltd.", "...") + ): + yield BadDescription("ends with a full stop", pkg_desc=desc, pkg=pkg) else: desc_len = len(desc) if not desc_len: diff --git a/testdata/data/repos/standalone/DescriptionCheck/BadDescription/fix.patch b/testdata/data/repos/standalone/DescriptionCheck/BadDescription/fix.patch index 9500e2b12..85a917c24 100644 --- a/testdata/data/repos/standalone/DescriptionCheck/BadDescription/fix.patch +++ b/testdata/data/repos/standalone/DescriptionCheck/BadDescription/fix.patch @@ -37,7 +37,7 @@ diff -Naur standalone/DescriptionCheck/BadDescription/BadDescription-4.ebuild fi --- standalone/DescriptionCheck/BadDescription/BadDescription-4.ebuild 2019-11-28 00:33:38.457040594 -0700 +++ fixed/DescriptionCheck/BadDescription/BadDescription-4.ebuild 2019-11-28 00:34:59.065514420 -0700 @@ -1,4 +1,4 @@ --DESCRIPTION="Ebuild with DESCRIPTION that is far too long and will be flagged by the BadDescription result since the check triggers at greater than 150 characters long." +-DESCRIPTION="Ebuild with DESCRIPTION that is far too long and will be flagged by the BadDescription result since the check triggers at greater than 150 characters long" +DESCRIPTION="Ebuild with a sane DESCRIPTION" HOMEPAGE="https://github.com/pkgcore/pkgcheck" LICENSE="BSD" diff --git a/testdata/repos/standalone/DescriptionCheck/BadDescription/BadDescription-4.ebuild b/testdata/repos/standalone/DescriptionCheck/BadDescription/BadDescription-4.ebuild index f4d9a2296..8e823634a 100644 --- a/testdata/repos/standalone/DescriptionCheck/BadDescription/BadDescription-4.ebuild +++ b/testdata/repos/standalone/DescriptionCheck/BadDescription/BadDescription-4.ebuild @@ -1,4 +1,4 @@ -DESCRIPTION="Ebuild with DESCRIPTION that is far too long and will be flagged by the BadDescription result since the check triggers at greater than 150 characters long." +DESCRIPTION="Ebuild with DESCRIPTION that is far too long and will be flagged by the BadDescription result since the check triggers at greater than 150 characters long" HOMEPAGE="https://github.com/pkgcore/pkgcheck" LICENSE="BSD" SLOT="0" diff --git a/tests/checks/test_metadata.py b/tests/checks/test_metadata.py index 30b1eceba..a1cd09379 100644 --- a/tests/checks/test_metadata.py +++ b/tests/checks/test_metadata.py @@ -26,13 +26,32 @@ class TestDescriptionCheck(misc.ReportTestCase): def mk_pkg(self, desc=""): return misc.FakePkg("dev-util/diffball-0.7.1", data={"DESCRIPTION": desc}) - def test_good_desc(self): - self.assertNoReport(self.check, self.mk_pkg("a perfectly written package description")) - - def test_bad_descs(self): - for desc in ("based on eclass", "diffball", "dev-util/diffball", "foon"): - r = self.assertReport(self.check, self.mk_pkg(desc)) - assert isinstance(r, metadata.BadDescription) + @pytest.mark.parametrize( + "desc", + ( + "a perfectly written package description", + "foo, bar, etc.", + "something something something...", + ), + ) + def test_good_desc(self, desc: str): + self.assertNoReport(self.check, self.mk_pkg(desc)) + + @pytest.mark.parametrize( + "desc", + ( + "based on eclass", + "diffball", + "dev-util/diffball", + "foon", + "some kind of description.", + "some kind of description,", + "some kind of description..", + ), + ) + def test_bad_descs(self, desc: str): + r = self.assertReport(self.check, self.mk_pkg(desc)) + assert isinstance(r, metadata.BadDescription) def test_desc_length(self): r = self.assertReport(self.check, self.mk_pkg())