Skip to content
Permalink
Browse files
GEOMETRY-63: more minor SonarQube fixes
  • Loading branch information
darkma773r committed Jul 23, 2021
1 parent 5246bdf commit c4f1da892bdd02ffffce092c661398f58be501ee
Showing 11 changed files with 32 additions and 40 deletions.
@@ -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 @@ void testConvexRegionBoundaryBuilder_duplicateLines() {

@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
@@ -52,9 +52,11 @@ void testGetBoundaries_listCannotBeModified() {
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
@@ -76,9 +76,10 @@ void testGetSupport_listCannotBeModified() {
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
@@ -201,7 +201,7 @@ public List<Interval> toIntervals() {
}
}

if (start != null && end != null) {
if (start != null) {
intervals.add(createInterval(start, end));
}

@@ -46,7 +46,7 @@ public EmbeddingPlane getPlane() {
/** {@inheritDoc} */
@Override
public EmbeddingPlane getHyperplane() {
return plane;
return getPlane();
}

/** {@inheritDoc} */
@@ -69,7 +69,7 @@ public RegionBSPTree3D copy() {
/** {@inheritDoc} */
@Override
public Iterable<PlaneConvexSubset> boundaries() {
return createBoundaryIterable(b -> (PlaneConvexSubset) b);
return createBoundaryIterable(PlaneConvexSubset.class::cast);
}

/** {@inheritDoc} */
@@ -81,7 +81,7 @@ public Stream<PlaneConvexSubset> boundaryStream() {
/** {@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
@@ -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() {
@@ -72,7 +72,7 @@ public RegionBSPTree2D copy() {
/** {@inheritDoc} */
@Override
public Iterable<LineConvexSubset> boundaries() {
return createBoundaryIterable(b -> (LineConvexSubset) b);
return createBoundaryIterable(LineConvexSubset.class::cast);
}

/** {@inheritDoc} */
@@ -84,7 +84,7 @@ public Stream<LineConvexSubset> boundaryStream() {
/** {@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.
@@ -387,7 +387,7 @@ void testGetCentroid() {
}

@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 @@ public void checkToTree_finite() {
}

@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 @@ public void checkToTree_singlePoint() {
}

@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 @@ public void checkToTree_maxInfinite() {
}

@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 @@ public void checkToTree_minInfinite() {
}

@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);
@@ -363,7 +363,7 @@ private void checkIntersection(final Bounds3D b, final Vector3D a1, final Vector
}

@Test
public void toRegion() {
void toRegion() {
// arrange
final Bounds3D b = Bounds3D.from(
Vector3D.of(0, 4, 8),
@@ -378,7 +378,7 @@ public void toRegion() {
}

@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));
@@ -335,7 +335,7 @@ private void checkIntersection(final Bounds2D b, final Vector2D a1, final Vector
}

@Test
public void toRegion() {
void toRegion() {
// arrange
final Bounds2D b = Bounds2D.from(
Vector2D.of(0, 4),
@@ -350,7 +350,7 @@ public void toRegion() {
}

@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));
}

0 comments on commit c4f1da8

Please sign in to comment.