Bug #196652 - Check for useless ABOUT-NLS|COPYING|LICENSE
authorZac Medico <zmedico@gentoo.org>
Tue, 23 Oct 2007 00:27:33 +0000 (00:27 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 23 Oct 2007 00:27:33 +0000 (00:27 -0000)
files in dodoc arguments.

svn path=/main/trunk/; revision=8236

bin/repoman
pym/repoman/checks.py

index c133eb02d56942324939a850047c9d55d0d35196..01a7f61bbf3144ee570172d0798b36376da95769 100755 (executable)
@@ -51,12 +51,12 @@ del os.environ["PORTAGE_LEGACY_GLOBALS"]
 
 try:
        from repoman.checks import EbuildWhitespace, EbuildHeader, EbuildQuote, \
-               EbuildAssignment, EbuildNestedDie
+               EbuildAssignment, EbuildNestedDie, EbuildUselessDodoc
 except ImportError:
        from os import path as osp
        sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), 'pym'))
        from repoman.checks import EbuildWhitespace, EbuildHeader, EbuildQuote, \
-               EbuildAssignment, EbuildNestedDie
+               EbuildAssignment, EbuildNestedDie, EbuildUselessDodoc
 
 import portage.checksum
 import portage.const
@@ -1382,7 +1382,8 @@ for x in scanlist:
                path = checkdir + '/' + y + '.ebuild'
                myear = time.gmtime(os.stat(path)[ST_MTIME])[0]
                contents = StringIO.StringIO(open(path, 'rb').read())
-               for check in (EbuildWhitespace, EbuildQuote, EbuildAssignment):
+               for check in (EbuildWhitespace, EbuildQuote,
+                       EbuildAssignment, EbuildUselessDodoc):
                        c = check(contents)
                        errors = c.Run()
                        for e in errors:
index d956b83f8f3a0e7488d614bfc8fbc39322e1cbc2..93c3222b338debfddd36ca10743b1b49d0a6940d 100644 (file)
@@ -224,3 +224,22 @@ class EbuildNestedDie(ContentCheck):
                        if match:
                                errors.append((num + 1, NESTED_DIE_ERROR))
                return errors
+
+class EbuildUselessDodoc(ContentCheck):
+       """Check ebuild for useless files in dodoc arguments."""
+       repoman_check_name = 'ebuild.minorsyn'
+       uselessdodoc_re = re.compile(
+               r'^\s*dodoc(\s+|\s+.*\s+)(ABOUT-NLS|COPYING|LICENSE)($|\s)')
+
+       def __init__(self, contents):
+               ContentCheck.__init__(self, contents)
+
+       def Run(self):
+               errors = []
+               uselessdodoc_re = self.uselessdodoc_re
+               for num, line in enumerate(self.contents):
+                       match = uselessdodoc_re.match(line)
+                       if match:
+                               errors.append((num + 1, "Useless dodoc '%s'" % \
+                                       (match.group(2), ) + " on line: %d"))
+               return errors