To understand how much code isn't used, we recorded the executed code in production with the coverage tool JaCoCo. The measurement took place between 21st Oct 2017 and 27st Oct 2017. The results were exported into a CSV file using the JaCoCo command line tool with the following command:
java -jar jacococli.jar report "C:\Temp\jacoco.exec" --classfiles \
C:\dev\repos\buschmais-spring-petclinic\target\classes --csv jacoco.csv
The CSV file contains all lines of code that were passed through during the measurement's time span.
%%classpath add mvn
tech.tablesaw tablesaw-beakerx 0.24.5
tech.tablesaw tablesaw-jsplot 0.24.5
%import tech.tablesaw.api.*
%import tech.tablesaw.columns.*
%import static tech.tablesaw.aggregate.AggregateFunctions.*
tech.tablesaw.beakerx.TablesawDisplayer.register()
OutputCell.HIDDEN
%%bash
wget https://raw.githubusercontent.com/feststelltaste/software-analytics/master/demos/dataset/jacoco.csv
coverage = Table.read().csv("jacoco.csv")
coverage.first(5)
We just take the only relevant data LINES_COVERED
as well as the information about the packages in PACKAGE
as well as the CLASS
columns.
coverage = coverage.retainColumns("PACKAGE", "CLASS", "LINE_COVERED")
coverage.first(5)
It was stated that whole packages wouldn't be needed anymore and that they could be safely removed. Therefore, we sum up the coverage data per class for each package and calculate the coverage ratio for each package.
per_package = coverage.summarize("LINE_COVERED", sum).by("PACKAGE");
per_package
We plot the data for the coverage ratio to get a brief overview of the result.
def bars = new CategoryBars(
value: per_package.column('Sum [LINE_COVERED]').asList())
new CategoryPlot(
categoryNames: per_package.column('PACKAGE').asList(),
orientation: PlotOrientationType.HORIZONTAL) << bars
The JDBC package org.springframework.samples.petclinic.repository.jdbc
isn't used at all and can be left out safely when migrating to the new platform.