From adee35e2b7d51bba4228c86ac78f2a554aa56361 Mon Sep 17 00:00:00 2001 From: "Apekshit(Appy) Sharma" Date: Fri, 20 Nov 2015 04:15:32 -0800 Subject: [PATCH] HBASE-14859 Better checkstyle reporting. Reports file names, error names and old/new error counts. (Apekshit) --- dev-support/checkstyle_report.py | 41 ++++++++++++++++++++++++++++------------ dev-support/test-patch.sh | 10 ++++------ 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/dev-support/checkstyle_report.py b/dev-support/checkstyle_report.py index 82f7675..0b700b9 100755 --- a/dev-support/checkstyle_report.py +++ b/dev-support/checkstyle_report.py @@ -36,28 +36,45 @@ def path_key(x): path = x.attrib['name'] return path[path.find('hbase-'):] -def print_row(path, master_errors, patch_errors): - print '%s\t%s\t%s' % (path,master_errors,patch_errors) +def error_name(x): + error_class = x.attrib['source'] + return error_class[error_class.rfind(".") + 1:] + +def print_row(path, error, master_errors, patch_errors): + print '%s\t%s\t%s\t%s' % (path,error, master_errors,patch_errors) master = etree.parse(sys.argv[1]) patch = etree.parse(sys.argv[2]) master_dict = defaultdict(int) +ret_value = 0 for child in master.getroot().getchildren(): if child.tag != 'file': continue - child_errors = len(child.getchildren()) - if child_errors == 0: - continue - master_dict[path_key(child)] = child_errors + file = path_key(child) + for error_tag in child.getchildren(): + error = error_name(error_tag) + if (file, error) in master_dict: + master_dict[(file, error)] += 1 + else: + master_dict[(file, error)] = 1 for child in patch.getroot().getchildren(): if child.tag != 'file': continue - child_errors = len(child.getchildren()) - if child_errors == 0: - continue - k = path_key(child) - if child_errors > master_dict[k]: - print_row(k, master_dict[k], child_errors) + temp_dict = defaultdict(int) + for error_tag in child.getchildren(): + error = error_name(error_tag) + if error in temp_dict: + temp_dict[error] += 1 + else: + temp_dict[error] = 1 + + file = path_key(child) + for error, count in temp_dict.iteritems(): + if count > master_dict[(file, error)]: + print_row(file, error, master_dict[(file, error)], count) + ret_value = 1 + +sys.exit(ret_value) diff --git a/dev-support/test-patch.sh b/dev-support/test-patch.sh index c6ea897..99ae82e 100755 --- a/dev-support/test-patch.sh +++ b/dev-support/test-patch.sh @@ -659,19 +659,17 @@ checkCheckstyleErrors() { mv target/checkstyle-result.xml $PATCH_DIR/patchCheckstyle.xml mv target/site/checkstyle-aggregate.html $PATCH_DIR mv target/site/checkstyle.css $PATCH_DIR - trunkCheckstyleErrors=`$GREP '