You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ah...@apache.org on 2023/02/16 14:46:25 UTC

[commons-statistics] 02/05: Sonar fix: Only one invocation possibly throwing an exception

This is an automated email from the ASF dual-hosted git repository.

aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-statistics.git

commit 21ebb2e3dd788b3619021cd46118a2f1355e958d
Author: aherbert <ah...@apache.org>
AuthorDate: Thu Feb 16 13:49:37 2023 +0000

    Sonar fix: Only one invocation possibly throwing an exception
---
 .../org/apache/commons/statistics/inference/BinomialTestTest.java    | 4 ++--
 .../commons/statistics/inference/KolmogorovSmirnovTestTest.java      | 5 +++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/commons-statistics-inference/src/test/java/org/apache/commons/statistics/inference/BinomialTestTest.java b/commons-statistics-inference/src/test/java/org/apache/commons/statistics/inference/BinomialTestTest.java
index 35547f9..e3527d0 100644
--- a/commons-statistics-inference/src/test/java/org/apache/commons/statistics/inference/BinomialTestTest.java
+++ b/commons-statistics-inference/src/test/java/org/apache/commons/statistics/inference/BinomialTestTest.java
@@ -49,8 +49,8 @@ class BinomialTestTest {
         "1, 2, 0.5",
     })
     void testBinomialTestThrows(int n, int k, double p) {
-        Assertions.assertThrows(IllegalArgumentException.class, () ->
-            BinomialTest.withDefaults().test(n, k, p));
+        final BinomialTest test = BinomialTest.withDefaults();
+        Assertions.assertThrows(IllegalArgumentException.class, () -> test.test(n, k, p));
     }
 
     /**
diff --git a/commons-statistics-inference/src/test/java/org/apache/commons/statistics/inference/KolmogorovSmirnovTestTest.java b/commons-statistics-inference/src/test/java/org/apache/commons/statistics/inference/KolmogorovSmirnovTestTest.java
index ee6936f..168c17c 100644
--- a/commons-statistics-inference/src/test/java/org/apache/commons/statistics/inference/KolmogorovSmirnovTestTest.java
+++ b/commons-statistics-inference/src/test/java/org/apache/commons/statistics/inference/KolmogorovSmirnovTestTest.java
@@ -1126,10 +1126,11 @@ class KolmogorovSmirnovTestTest {
     }
 
     private static void assertThrowsIllegalArgumentException(double[] x, double[] y) {
+        final KolmogorovSmirnovTest test = KolmogorovSmirnovTest.withDefaults();
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> KolmogorovSmirnovTest.withDefaults().statistic(x, y), "statistic");
+            () -> test.statistic(x, y), "statistic");
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> KolmogorovSmirnovTest.withDefaults().test(x, y), "test");
+            () -> test.test(x, y), "test");
     }
 
     @Test