mirror of
https://github.com/ejwa/gitinspector.git
synced 2024-11-16 00:28:25 +01:00
Implemented support for XML output in the metrics module.
This commit is contained in:
parent
c4b108b7ff
commit
0669adc560
2 changed files with 26 additions and 4 deletions
|
@ -61,7 +61,7 @@ class Runner:
|
|||
changes.get(self.hard), self.useweeks)
|
||||
|
||||
if self.include_metrics:
|
||||
metrics.output()
|
||||
format.call_output_function(metrics.output_html, metrics.output_text, metrics.output_xml)
|
||||
|
||||
if self.responsibilities:
|
||||
responsibilities.output(self.hard)
|
||||
|
|
28
metrics.py
28
metrics.py
|
@ -60,12 +60,34 @@ class Metrics:
|
|||
|
||||
return eloc_counter
|
||||
|
||||
def output():
|
||||
__eloc_info_text__ = "The following files are suspiciously big (in order of severity)"
|
||||
__metrics_missing_info_text__ = "No metrics violations were found in the repository"
|
||||
|
||||
def output_html():
|
||||
print("HTML output not yet supported.")
|
||||
|
||||
def output_text():
|
||||
metrics = Metrics()
|
||||
|
||||
if not metrics.eloc:
|
||||
print("\nNo metrics violations were found in the repository.")
|
||||
print("\n" + __metrics_missing_info_text__ + ".")
|
||||
else:
|
||||
print("\nThe following files are suspiciously big (in order of severity):")
|
||||
print("\n" + __eloc_info_text__ + ":")
|
||||
for i in sorted(set([(j, i) for (i, j) in metrics.eloc.items()]), reverse = True):
|
||||
print(i[1] + " (" + str(i[0]) + " eloc)")
|
||||
|
||||
def output_xml():
|
||||
metrics = Metrics()
|
||||
|
||||
if not metrics.eloc:
|
||||
print("\t<metrics>\n\t\t<message>" + __metrics_missing_info_text__ + "</message>\n\t</metrics>")
|
||||
else:
|
||||
eloc_xml = ""
|
||||
for i in sorted(set([(j, i) for (i, j) in metrics.eloc.items()]), reverse = True):
|
||||
eloc_xml += "\t\t\t\t\t<violation>\n"
|
||||
eloc_xml += "\t\t\t\t\t\t<file-name>" + i[1] + "</file-name>\n"
|
||||
eloc_xml += "\t\t\t\t\t\t<lines-of-code>" + str(i[0]) + "</lines-of-code>\n"
|
||||
eloc_xml += "\t\t\t\t\t</violation>\n"
|
||||
|
||||
print("\t\t<metrics>\n\t\t\t<eloc>\n\t\t\t\t<message>" + __eloc_info_text__ +
|
||||
"</message>\n\t\t\t\t<violations>\n" + eloc_xml + "\t\t\t\t</violations>\n\t\t\t</eloc>\n\t\t</metrics>")
|
||||
|
|
Loading…
Reference in a new issue