from repoman.errors import COPYRIGHT_ERROR, LICENSE_ERROR, CVS_HEADER_ERROR, \
LEADING_SPACES_ERROR, READONLY_ASSIGNMENT_ERROR, TRAILING_WHITESPACE_ERROR, \
- MISSING_QUOTES_ERROR
+ MISSING_QUOTES_ERROR, NESTED_DIE_ERROR
class ContentCheckException(Exception):
pass
-class EbuildHeaderCheck(ContentCheck):
+class EbuildHeader(ContentCheck):
"""Ensure ebuilds have proper headers
Args:
return errors
-class EbuildWhitespaceCheck(ContentCheck):
+class EbuildWhitespace(ContentCheck):
"""Ensure ebuilds have proper whitespacing"""
repoman_check_name = 'ebuild.minorsyn'
return errors
-class EbuildQuoteCheck(ContentCheck):
+class EbuildQuote(ContentCheck):
"""Ensure ebuilds have valid quoting around things like D,FILESDIR, etc..."""
repoman_check_name = 'ebuild.minorsyn'
return errors
-class EbuildAssignmentCheck(ContentCheck):
+class EbuildAssignment(ContentCheck):
"""Ensure ebuilds don't assign to readonly variables."""
repoman_check_name = 'variable.readonly'
errors.append((num + 1, READONLY_ASSIGNMENT_ERROR))
previous_line = line
return errors
+
+class EbuildNestedDie(ContentCheck):
+ """Check ebuild for nested die statements (die statements in subshells"""
+
+ repoman_check_name = 'ebuild.nesteddie'
+ nesteddie_re = re.compile(r'^[^#]*\([^)]*\bdie\b')
+
+ def __init__(self, contents):
+ ContentCheck.__init__(self, contents)
+
+ def Run(self):
+ errors = []
+ for num, line in enumerate(self.contents):
+ match = self.nesteddie_re.match(line)
+ if match:
+ errors.append((num + 1, NESTED_DIE_ERROR))
+ return errors
LEADING_SPACES_ERROR = 'Ebuild contains leading spaces on line: %d'
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'
\ No newline at end of file
+MISSING_QUOTES_ERROR = 'Unquoted Variable on line: %d'
+NESTED_DIE_ERROR = 'Ebuild calls die in a subshell'