From 4d6ecd3123c437c38b7fcc1aa4b4047a1bad31ab Mon Sep 17 00:00:00 2001 From: Adam Waldenberg Date: Tue, 3 Nov 2015 22:52:17 +0100 Subject: [PATCH] Avoid hyphen characters ("-") in JSON properties. Using that character is obviously a bad idea, as it is reserved for substraction in most programming languages; making output a hassle to parse. --- gitinspector/output/blameoutput.py | 2 +- gitinspector/output/changesoutput.py | 2 +- gitinspector/output/metricsoutput.py | 6 +++--- gitinspector/output/timelineoutput.py | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gitinspector/output/blameoutput.py b/gitinspector/output/blameoutput.py index 683f2ec..677b432 100644 --- a/gitinspector/output/blameoutput.py +++ b/gitinspector/output/blameoutput.py @@ -107,7 +107,7 @@ class BlameOutput(Outputable): stability_xml = ("\t\t\t\t\"stability\": " + "{0:.1f}".format(Blame.get_stability(i[0], i[1].rows, self.changes)) + ",\n") age_xml = ("\t\t\t\t\"age\": " + "{0:.1f}".format(float(i[1].skew) / i[1].rows) + ",\n") - percentage_in_comments_xml = ("\t\t\t\t\"percentage-in-comments\": " + "{0:.2f}".format(100.0 * i[1].comments / i[1].rows) + + percentage_in_comments_xml = ("\t\t\t\t\"percentage_in_comments\": " + "{0:.2f}".format(100.0 * i[1].comments / i[1].rows) + "\n") blame_xml += ("{\n" + name_xml + gravatar_xml + rows_xml + stability_xml + age_xml + percentage_in_comments_xml + "\t\t\t},") diff --git a/gitinspector/output/changesoutput.py b/gitinspector/output/changesoutput.py index b42417d..7a6b773 100644 --- a/gitinspector/output/changesoutput.py +++ b/gitinspector/output/changesoutput.py @@ -115,7 +115,7 @@ class ChangesOutput(Outputable): commits_xml = "\t\t\t\t\"commits\": " + str(authorinfo.commits) + ",\n" insertions_xml = "\t\t\t\t\"insertions\": " + str(authorinfo.insertions) + ",\n" deletions_xml = "\t\t\t\t\"deletions\": " + str(authorinfo.deletions) + ",\n" - percentage_xml = "\t\t\t\t\"percentage-of-changes\": " + "{0:.2f}".format(percentage) + "\n" + percentage_xml = "\t\t\t\t\"percentage_of_changes\": " + "{0:.2f}".format(percentage) + "\n" changes_xml += ("{\n" + name_xml + gravatar_xml + commits_xml + insertions_xml + deletions_xml + percentage_xml + "\t\t\t}") diff --git a/gitinspector/output/metricsoutput.py b/gitinspector/output/metricsoutput.py index ebf31ee..43f9286 100644 --- a/gitinspector/output/metricsoutput.py +++ b/gitinspector/output/metricsoutput.py @@ -103,7 +103,7 @@ class MetricsOutput(Outputable): if self.metrics.eloc: for i in sorted(set([(j, i) for (i, j) in self.metrics.eloc.items()]), reverse=True): eloc_xml += "{\n\t\t\t\t\"type\": \"estimated-lines-of-code\",\n" - eloc_xml += "\t\t\t\t\"file-name\": \"" + i[1] + "\",\n" + eloc_xml += "\t\t\t\t\"file_name\": \"" + i[1] + "\",\n" eloc_xml += "\t\t\t\t\"value\": " + str(i[0]) + "\n" eloc_xml += "\t\t\t}," else: @@ -113,7 +113,7 @@ class MetricsOutput(Outputable): if self.metrics.cyclomatic_complexity: for i in sorted(set([(j, i) for (i, j) in self.metrics.cyclomatic_complexity.items()]), reverse=True): eloc_xml += "{\n\t\t\t\t\"type\": \"cyclomatic-complexity\",\n" - eloc_xml += "\t\t\t\t\"file-name\": \"" + i[1] + "\",\n" + eloc_xml += "\t\t\t\t\"file_name\": \"" + i[1] + "\",\n" eloc_xml += "\t\t\t\t\"value\": " + str(i[0]) + "\n" eloc_xml += "\t\t\t}," else: @@ -123,7 +123,7 @@ class MetricsOutput(Outputable): if self.metrics.cyclomatic_complexity_density: for i in sorted(set([(j, i) for (i, j) in self.metrics.cyclomatic_complexity_density.items()]), reverse=True): eloc_xml += "{\n\t\t\t\t\"type\": \"cyclomatic-complexity-density\",\n" - eloc_xml += "\t\t\t\t\"file-name\": \"" + i[1] + "\",\n" + eloc_xml += "\t\t\t\t\"file_name\": \"" + i[1] + "\",\n" eloc_xml += "\t\t\t\t\"value\": {0:.3f} \"\n".format(i[0]) eloc_xml += "\t\t\t}," else: diff --git a/gitinspector/output/timelineoutput.py b/gitinspector/output/timelineoutput.py index 2c04038..ab35d44 100644 --- a/gitinspector/output/timelineoutput.py +++ b/gitinspector/output/timelineoutput.py @@ -136,7 +136,7 @@ class TimelineOutput(Outputable): if self.changes.get_commits(): message_xml = "\t\t\t\"message\": \"" + _(TIMELINE_INFO_TEXT) + "\",\n" timeline_xml = "" - periods_xml = "\t\t\t\"period-length\": \"{0}\",\n".format("week" if self.useweeks else "month") + periods_xml = "\t\t\t\"period_length\": \"{0}\",\n".format("week" if self.useweeks else "month") periods_xml += "\t\t\t\"periods\": [\n\t\t\t" timeline_data = timeline.TimelineData(self.changes, self.useweeks)