(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:
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: