From 27d30743051f2ecfda20b11eeda3a19cb5fa12eb Mon Sep 17 00:00:00 2001 From: Crt Mori Date: Thu, 16 Aug 2018 09:07:35 +0200 Subject: [PATCH 1/4] Fail gracefully when there are no defects in stream --- mlx/coverity.py | 75 +++++++++++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 36 deletions(-) diff --git a/mlx/coverity.py b/mlx/coverity.py index e7129d0c..b837c9b8 100644 --- a/mlx/coverity.py +++ b/mlx/coverity.py @@ -211,42 +211,45 @@ def process_coverity_nodes(app, doctree, fromdocname): report_info(env, "%d received" % (defects['totalNumberOfRecords'])) report_info(env, "building defects table... ", True) - for defect in defects['mergedDefects']: - row = nodes.row() - - # go through each col and decide if it is there or we print empty - for item_col in node['col']: - if 'CID' == item_col: - # CID is default and even if it is in disregard - row += create_cell(str(defect['cid']), - url=coverity_service.get_defect_url(app.config.coverity_credentials['stream'], - str(defect['cid']))) - elif 'Category' == item_col: - row += create_cell(defect['displayCategory']) - elif 'Impact' == item_col: - row += create_cell(defect['displayImpact']) - elif 'Issue' == item_col: - row += create_cell(defect['displayIssueKind']) - elif 'Type' == item_col: - row += create_cell(defect['displayType']) - elif 'Checker' == item_col: - row += create_cell(defect['checkerName']) - elif 'Component' == item_col: - row += create_cell(defect['componentName']) - elif 'Comment' == item_col: - row += cov_attribute_value_to_col(defect, 'Comment') - elif 'Classification' == item_col: - row += cov_attribute_value_to_col(defect, 'Classification') - elif 'Action' == item_col: - row += cov_attribute_value_to_col(defect, 'Action') - elif 'Status' == item_col: - row += cov_attribute_value_to_col(defect, 'DefectStatus') - else: - # generic check which if it is missing prints empty cell anyway - row += cov_attribute_value_to_col(defect, item_col) - - tbody += row - report_info(env, "done") + try: + for defect in defects['mergedDefects']: + row = nodes.row() + + # go through each col and decide if it is there or we print empty + for item_col in node['col']: + if 'CID' == item_col: + # CID is default and even if it is in disregard + row += create_cell(str(defect['cid']), + url=coverity_service.get_defect_url(app.config.coverity_credentials['stream'], + str(defect['cid']))) + elif 'Category' == item_col: + row += create_cell(defect['displayCategory']) + elif 'Impact' == item_col: + row += create_cell(defect['displayImpact']) + elif 'Issue' == item_col: + row += create_cell(defect['displayIssueKind']) + elif 'Type' == item_col: + row += create_cell(defect['displayType']) + elif 'Checker' == item_col: + row += create_cell(defect['checkerName']) + elif 'Component' == item_col: + row += create_cell(defect['componentName']) + elif 'Comment' == item_col: + row += cov_attribute_value_to_col(defect, 'Comment') + elif 'Classification' == item_col: + row += cov_attribute_value_to_col(defect, 'Classification') + elif 'Action' == item_col: + row += cov_attribute_value_to_col(defect, 'Action') + elif 'Status' == item_col: + row += cov_attribute_value_to_col(defect, 'DefectStatus') + else: + # generic check which if it is missing prints empty cell anyway + row += cov_attribute_value_to_col(defect, item_col) + + tbody += row + report_info(env, "done") + except AttributeError as e: + report_warning(env, 'Empty stream? Error: %s' % e) top_node += table node.replace_self(top_node) # try: From 280c3705b238ad85a4b8bfce8f6744b0771fbf16 Mon Sep 17 00:00:00 2001 From: Crt Mori Date: Thu, 16 Aug 2018 11:21:35 +0200 Subject: [PATCH 2/4] Covering up a flake error with the commented noqa Labeled too long line (for 1 character too long) with flake disregard label and now the line is even longer. The irony of our tools :wink: --- mlx/coverity.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mlx/coverity.py b/mlx/coverity.py index b837c9b8..ce3fed46 100644 --- a/mlx/coverity.py +++ b/mlx/coverity.py @@ -220,7 +220,7 @@ def process_coverity_nodes(app, doctree, fromdocname): if 'CID' == item_col: # CID is default and even if it is in disregard row += create_cell(str(defect['cid']), - url=coverity_service.get_defect_url(app.config.coverity_credentials['stream'], + url=coverity_service.get_defect_url(app.config.coverity_credentials['stream'], # noqa: E501 str(defect['cid']))) elif 'Category' == item_col: row += create_cell(defect['displayCategory']) From b81d1dfa50540e71003245ac77ae38bc547e975f Mon Sep 17 00:00:00 2001 From: Crt Mori Date: Fri, 24 Aug 2018 15:17:23 +0200 Subject: [PATCH 3/4] Making it info just in case there are no issues in stream indeed --- mlx/coverity.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mlx/coverity.py b/mlx/coverity.py index ce3fed46..c050ce90 100644 --- a/mlx/coverity.py +++ b/mlx/coverity.py @@ -249,7 +249,7 @@ def process_coverity_nodes(app, doctree, fromdocname): tbody += row report_info(env, "done") except AttributeError as e: - report_warning(env, 'Empty stream? Error: %s' % e) + report_info(env, 'No issues matching your query or empty stream. %s' % e) top_node += table node.replace_self(top_node) # try: From a4962b57338875b9e0b22d6600c80e9e8a4effa6 Mon Sep 17 00:00:00 2001 From: Crt Mori Date: Fri, 24 Aug 2018 15:56:43 +0200 Subject: [PATCH 4/4] Adding also info to table --- mlx/coverity.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mlx/coverity.py b/mlx/coverity.py index c050ce90..6963a176 100644 --- a/mlx/coverity.py +++ b/mlx/coverity.py @@ -250,6 +250,10 @@ def process_coverity_nodes(app, doctree, fromdocname): report_info(env, "done") except AttributeError as e: report_info(env, 'No issues matching your query or empty stream. %s' % e) + row = nodes.row() + row += create_cell('No issues matching your query or empty stream') + tbody += row + top_node += table node.replace_self(top_node) # try: