summaryrefslogtreecommitdiffstats
path: root/pym/repoman
diff options
context:
space:
mode:
Diffstat (limited to 'pym/repoman')
-rw-r--r--pym/repoman/checks.py23
-rw-r--r--pym/repoman/errors.py1
2 files changed, 23 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
diff --git a/pym/repoman/errors.py b/pym/repoman/errors.py
index 8378ed4d8..3b3b3c179 100644
--- a/pym/repoman/errors.py
+++ b/pym/repoman/errors.py
@@ -11,3 +11,4 @@ TRAILING_WHITESPACE_ERROR = 'Trailing whitespace error on line: %d'
READONLY_ASSIGNMENT_ERROR = 'Ebuild contains assignment to read-only variable on line: %d'
MISSING_QUOTES_ERROR = 'Unquoted Variable on line: %d'
NESTED_DIE_ERROR = 'Ebuild calls die in a subshell'
+REDUNDANT_CD_S_ERROR = 'Ebuild has redundant cd ${S} statement on line: %d'