Skip to content

Commit 6077688

Browse files
authored
Exclude all transitive dependencies of ssj besides commons-math3 and replace linear regression implementation (#638)
1 parent 47443bc commit 6077688

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

pom.xml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,11 @@
6363
<groupId>ca.umontreal.iro.simul</groupId>
6464
<artifactId>ssj</artifactId>
6565
<version>3.3.2</version>
66+
<!-- Dependencies are unused, provided by Jenkins core, have unusual licenses, unclear artifact ownership, and/or are obsolete. We only use SmoothingCubicSpline, which does not require dependencies. -->
6667
<exclusions>
6768
<exclusion>
68-
<groupId>com.google.code.gson</groupId>
69-
<artifactId>gson</artifactId>
70-
</exclusion>
71-
<!-- Provided by Jenkins core -->
72-
<exclusion>
73-
<groupId>org.jfree</groupId>
74-
<artifactId>jcommon</artifactId>
75-
</exclusion>
76-
<exclusion>
77-
<groupId>org.jfree</groupId>
78-
<artifactId>jfreechart</artifactId>
69+
<groupId>*</groupId>
70+
<artifactId>*</artifactId>
7971
</exclusion>
8072
</exclusions>
8173
</dependency>
@@ -104,6 +96,11 @@
10496
<groupId>io.jenkins.plugins</groupId>
10597
<artifactId>plugin-util-api</artifactId>
10698
</dependency>
99+
<dependency>
100+
<groupId>org.apache.commons</groupId>
101+
<artifactId>commons-math3</artifactId>
102+
<version>3.6.1</version>
103+
</dependency>
107104
<dependency>
108105
<groupId>org.jenkins-ci.plugins</groupId>
109106
<artifactId>display-url-api</artifactId>

src/main/java/hudson/tasks/junit/History.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@
4646
import java.util.concurrent.atomic.AtomicInteger;
4747
import java.util.stream.Collectors;
4848
import jenkins.util.SystemProperties;
49+
import org.apache.commons.math3.stat.regression.SimpleRegression;
4950
import org.kohsuke.accmod.Restricted;
5051
import org.kohsuke.accmod.restrictions.NoExternalUse;
5152
import org.kohsuke.stapler.bind.JavaScriptMethod;
52-
import umontreal.ssj.functionfit.LeastSquares;
5353
import umontreal.ssj.functionfit.SmoothingCubicSpline;
5454

5555
/**
@@ -248,7 +248,13 @@ private void createLinearTrend(
248248
if (history.size() < 3) {
249249
return;
250250
}
251-
double[] cs = LeastSquares.calcCoefficients(lrX, lrY);
251+
252+
SimpleRegression sr = new SimpleRegression(true);
253+
for (int i = 0; i < lrX.length; i++) {
254+
sr.addData(lrX[i], lrY[i]);
255+
}
256+
double intercept = sr.getIntercept();
257+
double slope = sr.getSlope();
252258

253259
ObjectNode lrSeries = MAPPER.createObjectNode();
254260
series.add(lrSeries);
@@ -273,7 +279,7 @@ private void createLinearTrend(
273279
}
274280
for (int index = 0; index < history.size(); ++index) {
275281
// Use float to reduce JSON size.
276-
lrData.add((float) (Math.round((cs[0] + index * cs[1]) * roundMul) / roundMul));
282+
lrData.add((float) (Math.round((intercept + index * slope) * roundMul) / roundMul));
277283
}
278284
}
279285

0 commit comments

Comments
 (0)