diff options
author | Zac Medico <zmedico@gentoo.org> | 2007-11-02 07:24:55 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2007-11-02 07:24:55 +0000 |
commit | dd134813921499946a6c05a859c0c5bc6fa84473 (patch) | |
tree | c863bba89c72e0f85d0d91440fd8c458c872a6e7 | |
parent | 0d75c2965c4da7cc0d95eb3816280d8beaf74602 (diff) | |
download | portage-dd134813921499946a6c05a859c0c5bc6fa84473.tar.gz portage-dd134813921499946a6c05a859c0c5bc6fa84473.tar.bz2 portage-dd134813921499946a6c05a859c0c5bc6fa84473.zip |
Add a check for redundant cd "${S}" statements on the first
line of src_(compile|install|test) ebuild methods. Thanks to
Petteri Räty <betelgeuse@gentoo.org> for this patch.
(trunk r8351 and r8353)
svn path=/main/branches/2.1.2/; revision=8376
-rwxr-xr-x | bin/repoman | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/bin/repoman b/bin/repoman index 328aec4ec..84033318a 100755 --- a/bin/repoman +++ b/bin/repoman @@ -836,6 +836,28 @@ class EbuildUselessDodoc(object): (match.group(2), ) + " on line: %d")) return errors +class EbuildUselessCdS(object): + """Check for redundant cd ${S} statements""" + repoman_check_name = 'ebuild.minorsyn' + method_re = re.compile(r'^\s*src_(compile|install|test)\s*\(\)') + cds_re = re.compile(r'^\s*cd\s+("\$(\{S\}|S)"|\$(\{S\}|S))\s') + + def __init__(self, contents): + self.contents = contents + + def Run(self): + errors = [] + check_next_line = False + for num, line in enumerate(self.contents): + if check_next_line: + check_next_line = False + if self.cds_re.match(line): + errors.append((num + 1, + 'Ebuild has redundant cd ${S} statement on line: %d')) + elif self.method_re.match(line): + check_next_line = True + return errors + if mymode == "commit": retval = ("","") if isCvs: @@ -1459,7 +1481,7 @@ for x in scanlist: finally: f.close() del f - for check in (EbuildQuote, EbuildUselessDodoc): + for check in (EbuildQuote, EbuildUselessDodoc, EbuildUselessCdS): c = check(contents) errors = c.Run() for e in errors: |