diff options
author | Zac Medico <zmedico@gentoo.org> | 2007-11-01 02:25:18 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2007-11-01 02:25:18 +0000 |
commit | e0f037138a16a8d3d608fdd1a1fd23f06df5c6f3 (patch) | |
tree | eab6b5c83172c3d7a40615d908884deb64f6b65d /pym/repoman/checks.py | |
parent | 052bd7b2a0acf97e890e59fa1693077b8aaae2e8 (diff) | |
download | portage-e0f037138a16a8d3d608fdd1a1fd23f06df5c6f3.tar.gz portage-e0f037138a16a8d3d608fdd1a1fd23f06df5c6f3.tar.bz2 portage-e0f037138a16a8d3d608fdd1a1fd23f06df5c6f3.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.
svn path=/main/trunk/; revision=8351
Diffstat (limited to 'pym/repoman/checks.py')
-rw-r--r-- | pym/repoman/checks.py | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/pym/repoman/checks.py b/pym/repoman/checks.py index 93c3222b3..eea7ba40f 100644 --- a/pym/repoman/checks.py +++ b/pym/repoman/checks.py @@ -9,7 +9,7 @@ import os from repoman.errors import COPYRIGHT_ERROR, LICENSE_ERROR, CVS_HEADER_ERROR, \ LEADING_SPACES_ERROR, READONLY_ASSIGNMENT_ERROR, TRAILING_WHITESPACE_ERROR, \ - MISSING_QUOTES_ERROR, NESTED_DIE_ERROR + MISSING_QUOTES_ERROR, NESTED_DIE_ERROR, REDUNDANT_CD_S_ERROR class ContentCheckException(Exception): @@ -243,3 +243,24 @@ class EbuildUselessDodoc(ContentCheck): errors.append((num + 1, "Useless dodoc '%s'" % \ (match.group(2), ) + " on line: %d")) return errors + +class EbuildUselessCdS(ContentCheck): + """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') + + def __init__(self, contents): + ContentCheck.__init__(self, 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, REDUNDANT_CD_S_ERROR)) + elif self.method_re.match(line): + check_next_line = True + return errors |