You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ma...@apache.org on 2021/04/21 21:07:25 UTC

[commons-geometry] branch master updated: GEOMETRY-63: fixing various PMD and SonarQube issues

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

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


The following commit(s) were added to refs/heads/master by this push:
     new b60aee2  GEOMETRY-63: fixing various PMD and SonarQube issues
b60aee2 is described below

commit b60aee205a76a1d6112508c22dc6d3f310fe7f23
Author: Matt Juntunen <ma...@hotmail.com>
AuthorDate: Wed Apr 21 11:16:51 2021 -0400

    GEOMETRY-63: fixing various PMD and SonarQube issues
---
 .../geometry/euclidean/AbstractLinecastPoint.java  |  2 +-
 .../geometry/euclidean/AbstractNSphere.java        |  2 +-
 .../euclidean/threed/SphericalCoordinates.java     | 24 ++++----
 .../geometry/euclidean/twod/PolarCoordinates.java  | 19 ++++---
 .../geometry/io/core/BoundaryIOManager.java        |  4 +-
 .../geometry/io/core/internal/CharReadBuffer.java  |  6 +-
 .../io/core/internal/SimpleTextParser.java         |  9 +--
 .../geometry/io/core/utils/ParsedDouble.java       | 64 +++++++++++-----------
 .../geometry/io/core/BoundaryIOManagerTest.java    | 43 +++++++++------
 .../io/core/internal/SimpleTextParserTest.java     |  4 ++
 .../io/euclidean/threed/FacetDefinitionsTest.java  |  6 +-
 .../threed/SimpleFacetDefinitionTest.java          | 10 +++-
 .../io/euclidean/threed/obj/ObjWriterTest.java     |  2 +
 .../io/euclidean/threed/stl/TextStlWriterTest.java | 11 +++-
 14 files changed, 119 insertions(+), 87 deletions(-)

diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/AbstractLinecastPoint.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/AbstractLinecastPoint.java
index 756df65..ef476aa 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/AbstractLinecastPoint.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/AbstractLinecastPoint.java
@@ -113,7 +113,7 @@ public abstract class AbstractLinecastPoint<
     /** {@inheritDoc} */
     @Override
     public String toString() {
-        final StringBuilder sb = new StringBuilder();
+        final StringBuilder sb = new StringBuilder(50);
         sb.append(getClass().getSimpleName())
             .append("[point= ")
             .append(getPoint())
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/AbstractNSphere.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/AbstractNSphere.java
index b73190d..12a1ed6 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/AbstractNSphere.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/AbstractNSphere.java
@@ -152,7 +152,7 @@ public abstract class AbstractNSphere<V extends EuclideanVector<V>> implements R
     /** {@inheritDoc} */
     @Override
     public String toString() {
-        final StringBuilder sb = new StringBuilder();
+        final StringBuilder sb = new StringBuilder(30);
         sb.append(this.getClass().getSimpleName())
             .append("[center= ")
             .append(center)
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/SphericalCoordinates.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/SphericalCoordinates.java
index b7415e7..223b48c 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/SphericalCoordinates.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/SphericalCoordinates.java
@@ -77,17 +77,21 @@ public final class SphericalCoordinates implements Spatial {
      * @param azimuth Azimuth angle in radians.
      * @param polar Polar angle in radians.
      */
-    private SphericalCoordinates(double radius, double azimuth, double polar) {
-        if (radius < 0) {
+    private SphericalCoordinates(final double radius, final double azimuth, final double polar) {
+        double rad = radius;
+        double az = azimuth;
+        double pol = polar;
+
+        if (rad < 0) {
             // negative radius; flip the angles
-            radius = Math.abs(radius);
-            azimuth += PlaneAngleRadians.PI;
-            polar += PlaneAngleRadians.PI;
+            rad = Math.abs(rad);
+            az += PlaneAngleRadians.PI;
+            pol += PlaneAngleRadians.PI;
         }
 
-        this.radius = radius;
-        this.azimuth = normalizeAzimuth(azimuth);
-        this.polar = normalizePolar(polar);
+        this.radius = rad;
+        this.azimuth = normalizeAzimuth(az);
+        this.polar = normalizePolar(pol);
     }
 
     /** Return the radius value. The value is in the range {@code [0, +Infinity)}.
@@ -285,11 +289,11 @@ public final class SphericalCoordinates implements Spatial {
      * @param polar polar value in radians
      * @return equivalent polar value in the range {@code [0, +pi]}
      */
-    public static double normalizePolar(double polar) {
+    public static double normalizePolar(final double polar) {
         // normalize the polar angle; this is the angle between the polar vector and the point ray
         // so it is unsigned (unlike the azimuth) and should be in the range [0, pi]
         if (Double.isFinite(polar)) {
-            polar = Math.abs(PlaneAngleRadians.normalizeBetweenMinusPiAndPi(polar));
+            return Math.abs(PlaneAngleRadians.normalizeBetweenMinusPiAndPi(polar));
         }
 
         return polar;
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/PolarCoordinates.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/PolarCoordinates.java
index bb66412..ff45a92 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/PolarCoordinates.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/PolarCoordinates.java
@@ -57,15 +57,18 @@ public final class PolarCoordinates implements Spatial {
      * @param radius Radius value.
      * @param azimuth Azimuth angle in radians.
      */
-    private PolarCoordinates(double radius, double azimuth) {
-        if (radius < 0) {
+    private PolarCoordinates(final double radius, final double azimuth) {
+        double rad = radius;
+        double az = azimuth;
+
+        if (rad < 0) {
             // negative radius; flip the angles
-            radius = Math.abs(radius);
-            azimuth += PlaneAngleRadians.PI;
+            rad = Math.abs(radius);
+            az += PlaneAngleRadians.PI;
         }
 
-        this.radius = radius;
-        this.azimuth = normalizeAzimuth(azimuth);
+        this.radius = rad;
+        this.azimuth = normalizeAzimuth(az);
     }
 
     /** Return the radius value. The value will be greater than or equal to 0.
@@ -228,9 +231,9 @@ public final class PolarCoordinates implements Spatial {
      * @param azimuth azimuth value in radians
      * @return equivalent azimuth value in the range {@code [0, 2pi)}.
      */
-    public static double normalizeAzimuth(double azimuth) {
+    public static double normalizeAzimuth(final double azimuth) {
         if (Double.isFinite(azimuth)) {
-            azimuth = PlaneAngleRadians.normalizeBetweenZeroAndTwoPi(azimuth);
+            return PlaneAngleRadians.normalizeBetweenZeroAndTwoPi(azimuth);
         }
 
         return azimuth;
diff --git a/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/BoundaryIOManager.java b/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/BoundaryIOManager.java
index 2ed38ed..25595c2 100644
--- a/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/BoundaryIOManager.java
+++ b/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/BoundaryIOManager.java
@@ -104,7 +104,7 @@ public class BoundaryIOManager<
      */
     public List<GeometryFormat> getReadFormats() {
         return readRegistry.getHandlers().stream()
-                .map(h -> h.getFormat())
+                .map(BoundaryReadHandler::getFormat)
                 .collect(Collectors.toList());
     }
 
@@ -162,7 +162,7 @@ public class BoundaryIOManager<
      */
     public List<GeometryFormat> getWriteFormats() {
         return writeRegistry.getHandlers().stream()
-                .map(h -> h.getFormat())
+                .map(BoundaryWriteHandler::getFormat)
                 .collect(Collectors.toList());
     }
 
diff --git a/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/internal/CharReadBuffer.java b/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/internal/CharReadBuffer.java
index 905ef3a..c63adb5 100644
--- a/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/internal/CharReadBuffer.java
+++ b/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/internal/CharReadBuffer.java
@@ -48,7 +48,7 @@ public class CharReadBuffer {
     private int count;
 
     /** True when the end of reader content is reached. */
-    private boolean eof;
+    private boolean reachedEof;
 
     /** Minimum number of characters to request for each read. */
     private final int minRead;
@@ -284,7 +284,7 @@ public class CharReadBuffer {
      * @throws IOException if an I/O error occurs
      */
     private void readChars(final int n) throws IOException {
-        if (!eof) {
+        if (!reachedEof) {
             int remaining = Math.max(n, minRead);
 
             ensureCapacity(count + remaining);
@@ -298,7 +298,7 @@ public class CharReadBuffer {
 
                 read = reader.read(buffer, tail, len);
                 if (read == EOF) {
-                    eof = true;
+                    reachedEof = true;
                     break;
                 }
 
diff --git a/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/internal/SimpleTextParser.java b/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/internal/SimpleTextParser.java
index 22babac..e3e6f59 100644
--- a/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/internal/SimpleTextParser.java
+++ b/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/internal/SimpleTextParser.java
@@ -285,9 +285,7 @@ public class SimpleTextParser {
         if (hasMoreCharacters()) {
             final StringBuilder sb = new StringBuilder(len);
 
-            consume(len, ch -> {
-                sb.append((char) ch);
-            });
+            consume(len, ch -> sb.append((char) ch));
 
             token = sb.toString();
         }
@@ -320,9 +318,8 @@ public class SimpleTextParser {
         if (hasMoreCharacters()) {
             final StringBuilder sb = new StringBuilder(len);
 
-            consumeWithLineContinuation(lineContinuationChar, len, ch -> {
-                sb.append((char) ch);
-            });
+            consumeWithLineContinuation(lineContinuationChar, len,
+                    ch -> sb.append((char) ch));
 
             token = sb.toString();
         }
diff --git a/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/utils/ParsedDouble.java b/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/utils/ParsedDouble.java
index 82f057e..c97ece0 100644
--- a/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/utils/ParsedDouble.java
+++ b/commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/utils/ParsedDouble.java
@@ -37,28 +37,28 @@ package org.apache.commons.geometry.io.core.utils;
 final class ParsedDouble {
 
     /** Minus sign character. */
-    private static final char MINUS = '-';
+    private static final char MINUS_CHAR = '-';
 
     /** Decimal separator character. */
-    private static final char DECIMAL_SEP = '.';
+    private static final char DECIMAL_SEP_CHAR = '.';
 
     /** Exponent character. */
-    private static final char EXPONENT = 'E';
+    private static final char EXPONENT_CHAR = 'E';
 
     /** Zero digit character. */
-    private static final char ZERO = '0';
+    private static final char ZERO_CHAR = '0';
 
     /** One digit character. */
-    private static final char ONE = '1';
+    private static final char ONE_CHAR = '1';
 
-    /** String containing the digits '0' - '9' in sequence. */
-    private static final String DIGITS = "0123456789";
+    /** String containing the decimal digits '0' - '9' in sequence. */
+    private static final String DECIMAL_DIGITS = "0123456789";
 
     /** Shared instance representing the positive zero double value. */
-    private static final ParsedDouble POS_ZERO = new ParsedDouble(false, String.valueOf(ZERO), 0);
+    private static final ParsedDouble POS_ZERO = new ParsedDouble(false, String.valueOf(ZERO_CHAR), 0);
 
     /** Shared instance representing the negative zero double value. */
-    private static final ParsedDouble NEG_ZERO = new ParsedDouble(true, String.valueOf(ZERO), 0);
+    private static final ParsedDouble NEG_ZERO = new ParsedDouble(true, String.valueOf(ZERO_CHAR), 0);
 
     /** True if the value is negative. */
     private final boolean negative;
@@ -110,7 +110,7 @@ final class ParsedDouble {
      * @return true if the value is equal to zero
      */
     public boolean isZero() {
-        return getPrecision() == 1 && digits.charAt(0) == ZERO;
+        return getPrecision() == 1 && digits.charAt(0) == ZERO_CHAR;
     }
 
     /** Return the precision of this instance, meaning the number of significant decimal
@@ -211,7 +211,7 @@ final class ParsedDouble {
 
         final StringBuilder sb = new StringBuilder();
         if (negative) {
-            sb.append(MINUS);
+            sb.append(MINUS_CHAR);
         }
 
         if (exponent < 0) {
@@ -224,15 +224,15 @@ final class ParsedDouble {
                 sb.append(digits.charAt(i));
             }
             if (i == 0) {
-                sb.append(ZERO);
+                sb.append(ZERO_CHAR);
             }
 
             // decimal separator
-            sb.append(DECIMAL_SEP);
+            sb.append(DECIMAL_SEP_CHAR);
 
             // add placeholder fraction zeros if needed
             for (int j = 0; j > diff; --j) {
-                sb.append(ZERO);
+                sb.append(ZERO_CHAR);
             }
 
             // fraction digits
@@ -241,12 +241,12 @@ final class ParsedDouble {
             sb.append(digits);
 
             for (int i = 0; i < exponent; ++i) {
-                sb.append(ZERO);
+                sb.append(ZERO_CHAR);
             }
 
             if (includeDecimalPlaceholder) {
-                sb.append(DECIMAL_SEP)
-                    .append(ZERO);
+                sb.append(DECIMAL_SEP_CHAR)
+                    .append(ZERO_CHAR);
             }
         }
 
@@ -305,7 +305,7 @@ final class ParsedDouble {
 
         final StringBuilder sb = new StringBuilder();
         if (negative) {
-            sb.append(MINUS);
+            sb.append(MINUS_CHAR);
         }
 
         if (precision <= wholeDigits) {
@@ -314,24 +314,24 @@ final class ParsedDouble {
             sb.append(digits);
 
             for (int i = precision; i < wholeDigits; ++i) {
-                sb.append(ZERO);
+                sb.append(ZERO_CHAR);
             }
 
             if (includeDecimalPlaceholder) {
-                sb.append(DECIMAL_SEP)
-                    .append(ZERO);
+                sb.append(DECIMAL_SEP_CHAR)
+                    .append(ZERO_CHAR);
             }
         } else {
             // we'll need a fractional portion
             sb.append(digits, 0, wholeDigits)
-                .append(DECIMAL_SEP)
+                .append(DECIMAL_SEP_CHAR)
                 .append(digits, wholeDigits, precision);
         }
 
         // add the exponent but only if non-zero
         final int resultExponent = exponent + precision - wholeDigits;
         if (resultExponent != 0) {
-            sb.append(EXPONENT)
+            sb.append(EXPONENT_CHAR)
                 .append(resultExponent);
         }
 
@@ -371,7 +371,7 @@ final class ParsedDouble {
         // extract the different portions of the string representation
         // (since double is finite, str is guaranteed to not be empty and to contain a
         // single decimal point according to the Double.toString() API)
-        final boolean negative = str.charAt(0) == MINUS;
+        final boolean negative = str.charAt(0) == MINUS_CHAR;
         final int digitStartIdx = negative ? 1 : 0;
 
         final StringBuilder digitStr = new StringBuilder(str.length());
@@ -383,9 +383,9 @@ final class ParsedDouble {
         for (int i = digitStartIdx; i < str.length(); ++i) {
             ch = str.charAt(i);
 
-            if (ch == DECIMAL_SEP) {
+            if (ch == DECIMAL_SEP_CHAR) {
                 decimalSepIdx = i;
-            } else if (ch == EXPONENT) {
+            } else if (ch == EXPONENT_CHAR) {
                 exponentIdx = i;
             } else if (exponentIdx < 0) {
                 digitStr.append(ch);
@@ -423,7 +423,7 @@ final class ParsedDouble {
         char ch;
         for (int i = 0; i < seq.length(); ++i) {
             ch = seq.charAt(i);
-            if (ch != ZERO) {
+            if (ch != ZERO_CHAR) {
                 return i;
             }
         }
@@ -441,7 +441,7 @@ final class ParsedDouble {
         char ch;
         for (i = seq.length() - 1; i >= 0; --i) {
             ch = seq.charAt(i);
-            if (ch != ZERO) {
+            if (ch != ZERO_CHAR) {
                 break;
             }
         }
@@ -455,7 +455,7 @@ final class ParsedDouble {
      * @return numeric value of the digit character, ex: '1' = 1
      */
     private static int digitValue(final char ch) {
-        return ch - ZERO;
+        return ch - ZERO_CHAR;
     }
 
     /** Add one to the value of the integer represented by the given string, returning
@@ -469,7 +469,7 @@ final class ParsedDouble {
         final char[] digitChars = digitStr.toCharArray();
         if (addOne(digitChars)) {
             return new StringBuilder()
-                    .append(ONE)
+                    .append(ONE_CHAR)
                     .append(digitChars)
                     .toString();
         }
@@ -488,10 +488,10 @@ final class ParsedDouble {
         int i;
         char c;
         for (i = digitChars.length - 1; i >= 0; --i) {
-            c = DIGITS.charAt((digitValue(digitChars[i]) + 1) % DIGITS.length());
+            c = DECIMAL_DIGITS.charAt((digitValue(digitChars[i]) + 1) % DECIMAL_DIGITS.length());
             digitChars[i] = c;
 
-            if (c != ZERO) {
+            if (c != ZERO_CHAR) {
                 break; // no carry over; stop
             }
         }
diff --git a/commons-geometry-io-core/src/test/java/org/apache/commons/geometry/io/core/BoundaryIOManagerTest.java b/commons-geometry-io-core/src/test/java/org/apache/commons/geometry/io/core/BoundaryIOManagerTest.java
index 7573c95..9b7bb33 100644
--- a/commons-geometry-io-core/src/test/java/org/apache/commons/geometry/io/core/BoundaryIOManagerTest.java
+++ b/commons-geometry-io-core/src/test/java/org/apache/commons/geometry/io/core/BoundaryIOManagerTest.java
@@ -20,7 +20,6 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.nio.charset.Charset;
-import java.nio.file.Path;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
@@ -38,7 +37,6 @@ import org.apache.commons.geometry.io.core.output.GeometryOutput;
 import org.apache.commons.geometry.io.core.test.StubGeometryFormat;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.io.TempDir;
 
 public class BoundaryIOManagerTest {
 
@@ -56,9 +54,6 @@ public class BoundaryIOManagerTest {
 
     private static final GeometryFormat FMT_C = new StubGeometryFormat("testC", Collections.singletonList("c"));
 
-    @TempDir
-    Path tempDir;
-
     private final TestManager manager = new TestManager();
 
     @Test
@@ -123,15 +118,19 @@ public class BoundaryIOManagerTest {
 
     @Test
     public void testRegisterReadHandler_illegalArgs() {
+        // arrange
+        final StubReadHandler nullFmt = new StubReadHandler(null);
+        final StubReadHandler nullFmtName = new StubReadHandler(new StubGeometryFormat(null));
+
         // act/assert
         GeometryTestUtils.assertThrowsWithMessage(
                 () -> manager.registerReadHandler(null),
                 NullPointerException.class, "Handler cannot be null");
         GeometryTestUtils.assertThrowsWithMessage(
-                () -> manager.registerReadHandler(new StubReadHandler(null)),
+                () -> manager.registerReadHandler(nullFmt),
                 NullPointerException.class, "Format cannot be null");
         GeometryTestUtils.assertThrowsWithMessage(
-                () -> manager.registerReadHandler(new StubReadHandler(new StubGeometryFormat(null))),
+                () -> manager.registerReadHandler(nullFmtName),
                 NullPointerException.class, "Format name cannot be null");
     }
 
@@ -527,15 +526,19 @@ public class BoundaryIOManagerTest {
         final StubReadHandler r1 = new StubReadHandler(FMT_A);
         manager.registerReadHandler(r1);
 
+        final StubGeometryInput inputA = new StubGeometryInput("file.a");
+        final StubGeometryInput inputB = new StubGeometryInput("file.b");
+        final StubGeometryInput inputNull = new StubGeometryInput(null);
+
         final DoublePrecisionContext precision = new EpsilonDoublePrecisionContext(1e-4);
 
         // act/assert
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> manager.read(new StubGeometryInput("file.a"), FMT_B, precision));
+                () -> manager.read(inputA, FMT_B, precision));
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> manager.read(new StubGeometryInput("file.b"), null, precision));
+                () -> manager.read(inputB, null, precision));
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> manager.read(new StubGeometryInput(null), null, precision));
+                () -> manager.read(inputNull, null, precision));
     }
 
     @Test
@@ -580,15 +583,19 @@ public class BoundaryIOManagerTest {
         final StubReadHandler r1 = new StubReadHandler(FMT_A);
         manager.registerReadHandler(r1);
 
+        final StubGeometryInput inputA = new StubGeometryInput("file.a");
+        final StubGeometryInput inputB = new StubGeometryInput("file.b");
+        final StubGeometryInput inputNull = new StubGeometryInput(null);
+
         final DoublePrecisionContext precision = new EpsilonDoublePrecisionContext(1e-4);
 
         // act/assert
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> manager.boundaries(new StubGeometryInput("file.a"), FMT_B, precision));
+                () -> manager.boundaries(inputA, FMT_B, precision));
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> manager.boundaries(new StubGeometryInput("file.b"), null, precision));
+                () -> manager.boundaries(inputB, null, precision));
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> manager.boundaries(new StubGeometryInput(null), null, precision));
+                () -> manager.boundaries(inputNull, null, precision));
     }
 
     @Test
@@ -631,15 +638,19 @@ public class BoundaryIOManagerTest {
         final StubWriteHandler w1 = new StubWriteHandler(FMT_A);
         manager.registerWriteHandler(w1);
 
+        final StubGeometryOutput outputA = new StubGeometryOutput("file.a");
+        final StubGeometryOutput outputB = new StubGeometryOutput("file.b");
+        final StubGeometryOutput nullOutput = new StubGeometryOutput(null);
+
         final TestBoundaryList src = BOUNDARY_LIST;
 
         // act/assert
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> manager.write(src, new StubGeometryOutput("file.a"), FMT_B));
+                () -> manager.write(src, outputA, FMT_B));
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> manager.write(src, new StubGeometryOutput("file.b"), null));
+                () -> manager.write(src, outputB, null));
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> manager.write(src, new StubGeometryOutput(null), null));
+                () -> manager.write(src, nullOutput, null));
     }
 
     private static final class TestManager
diff --git a/commons-geometry-io-core/src/test/java/org/apache/commons/geometry/io/core/internal/SimpleTextParserTest.java b/commons-geometry-io-core/src/test/java/org/apache/commons/geometry/io/core/internal/SimpleTextParserTest.java
index 6013dfd..358a07b 100644
--- a/commons-geometry-io-core/src/test/java/org/apache/commons/geometry/io/core/internal/SimpleTextParserTest.java
+++ b/commons-geometry-io-core/src/test/java/org/apache/commons/geometry/io/core/internal/SimpleTextParserTest.java
@@ -858,6 +858,8 @@ public class SimpleTextParserTest {
             .match("a")
             .next(100)
             .match("bcdef");
+
+        Assertions.assertFalse(p.hasMoreCharacters());
     }
 
     @Test
@@ -894,6 +896,8 @@ public class SimpleTextParserTest {
             .matchIgnoreCase("A")
             .next(100)
             .matchIgnoreCase("BcdEF");
+
+        Assertions.assertFalse(p.hasMoreCharacters());
     }
 
     @Test
diff --git a/commons-geometry-io-euclidean/src/test/java/org/apache/commons/geometry/io/euclidean/threed/FacetDefinitionsTest.java b/commons-geometry-io-euclidean/src/test/java/org/apache/commons/geometry/io/euclidean/threed/FacetDefinitionsTest.java
index 8f3f931..7ef25bb 100644
--- a/commons-geometry-io-euclidean/src/test/java/org/apache/commons/geometry/io/euclidean/threed/FacetDefinitionsTest.java
+++ b/commons-geometry-io-euclidean/src/test/java/org/apache/commons/geometry/io/euclidean/threed/FacetDefinitionsTest.java
@@ -46,7 +46,7 @@ public class FacetDefinitionsTest {
         final ConvexPolygon3D p = FacetDefinitions.toPolygon(f, TEST_PRECISION);
 
         // assert
-        Assertions.assertSame(p.getPlane().getPrecision(), TEST_PRECISION);
+        Assertions.assertSame(TEST_PRECISION, p.getPlane().getPrecision());
 
         EuclideanTestUtils.assertCoordinatesEqual(Vector3D.Unit.PLUS_Z, p.getPlane().getNormal(), TEST_EPS);
         Assertions.assertEquals(4, p.getVertices().size());
@@ -63,7 +63,7 @@ public class FacetDefinitionsTest {
         final ConvexPolygon3D p = FacetDefinitions.toPolygon(f, TEST_PRECISION);
 
         // assert
-        Assertions.assertSame(p.getPlane().getPrecision(), TEST_PRECISION);
+        Assertions.assertSame(TEST_PRECISION, p.getPlane().getPrecision());
 
         EuclideanTestUtils.assertCoordinatesEqual(Vector3D.Unit.PLUS_Z, p.getPlane().getNormal(), TEST_EPS);
         Assertions.assertEquals(4, p.getVertices().size());
@@ -80,7 +80,7 @@ public class FacetDefinitionsTest {
         final ConvexPolygon3D p = FacetDefinitions.toPolygon(f, TEST_PRECISION);
 
         // assert
-        Assertions.assertSame(p.getPlane().getPrecision(), TEST_PRECISION);
+        Assertions.assertSame(TEST_PRECISION, p.getPlane().getPrecision());
 
         EuclideanTestUtils.assertCoordinatesEqual(Vector3D.Unit.MINUS_Z, p.getPlane().getNormal(), TEST_EPS);
         Assertions.assertEquals(4, p.getVertices().size());
diff --git a/commons-geometry-io-euclidean/src/test/java/org/apache/commons/geometry/io/euclidean/threed/SimpleFacetDefinitionTest.java b/commons-geometry-io-euclidean/src/test/java/org/apache/commons/geometry/io/euclidean/threed/SimpleFacetDefinitionTest.java
index 023041a..ed948b2 100644
--- a/commons-geometry-io-euclidean/src/test/java/org/apache/commons/geometry/io/euclidean/threed/SimpleFacetDefinitionTest.java
+++ b/commons-geometry-io-euclidean/src/test/java/org/apache/commons/geometry/io/euclidean/threed/SimpleFacetDefinitionTest.java
@@ -38,8 +38,11 @@ public class SimpleFacetDefinitionTest {
         // assert
         Assertions.assertEquals(FACET_PTS, f.getVertices());
         Assertions.assertNotSame(FACET_PTS, f.getVertices());
+
+        final List<Vector3D> vertices = f.getVertices();
+        final Vector3D toAdd = FACET_PTS.get(0);
         Assertions.assertThrows(UnsupportedOperationException.class,
-                () -> f.getVertices().add(FACET_PTS.get(0)));
+                () -> vertices.add(toAdd));
 
         Assertions.assertNull(f.getNormal());
     }
@@ -55,8 +58,11 @@ public class SimpleFacetDefinitionTest {
         // assert
         Assertions.assertEquals(FACET_PTS, f.getVertices());
         Assertions.assertNotSame(FACET_PTS, f.getVertices());
+
+        final List<Vector3D> vertices = f.getVertices();
+        final Vector3D toAdd = FACET_PTS.get(0);
         Assertions.assertThrows(UnsupportedOperationException.class,
-                () -> f.getVertices().add(FACET_PTS.get(0)));
+                () -> vertices.add(toAdd));
 
         Assertions.assertSame(normal, f.getNormal());
     }
diff --git a/commons-geometry-io-euclidean/src/test/java/org/apache/commons/geometry/io/euclidean/threed/obj/ObjWriterTest.java b/commons-geometry-io-euclidean/src/test/java/org/apache/commons/geometry/io/euclidean/threed/obj/ObjWriterTest.java
index 757e3a3..21b6fb6 100644
--- a/commons-geometry-io-euclidean/src/test/java/org/apache/commons/geometry/io/euclidean/threed/obj/ObjWriterTest.java
+++ b/commons-geometry-io-euclidean/src/test/java/org/apache/commons/geometry/io/euclidean/threed/obj/ObjWriterTest.java
@@ -64,6 +64,8 @@ public class ObjWriterTest {
         try (ObjWriter objWriter = new ObjWriter(writer)) {
             objWriter.close();
         }
+
+        Assertions.assertEquals("", writer.toString());
     }
 
     @Test
diff --git a/commons-geometry-io-euclidean/src/test/java/org/apache/commons/geometry/io/euclidean/threed/stl/TextStlWriterTest.java b/commons-geometry-io-euclidean/src/test/java/org/apache/commons/geometry/io/euclidean/threed/stl/TextStlWriterTest.java
index 1fd930a..a9eb74c 100644
--- a/commons-geometry-io-euclidean/src/test/java/org/apache/commons/geometry/io/euclidean/threed/stl/TextStlWriterTest.java
+++ b/commons-geometry-io-euclidean/src/test/java/org/apache/commons/geometry/io/euclidean/threed/stl/TextStlWriterTest.java
@@ -19,6 +19,7 @@ package org.apache.commons.geometry.io.euclidean.threed.stl;
 import java.io.IOException;
 import java.io.StringWriter;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 
 import org.apache.commons.geometry.core.GeometryTestUtils;
@@ -387,13 +388,17 @@ public class TextStlWriterTest {
         try (TextStlWriter writer = new TextStlWriter(out)) {
             writer.startSolid();
 
+            final List<Vector3D> noElements = Collections.emptyList();
+            final List<Vector3D> singleElement = Collections.singletonList(Vector3D.ZERO);
+            final List<Vector3D> twoElements = Arrays.asList(Vector3D.ZERO, Vector3D.of(1, 1, 1));
+
             // act/assert
             Assertions.assertThrows(IllegalArgumentException.class,
-                    () -> writer.writeTriangles(Arrays.asList(), null));
+                    () -> writer.writeTriangles(noElements, null));
             Assertions.assertThrows(IllegalArgumentException.class,
-                    () -> writer.writeTriangles(Arrays.asList(Vector3D.ZERO), null));
+                    () -> writer.writeTriangles(singleElement, null));
             Assertions.assertThrows(IllegalArgumentException.class,
-                    () -> writer.writeTriangles(Arrays.asList(Vector3D.ZERO, Vector3D.of(1, 1, 1)), null));
+                    () -> writer.writeTriangles(twoElements, null));
         }
     }