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 c4f1da8 GEOMETRY-63: more minor SonarQube fixes c4f1da8 is described below commit c4f1da892bdd02ffffce092c661398f58be501ee Author: Matt Juntunen <mattjuntu...@apache.org> AuthorDate: Thu Jul 22 22:12:54 2021 -0400 GEOMETRY-63: more minor SonarQube fixes --- .../AbstractConvexHyperplaneBoundedRegionTest.java | 17 ++++++++++++----- .../geometry/core/partitioning/BoundaryListTest.java | 4 +++- .../commons/geometry/enclosing/EnclosingBallTest.java | 3 ++- .../geometry/euclidean/oned/RegionBSPTree1D.java | 2 +- .../threed/AbstractEmbeddedRegionPlaneSubset.java | 2 +- .../geometry/euclidean/threed/RegionBSPTree3D.java | 4 ++-- .../euclidean/threed/line/LineConvexSubset3D.java | 18 ------------------ .../geometry/euclidean/twod/RegionBSPTree2D.java | 4 ++-- .../commons/geometry/euclidean/oned/IntervalTest.java | 10 +++++----- .../geometry/euclidean/threed/Bounds3DTest.java | 4 ++-- .../commons/geometry/euclidean/twod/Bounds2DTest.java | 4 ++-- 11 files changed, 32 insertions(+), 40 deletions(-) diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/AbstractConvexHyperplaneBoundedRegionTest.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/AbstractConvexHyperplaneBoundedRegionTest.java index cee1308..f8cf67f 100644 --- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/AbstractConvexHyperplaneBoundedRegionTest.java +++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/AbstractConvexHyperplaneBoundedRegionTest.java @@ -39,9 +39,12 @@ class AbstractConvexHyperplaneBoundedRegionTest { void testBoundaries_areUnmodifiable() { // arrange final StubRegion region = new StubRegion(new ArrayList<>()); + final List<TestLineSegment> boundaries = region.getBoundaries(); + final TestLineSegment span = TestLine.X_AXIS.span(); + // act/assert - Assertions.assertThrows(UnsupportedOperationException.class, () -> region.getBoundaries().add(TestLine.X_AXIS.span())); + Assertions.assertThrows(UnsupportedOperationException.class, () -> boundaries.add(span)); } @Test @@ -628,13 +631,17 @@ class AbstractConvexHyperplaneBoundedRegionTest { @Test void testConvexRegionBoundaryBuilder() { - // act/assert - Assertions.assertThrows(IllegalArgumentException.class, () -> StubRegion.fromBounds(Arrays.asList(TestLine.X_AXIS, TestLine.X_AXIS.reverse()))); - Assertions.assertThrows(IllegalArgumentException.class, () -> StubRegion.fromBounds(Arrays.asList( + // arrange + final List<TestLine> opposites = Arrays.asList(TestLine.X_AXIS, TestLine.X_AXIS.reverse()); + final List<TestLine> nonConvex = Arrays.asList( TestLine.X_AXIS, TestLine.Y_AXIS, new TestLine(new TestPoint2D(1, 0), new TestPoint2D(0, -1)), - new TestLine(new TestPoint2D(1, 0), new TestPoint2D(0, -2))))); + new TestLine(new TestPoint2D(1, 0), new TestPoint2D(0, -2))); + + // act/assert + Assertions.assertThrows(IllegalArgumentException.class, () -> StubRegion.fromBounds(opposites)); + Assertions.assertThrows(IllegalArgumentException.class, () -> StubRegion.fromBounds(nonConvex)); } @Test diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/BoundaryListTest.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/BoundaryListTest.java index 08e7c0f..8940cfd 100644 --- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/BoundaryListTest.java +++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/BoundaryListTest.java @@ -52,9 +52,11 @@ class BoundaryListTest { boundaries.add(new TestLineSegment(0, 0, 1, 1)); final BoundaryList<TestPoint2D, TestLineSegment> list = new BoundaryList<>(boundaries); + final List<TestLineSegment> items = list.getBoundaries(); + final TestLineSegment segment = new TestLineSegment(1, 1, 0, 2); // act/assert - Assertions.assertThrows(UnsupportedOperationException.class, () -> list.getBoundaries().add(new TestLineSegment(1, 1, 0, 2))); + Assertions.assertThrows(UnsupportedOperationException.class, () -> items.add(segment)); } @Test diff --git a/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/enclosing/EnclosingBallTest.java b/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/enclosing/EnclosingBallTest.java index de2c04b..96b5f3b 100644 --- a/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/enclosing/EnclosingBallTest.java +++ b/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/enclosing/EnclosingBallTest.java @@ -76,9 +76,10 @@ class EnclosingBallTest { final List<Vector2D> support = new ArrayList<>(Collections.singletonList(Vector2D.ZERO)); final EnclosingBall<Vector2D> ball = new EnclosingBall<>(Vector2D.of(1, 1), 4, support); + final List<Vector2D> ballSupport = ball.getSupport(); // act/assert - Assertions.assertThrows(UnsupportedOperationException.class, () -> ball.getSupport().add(Vector2D.Unit.PLUS_X)); + Assertions.assertThrows(UnsupportedOperationException.class, () -> ballSupport.add(Vector2D.Unit.PLUS_X)); } @Test diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/RegionBSPTree1D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/RegionBSPTree1D.java index a6b9434..cb94de7 100644 --- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/RegionBSPTree1D.java +++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/RegionBSPTree1D.java @@ -201,7 +201,7 @@ public final class RegionBSPTree1D extends AbstractRegionBSPTree<Vector1D, Regio } } - if (start != null && end != null) { + if (start != null) { intervals.add(createInterval(start, end)); } diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/AbstractEmbeddedRegionPlaneSubset.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/AbstractEmbeddedRegionPlaneSubset.java index d535533..f9f29ea 100644 --- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/AbstractEmbeddedRegionPlaneSubset.java +++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/AbstractEmbeddedRegionPlaneSubset.java @@ -46,7 +46,7 @@ abstract class AbstractEmbeddedRegionPlaneSubset extends AbstractPlaneSubset imp /** {@inheritDoc} */ @Override public EmbeddingPlane getHyperplane() { - return plane; + return getPlane(); } /** {@inheritDoc} */ diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3D.java index 444a350..db12354 100644 --- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3D.java +++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3D.java @@ -69,7 +69,7 @@ public final class RegionBSPTree3D extends AbstractRegionBSPTree<Vector3D, Regio /** {@inheritDoc} */ @Override public Iterable<PlaneConvexSubset> boundaries() { - return createBoundaryIterable(b -> (PlaneConvexSubset) b); + return createBoundaryIterable(PlaneConvexSubset.class::cast); } /** {@inheritDoc} */ @@ -81,7 +81,7 @@ public final class RegionBSPTree3D extends AbstractRegionBSPTree<Vector3D, Regio /** {@inheritDoc} */ @Override public List<PlaneConvexSubset> getBoundaries() { - return createBoundaryList(b -> (PlaneConvexSubset) b); + return createBoundaryList(PlaneConvexSubset.class::cast); } /** Return a list of {@link ConvexVolume}s representing the same region diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/line/LineConvexSubset3D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/line/LineConvexSubset3D.java index e205b16..d3d9d4b 100644 --- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/line/LineConvexSubset3D.java +++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/line/LineConvexSubset3D.java @@ -33,18 +33,6 @@ public abstract class LineConvexSubset3D extends LineSubset3D { super(line); } - /** Return true if the line subset is infinite. - * @return true if the line subset is infinite. - */ - @Override - public abstract boolean isInfinite(); - - /** Return true if the line subset is finite. - * @return true if the line subset is finite. - */ - @Override - public abstract boolean isFinite(); - /** Get the start point for the line subset. * @return the start point for the line subset, or null if no start point exists */ @@ -69,12 +57,6 @@ public abstract class LineConvexSubset3D extends LineSubset3D { */ public abstract double getSubspaceEnd(); - /** Get the size (length) of the line subset. - * @return the size of the line subset - */ - @Override - public abstract double getSize(); - /** {@inheritDoc} */ @Override public Interval getSubspaceRegion() { diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/RegionBSPTree2D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/RegionBSPTree2D.java index d4977d8..bd3edd6 100644 --- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/RegionBSPTree2D.java +++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/RegionBSPTree2D.java @@ -72,7 +72,7 @@ public final class RegionBSPTree2D extends AbstractRegionBSPTree<Vector2D, Regio /** {@inheritDoc} */ @Override public Iterable<LineConvexSubset> boundaries() { - return createBoundaryIterable(b -> (LineConvexSubset) b); + return createBoundaryIterable(LineConvexSubset.class::cast); } /** {@inheritDoc} */ @@ -84,7 +84,7 @@ public final class RegionBSPTree2D extends AbstractRegionBSPTree<Vector2D, Regio /** {@inheritDoc} */ @Override public List<LineConvexSubset> getBoundaries() { - return createBoundaryList(b -> (LineConvexSubset) b); + return createBoundaryList(LineConvexSubset.class::cast); } /** Get the boundary of the region as a list of connected line subset paths. diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/IntervalTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/IntervalTest.java index 0f5193c..ead9b95 100644 --- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/IntervalTest.java +++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/IntervalTest.java @@ -387,7 +387,7 @@ class IntervalTest { } @Test - public void checkToTree_finite() { + void checkToTree_finite() { // arrange final Precision.DoubleEquivalence precision = Precision.doubleEquivalenceOfEpsilon(1e-2); final Interval interval = Interval.of(-1, 1, precision); @@ -412,7 +412,7 @@ class IntervalTest { } @Test - public void checkToTree_singlePoint() { + void checkToTree_singlePoint() { // arrange final Precision.DoubleEquivalence precision = Precision.doubleEquivalenceOfEpsilon(1e-2); final Interval interval = Interval.of(1, 1, precision); @@ -433,7 +433,7 @@ class IntervalTest { } @Test - public void checkToTree_maxInfinite() { + void checkToTree_maxInfinite() { // arrange final Precision.DoubleEquivalence precision = Precision.doubleEquivalenceOfEpsilon(1e-2); final Interval interval = Interval.of(-1, Double.POSITIVE_INFINITY, precision); @@ -457,7 +457,7 @@ class IntervalTest { } @Test - public void checkToTree_minInfinite() { + void checkToTree_minInfinite() { // arrange final Precision.DoubleEquivalence precision = Precision.doubleEquivalenceOfEpsilon(1e-2); final Interval interval = Interval.of(Double.NEGATIVE_INFINITY, 1, precision); @@ -481,7 +481,7 @@ class IntervalTest { } @Test - public void checkToTree_minMaxInfinite() { + void checkToTree_minMaxInfinite() { // arrange final Precision.DoubleEquivalence precision = Precision.doubleEquivalenceOfEpsilon(1e-2); final Interval interval = Interval.of(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, precision); diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Bounds3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Bounds3DTest.java index bf66903..aada5a4 100644 --- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Bounds3DTest.java +++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Bounds3DTest.java @@ -363,7 +363,7 @@ class Bounds3DTest { } @Test - public void toRegion() { + void toRegion() { // arrange final Bounds3D b = Bounds3D.from( Vector3D.of(0, 4, 8), @@ -378,7 +378,7 @@ class Bounds3DTest { } @Test - public void toRegion_boundingBoxTooSmall() { + void toRegion_boundingBoxTooSmall() { // act/assert Assertions.assertThrows(IllegalArgumentException.class, () -> Bounds3D.from(Vector3D.ZERO, Vector3D.of(1e-12, 1e-12, 1e-12)) .toRegion(TEST_PRECISION)); diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Bounds2DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Bounds2DTest.java index 36b9a3d..17cf497 100644 --- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Bounds2DTest.java +++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Bounds2DTest.java @@ -335,7 +335,7 @@ class Bounds2DTest { } @Test - public void toRegion() { + void toRegion() { // arrange final Bounds2D b = Bounds2D.from( Vector2D.of(0, 4), @@ -350,7 +350,7 @@ class Bounds2DTest { } @Test - public void toRegion_boundingBoxTooSmall() { + void toRegion_boundingBoxTooSmall() { // act/assert Assertions.assertThrows(IllegalArgumentException.class, () -> Bounds2D.from(Vector2D.ZERO, Vector2D.of(1e-12, 1e-12)).toRegion(TEST_PRECISION)); }