Skip to content

Commit 3c9508b

Browse files
committed
DescriptionCheck: catch ending with a full stop
Bug: https://bugs.gentoo.org/729968 Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org> Signed-off-by: Michał Górny <mgorny@gentoo.org> Closes: #472
1 parent ee2563c commit 3c9508b

5 files changed

Lines changed: 37 additions & 11 deletions

File tree

NEWS.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ pkgcheck 0.10.40 (unreleased)
1414
- StabilizationGroupsCheck: check for invalid and non-existant stabilization
1515
groups (Arthur Zamarin)
1616

17+
- DescriptionCheck: check for descriptions ending with a full-stop (Arthur
18+
Zamarin, Michał Górny, #472)
19+
1720

1821
**Packaging:**
1922

src/pkgcheck/checks/metadata.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,18 +1515,22 @@ class DescriptionCheck(Check):
15151515
"""DESCRIPTION checks.
15161516
15171517
Check on length (<=80), too short (<10), or generic (lifted from eclass or
1518-
just using the package's name).
1518+
just using the package's name), or ending with a full stop.
15191519
"""
15201520

15211521
known_results = frozenset([BadDescription])
15221522

15231523
def feed(self, pkg):
1524-
desc = pkg.description
1524+
desc: str = pkg.description
15251525
s = desc.lower()
15261526
if s.startswith("based on") and "eclass" in s:
15271527
yield BadDescription("generic eclass defined description", pkg_desc=desc, pkg=pkg)
15281528
elif s in (pkg.package.lower(), pkg.key.lower()):
15291529
yield BadDescription("generic package description", pkg_desc=desc, pkg=pkg)
1530+
elif desc.endswith(tuple(".,:;")) and not desc.lower().endswith(
1531+
("etc.", "co.", "inc.", "ltd.", "...")
1532+
):
1533+
yield BadDescription("ends with a full stop", pkg_desc=desc, pkg=pkg)
15301534
else:
15311535
desc_len = len(desc)
15321536
if not desc_len:

testdata/data/repos/standalone/DescriptionCheck/BadDescription/fix.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ diff -Naur standalone/DescriptionCheck/BadDescription/BadDescription-4.ebuild fi
3737
--- standalone/DescriptionCheck/BadDescription/BadDescription-4.ebuild 2019-11-28 00:33:38.457040594 -0700
3838
+++ fixed/DescriptionCheck/BadDescription/BadDescription-4.ebuild 2019-11-28 00:34:59.065514420 -0700
3939
@@ -1,4 +1,4 @@
40-
-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."
40+
-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"
4141
+DESCRIPTION="Ebuild with a sane DESCRIPTION"
4242
HOMEPAGE="https://github.com/pkgcore/pkgcheck"
4343
LICENSE="BSD"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
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."
1+
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"
22
HOMEPAGE="https://github.com/pkgcore/pkgcheck"
33
LICENSE="BSD"
44
SLOT="0"

tests/checks/test_metadata.py

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,32 @@ class TestDescriptionCheck(misc.ReportTestCase):
2626
def mk_pkg(self, desc=""):
2727
return misc.FakePkg("dev-util/diffball-0.7.1", data={"DESCRIPTION": desc})
2828

29-
def test_good_desc(self):
30-
self.assertNoReport(self.check, self.mk_pkg("a perfectly written package description"))
31-
32-
def test_bad_descs(self):
33-
for desc in ("based on eclass", "diffball", "dev-util/diffball", "foon"):
34-
r = self.assertReport(self.check, self.mk_pkg(desc))
35-
assert isinstance(r, metadata.BadDescription)
29+
@pytest.mark.parametrize(
30+
"desc",
31+
(
32+
"a perfectly written package description",
33+
"foo, bar, etc.",
34+
"something something something...",
35+
),
36+
)
37+
def test_good_desc(self, desc: str):
38+
self.assertNoReport(self.check, self.mk_pkg(desc))
39+
40+
@pytest.mark.parametrize(
41+
"desc",
42+
(
43+
"based on eclass",
44+
"diffball",
45+
"dev-util/diffball",
46+
"foon",
47+
"some kind of description.",
48+
"some kind of description,",
49+
"some kind of description..",
50+
),
51+
)
52+
def test_bad_descs(self, desc: str):
53+
r = self.assertReport(self.check, self.mk_pkg(desc))
54+
assert isinstance(r, metadata.BadDescription)
3655

3756
def test_desc_length(self):
3857
r = self.assertReport(self.check, self.mk_pkg())

0 commit comments

Comments
 (0)