From 06c25cd3f55b72d5c92555e4f3f25af83a19466a Mon Sep 17 00:00:00 2001 From: Alec Warner Date: Mon, 1 Oct 2007 12:27:45 +0000 Subject: [PATCH] Rename checks as the naming was overkill (they are all obviously checks being in the check module), add nesteddie check svn path=/main/trunk/; revision=7898 --- pym/repoman/checks.py | 27 ++++++++++++++++++++++----- pym/repoman/errors.py | 3 ++- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/pym/repoman/checks.py b/pym/repoman/checks.py index ac79b990e..7ec670804 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 + MISSING_QUOTES_ERROR, NESTED_DIE_ERROR class ContentCheckException(Exception): @@ -41,7 +41,7 @@ class ContentCheck(object): pass -class EbuildHeaderCheck(ContentCheck): +class EbuildHeader(ContentCheck): """Ensure ebuilds have proper headers Args: @@ -84,7 +84,7 @@ class EbuildHeaderCheck(ContentCheck): return errors -class EbuildWhitespaceCheck(ContentCheck): +class EbuildWhitespace(ContentCheck): """Ensure ebuilds have proper whitespacing""" repoman_check_name = 'ebuild.minorsyn' @@ -114,7 +114,7 @@ class EbuildWhitespaceCheck(ContentCheck): return errors -class EbuildQuoteCheck(ContentCheck): +class EbuildQuote(ContentCheck): """Ensure ebuilds have valid quoting around things like D,FILESDIR, etc...""" repoman_check_name = 'ebuild.minorsyn' @@ -146,7 +146,7 @@ class EbuildQuoteCheck(ContentCheck): return errors -class EbuildAssignmentCheck(ContentCheck): +class EbuildAssignment(ContentCheck): """Ensure ebuilds don't assign to readonly variables.""" repoman_check_name = 'variable.readonly' @@ -175,3 +175,20 @@ class EbuildAssignmentCheck(ContentCheck): 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 diff --git a/pym/repoman/errors.py b/pym/repoman/errors.py index c8734ff4d..8378ed4d8 100644 --- a/pym/repoman/errors.py +++ b/pym/repoman/errors.py @@ -9,4 +9,5 @@ CVS_HEADER_ERROR = 'Malformed CVS Header on line: %d' 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' -- 2.26.2