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 84e42ef5073e81a7421a2ad3f833bab033f52e98
Author: Alex Herbert <aherb...@apache.org>
AuthorDate: Mon Mar 24 15:44:53 2025 +0000

    Sonar fix: replace lambda with method reference
---
 .../commons/statistics/descriptive/Int128Test.java     |  4 ++--
 .../commons/statistics/descriptive/TestHelper.java     |  8 ++++----
 .../commons/statistics/descriptive/UInt128Test.java    | 10 +++++-----
 .../commons/statistics/descriptive/UInt192Test.java    | 18 +++++++++---------
 4 files changed, 20 insertions(+), 20 deletions(-)

diff --git 
a/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/Int128Test.java
 
b/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/Int128Test.java
index a6aab0a..b445474 100644
--- 
a/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/Int128Test.java
+++ 
b/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/Int128Test.java
@@ -186,7 +186,7 @@ class Int128Test {
         Assertions.assertEquals(x, v.toIntExact());
         final int y = x < 0 ? -1 : 1;
         v.add(y);
-        Assertions.assertThrows(ArithmeticException.class, () -> 
v.toIntExact());
+        Assertions.assertThrows(ArithmeticException.class, v::toIntExact);
         v.add(-y);
         Assertions.assertEquals(x, v.toIntExact());
     }
@@ -198,7 +198,7 @@ class Int128Test {
         Assertions.assertEquals(x, v.toLongExact());
         final int y = x < 0 ? -1 : 1;
         v.add(y);
-        Assertions.assertThrows(ArithmeticException.class, () -> 
v.toLongExact());
+        Assertions.assertThrows(ArithmeticException.class, v::toLongExact);
         v.add(-y);
         Assertions.assertEquals(x, v.toLongExact());
     }
diff --git 
a/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/TestHelper.java
 
