In [1]:
import pandas as pd
coverage = pd.read_csv("../dataset/jacoco_demo.csv")
coverage.head()
Out[1]:
In [2]:
coverage['lines'] = coverage.LINE_MISSED + coverage.LINE_COVERED
coverage['covered'] = coverage.LINE_COVERED / coverage.lines
coverage.head()
Out[2]:
In [3]:
%matplotlib inline
import matplotlib.pyplot as plt
ax = coverage.covered.hist();
ax.set_title("Verteilung der Gesamtausnutzung")
ax.set_xlabel("Anzahl")
ax.set_ylabel("Nutzungsgrad");
In [4]:
coverage['fqn'] = coverage.PACKAGE + "." + coverage.CLASS
coverage_per_class = coverage.set_index('fqn')[['lines', 'covered']]
coverage_per_class.head()
Out[4]:
In [5]:
import requests
KEY = "org.springframework.samples:spring-petclinic:boundedcontexts"
URL = "https://sonarcloud.io/api/issues/search?languages=java&componentKeys="
issues_json = requests.get(URL + KEY).json()
print(str(issues_json)[:500])
In [6]:
from pandas.io.json import json_normalize
issues = json_normalize(issues_json['issues'])[['component', 'debt']]
issues['debt'] = issues.debt.apply(pd.Timedelta)
issues.head()
Out[6]:
In [7]:
issues['fqn'] = issues.component.str.extract("/java/(.*).java", expand=True)
issues['fqn'] = issues.fqn.str.replace("/", ".")
debt_per_class = issues.groupby('fqn')[['debt']].sum()
debt_per_class.head()
Out[7]:
...ein paar Code-Zeilen weiter...
In [8]:
analysis = coverage_per_class.join(debt_per_class)
analysis = analysis.fillna(0)
analysis.head()
Out[8]:
In [9]:
analysis['domain'] = "Other" # Standardvorbelegung
domains = ["Owner", "Pet", "Visit", "Vet", "Specialty", "Clinic"]
for domain in domains:
analysis.loc[analysis.index.str.contains(domain), 'domain'] = domain
analysis.head()
Out[9]:
In [10]:
mgt = analysis.groupby('domain').agg(
{"covered" : "mean", "debt" : "sum", "lines" : "sum"})
mgt['debt'] = mgt['debt'].dt.seconds / 60
mgt.columns = ['Nutzungsgrad (%)', 'Technische Schulden (min)', 'Größe']
mgt
Out[10]:
In [11]:
from ausi import portfolio
In [12]:
portfolio.plot_diagram(mgt, "Technische Schulden (min)", "Nutzungsgrad (%)", "Größe");
In [13]:
analysis['tech'] = analysis.index.str.split(".").str[-2]
mgt = analysis.groupby('tech').agg(
{"covered": "mean", "debt" : "sum", "lines" : "sum"})
mgt['debt'] = mgt['debt'].dt.seconds / 60
mgt.columns = ['Nutzungsgrad (%)', 'Technische Schulden (min)', 'Größe']
mgt
Out[13]:
In [14]:
portfolio.plot_diagram(mgt, "Technische Schulden (min)", "Nutzungsgrad (%)", "Größe");