Rename checks as the naming was overkill (they are all obviously checks being in...
authorAlec Warner <antarus@gentoo.org>
Mon, 1 Oct 2007 12:27:45 +0000 (12:27 -0000)
committerAlec Warner <antarus@gentoo.org>
Mon, 1 Oct 2007 12:27:45 +0000 (12:27 -0000)
svn path=/main/trunk/; revision=7898

pym/repoman/checks.py
pym/repoman/errors.py

index ac79b990ec88dbbd4f9360a27cd3aa0427e02278..7ec670804a4b49a555fa8e6e69c7338205e891d1 100644 (file)
@@ -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
index c8734ff4d182f85bc0be052db6bdb061009339de..8378ed4d8ca16a7cf276ecc1ee0cb862cdc6bb91 100644 (file)
@@ -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'