b/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/TestHelper.java
index aa080d1..31289a8 100644
--- 
a/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/TestHelper.java
+++ 
b/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/TestHelper.java
@@ -301,7 +301,7 @@ final class TestHelper {
         try {
             i = expected.getAsInt();
         } catch (final Throwable t) {
-            Assertions.assertThrowsExactly(t.getClass(), () -> 
actual.getAsInt(), intMsg);
+            Assertions.assertThrowsExactly(t.getClass(), actual::getAsInt, 
intMsg);
         }
         if (i != null) {
             Assertions.assertEquals(i.intValue(), actual.getAsInt(), intMsg);
@@ -325,7 +325,7 @@ final class TestHelper {
         try {
             l = expected.getAsLong();
         } catch (final Throwable t) {
-            Assertions.assertThrowsExactly(t.getClass(), () -> 
actual.getAsLong(), longMsg);
+            Assertions.assertThrowsExactly(t.getClass(), actual::getAsLong, 
longMsg);
         }
         if (l != null) {
             Assertions.assertEquals(l.longValue(), actual.getAsLong(), 
longMsg);
@@ -355,7 +355,7 @@ final class TestHelper {
         try {
             d = expected.getAsDouble();
         } catch (final Throwable t) {
-            Assertions.assertThrowsExactly(t.getClass(), () -> 
actual.getAsDouble(), doubleMsg);
+            Assertions.assertThrowsExactly(t.getClass(), actual::getAsDouble, 
doubleMsg);
         }
         if (d != null) {
             if (tol == null) {
@@ -391,7 +391,7 @@ final class TestHelper {
         try {
             b = expected.getAsBigInteger();
         } catch (final Throwable t) {
-            Assertions.assertThrowsExactly(t.getClass(), () -> actual.get(), 
bigMsg);
+            Assertions.assertThrowsExactly(t.getClass(), actual::get, bigMsg);
         }
         if (b != null) {
             if (tol == null) {
diff --git 
a/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/UInt128Test.java
 
b/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/UInt128Test.java
index 0c24df2..5fab650 100644
--- 
a/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/UInt128Test.java
+++ 
b/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/UInt128Test.java
@@ -243,17 +243,17 @@ class UInt128Test {
         final UInt128 v = new UInt128(0, x);
         Assertions.assertEquals(x, v.toIntExact());
         v.addPositive(1);
-        Assertions.assertThrows(ArithmeticException.class, () -> 
v.toIntExact());
+        Assertions.assertThrows(ArithmeticException.class, v::toIntExact);
         Assertions.assertEquals(0x1.0p31, v.toDouble());
         Assertions.assertEquals(y, v.toLongExact());
         // 2^32 has no low bits - check the result is not returned as zero
         final UInt128 v2 = new UInt128(0, 2 * y);
-        Assertions.assertThrows(ArithmeticException.class, () -> 
v2.toIntExact());
+        Assertions.assertThrows(ArithmeticException.class, v2::toIntExact);
         Assertions.assertEquals(0x1.0p32, v2.toDouble());
         Assertions.assertEquals(2 * y, v2.toLongExact());
         // 2^64 has no low bits - check the result is not returned as zero
         final UInt128 v3 = new UInt128(1, 0);
-        Assertions.assertThrows(ArithmeticException.class, () -> 
v3.toIntExact());
+        Assertions.assertThrows(ArithmeticException.class, v3::toIntExact);
         Assertions.assertEquals(0x1.0p64, v3.toDouble());
     }
 
@@ -263,11 +263,11 @@ class UInt128Test {
         final UInt128 v = new UInt128(0, x);
         Assertions.assertEquals(x, v.toLongExact());
         v.addPositive(1);
-        Assertions.assertThrows(ArithmeticException.class, () -> 
v.toLongExact());
+        Assertions.assertThrows(ArithmeticException.class, v::toLongExact);
         Assertions.assertEquals(0x1.0p63, v.toDouble());
         // 2^64 has no low bits - check the result is not returned as zero
         final UInt128 v3 = new UInt128(1, 0);
-        Assertions.assertThrows(ArithmeticException.class, () -> 
v3.toLongExact());
+        Assertions.assertThrows(ArithmeticException.class, v3::toLongExact);
         Assertions.assertEquals(0x1.0p64, v3.toDouble());
     }
 }
diff --git 
a/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/UInt192Test.java
 
b/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/UInt192Test.java
index 0edf578..435e9d7 100644
--- 
a/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/UInt192Test.java
+++ 
b/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/UInt192Test.java
@@ -212,25 +212,25 @@ class UInt192Test {
         final UInt192 v = new UInt192(0, 0, x);
         Assertions.assertEquals(x, v.toIntExact());
         v.addSquare(1);
-        Assertions.assertThrows(ArithmeticException.class, () -> 
v.toIntExact());
+        Assertions.assertThrows(ArithmeticException.class, v::toIntExact);
         Assertions.assertEquals(0x1.0p31, v.toDouble());
         Assertions.assertEquals(y, v.toLongExact());
         // 2^32 has no low bits - check the result is not returned as zero
         final UInt192 v2 = new UInt192(0, 0, 2 * y);
-        Assertions.assertThrows(ArithmeticException.class, () -> 
v2.toIntExact());
+        Assertions.assertThrows(ArithmeticException.class, v2::toIntExact);
         Assertions.assertEquals(0x1.0p32, v2.toDouble());
         Assertions.assertEquals(2 * y, v2.toLongExact());
         // 2^64 has no low bits - check the result is not returned as zero
         final UInt192 v3 = new UInt192(0, 1, 0);
-        Assertions.assertThrows(ArithmeticException.class, () -> 
v3.toIntExact());
+        Assertions.assertThrows(ArithmeticException.class, v3::toIntExact);
         Assertions.assertEquals(0x1.0p64, v3.toDouble());
         // 2^96 has no low bits - check the result is not returned as zero
         final UInt192 v4 = new UInt192(0, 1L << 32, 0);
-        Assertions.assertThrows(ArithmeticException.class, () -> 
v4.toIntExact());
+        Assertions.assertThrows(ArithmeticException.class, v4::toIntExact);
         Assertions.assertEquals(0x1.0p96, v4.toDouble());
         // 2^128 has no low bits - check the result is not returned as zero
         final UInt192 v5 = new UInt192(1, 0, 0);
-        Assertions.assertThrows(ArithmeticException.class, () -> 
v5.toIntExact());
+        Assertions.assertThrows(ArithmeticException.class, v5::toIntExact);
         Assertions.assertEquals(0x1.0p128, v5.toDouble());
     }
 
@@ -240,19 +240,19 @@ class UInt192Test {
         final UInt192 v = new UInt192(0, 0, x);
         Assertions.assertEquals(x, v.toLongExact());
         v.addSquare(1);
-        Assertions.assertThrows(ArithmeticException.class, () -> 
v.toLongExact());
+        Assertions.assertThrows(ArithmeticException.class, v::toLongExact);
         Assertions.assertEquals(0x1.0p63, v.toDouble());
         // 2^64 has no low bits - check the result is not returned as zero
         final UInt192 v3 = new UInt192(0, 1, 0);
-        Assertions.assertThrows(ArithmeticException.class, () -> 
v3.toLongExact());
+        Assertions.assertThrows(ArithmeticException.class, v3::toLongExact);
         Assertions.assertEquals(0x1.0p64, v3.toDouble());
         // 2^96 has no low bits - check the result is not returned as zero
         final UInt192 v4 = new UInt192(0, 1L << 32, 0);
-        Assertions.assertThrows(ArithmeticException.class, () -> 
v4.toLongExact());
+        Assertions.assertThrows(ArithmeticException.class, v4::toLongExact);
         Assertions.assertEquals(0x1.0p96, v4.toDouble());
         // 2^128 has no low bits - check the result is not returned as zero
         final UInt192 v5 = new UInt192(1, 0, 0);
-        Assertions.assertThrows(ArithmeticException.class, () -> 
v5.toLongExact());
+        Assertions.assertThrows(ArithmeticException.class, v5::toLongExact);
         Assertions.assertEquals(0x1.0p128, v5.toDouble());
     }
 

Reply via email to