RULE: rule checker bugfix 35/119235/1
authorMyungJoo Ham <myungjoo.ham@samsung.com>
Thu, 16 Mar 2017 06:01:10 +0000 (15:01 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Thu, 16 Mar 2017 06:01:10 +0000 (15:01 +0900)
Change-Id: Ia230691e39b426fbf07df5f146d8e890f5b776a2
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
rule_checker.py

index 75d909c..068a36e 100755 (executable)
@@ -35,15 +35,15 @@ def ruleCheckInc(file):
            continue
 
         # Prevent: https://github.com/rpm-software-management/rpm/issues/158
-       if re.search('^#.*[^%]%[^%]', line) and !re.search('^#!', line):
+       if re.search('^#.*[^%]%[^%]', line) and not re.search('^#!', line):
            error += 1
            print("ERROR: unless it is shebang, you must not have rpm macro in a # comment. They are expanded and multiline macro will do unexpected effects.")
            continue
 
         # RULE 5.2
-       if re.search('^\s*Recommends', line, re.IGNORECASE) or
-           re.search('^\s*Provides', line, re.IGNORECASE) or
-           re.search('^\s*Enhances', line, re.IGNORECASE) or
+       if re.search('^\s*Recommends', line, re.IGNORECASE) or  \
+           re.search('^\s*Provides', line, re.IGNORECASE) or   \
+           re.search('^\s*Enhances', line, re.IGNORECASE) or   \
            re.search('^\s*Supplements', line, re.IGNORECASE):
            error += 1
            print("ERROR: RULE 5.2 .inc file cannot have unsupported relations")
@@ -54,9 +54,9 @@ def ruleCheckInc(file):
            print("ERROR: RULE 1.1 to ensure 1.1, do not use -n option in package name")
 
        # RULE 1-3
-       if !re.search('^\s*%package\s*(root)|(sub1)|(sub2)'):
+       if re.search('^\s*%package', line) and not re.search('^\s*%package\s*(root)|(sub1)|(sub2)', line):
            error +=1
-           print("ERROR: RULE 1.3 the send prefix should be root, sub1, or sub2")
+           print("ERROR: RULE 1.3 the send prefix should be root, sub1, or sub2.")
 
            
 
@@ -79,8 +79,8 @@ def main():
            error += result[0]
            warning += result[1]
 
-    print('Error: '+error)
-    print('Warning: '+warning)
+    print('Error: '+str(error))
+    print('Warning: '+str(warning))
 
     return error