From 5238f3d5df712068e905be5b59cd765d56b9af39 Mon Sep 17 00:00:00 2001 From: MyungJoo Ham Date: Thu, 16 Mar 2017 15:48:42 +0900 Subject: RULE: add rule 1-9. error report format added Change-Id: I853d32187ab7697daa9f7dbb71321acae72a35d5 Signed-off-by: MyungJoo Ham --- RULES | 2 ++ rule_checker.py | 25 ++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/RULES b/RULES index b042e22..85ce751 100644 --- a/RULES +++ b/RULES @@ -28,6 +28,8 @@ 1-8. In order to implement "radio-button" UI (choose only one), the block name starts with "chooseonlyone_" E.g., "building-blocks-root-chooseonlyone_Kernel" +1-9. [NAME] = [a-zA-Z0-9_]+ + =========================================================================== diff --git a/rule_checker.py b/rule_checker.py index e17f6d0..539ee8a 100755 --- a/rule_checker.py +++ b/rule_checker.py @@ -16,10 +16,13 @@ import os import os.path import sys +def report(file, lc, code): + print(file + ":Line " + str(lc) + " |"+code) def ruleCheckInc(file): error = 0 warning = 0 + lc = 0 try: f = open("packaging/"+file, 'r') @@ -28,6 +31,7 @@ def ruleCheckInc(file): print("WARNING: cannot find packaging/"+file) return (0, 1) for line in f: + lc += 1 # RULE 5.1 if re.search('^\s*BuildRequires', line, re.IGNORECASE): error += 1 @@ -38,6 +42,7 @@ def ruleCheckInc(file): 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.") + report(file, lc, line) continue # RULE 5.2 @@ -47,21 +52,39 @@ def ruleCheckInc(file): re.search('^\s*Supplements', line, re.IGNORECASE): error += 1 print("ERROR: RULE 5.2 .inc file cannot have unsupported relations") + report(file, lc, line) + continue # RULE 1-1 if re.search('^\s*%package\s*-n', line, re.IGNORECASE): error += 1 print("ERROR: RULE 1.1 to ensure 1.1, do not use -n option in package name") + report(file, lc, line) + continue # Implicit / General Rule if re.search('^\s*%package\s', line, re.IGNORECASE) and not re.search('^\s*%package\s', line): error += 1 print('ERROR: (General) Please use %package, not '+re.search('^%package')) + report(file, lc, line) + continue - # RULE 1-3 + # RULE 1-3 / 1-4 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.") + report(file, lc, line) + continue + + # RULE 1-5 + 1-9 / there is - in the name + if re.search('^\s*%package\s*root', line) and \ + not re.search('^\s*%package\s*root-[a-zA-Z0-9_]*\s*$', line): + error += 1 + print("ERROR: RULE 1.9 not met with root (RULE 1.5)") + report(file, lc, line) + continue + + -- cgit v1.2.3