You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2019/09/26 12:54:27 UTC

[commons-geometry] branch master updated (687412e -> 2447eaf)

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

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


    from 687412e  Update "pom.xml" (based on the one for "Commons RNG").
     new a7ef97f  GEOMETRY-46: Add additional UnitVector methods
     new 1f52ccf  Add unit tests
     new a07e4bd  Fix braces
     new 91bd071  Prefer get methods over use of super
     new a0fdcf1  Fix unit vector test precision
     new a5a4516  Merge branch 'GEOMETRY-46__steven'
     new 2447eaf  Enable CheckStyle (based on the configuration for "Commons RNG").

The 7 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../commons/geometry/euclidean/oned/Vector1D.java  |  12 +
 .../geometry/euclidean/threed/Vector3D.java        |  12 +
 .../commons/geometry/euclidean/twod/Vector2D.java  |  12 +
 .../geometry/euclidean/oned/Vector1DTest.java      |  29 +++
 .../geometry/euclidean/threed/Vector3DTest.java    |  29 +++
 .../geometry/euclidean/twod/Vector2DTest.java      |  31 +++
 pom.xml                                            |  55 +++-
 .../checkstyle-suppressions.xml}                   |  26 +-
 src/main/resources/checkstyle/checkstyle.xml       | 289 +++++++++++++--------
 9 files changed, 365 insertions(+), 130 deletions(-)
 copy src/main/resources/{spotbugs/spotbugs-exclude-filter.xml => checkstyle/checkstyle-suppressions.xml} (58%)


[commons-geometry] 01/07: GEOMETRY-46: Add additional UnitVector methods

Posted by er...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit a7ef97fea91e6ed73df653041d0efdfa15f1ec26
Author: Steven Fontaine <si...@gmail.com>
AuthorDate: Tue Sep 24 13:22:16 2019 -0500

    GEOMETRY-46: Add additional UnitVector methods
---
 .../org/apache/commons/geometry/euclidean/oned/Vector1D.java | 12 ++++++++++++
 .../apache/commons/geometry/euclidean/threed/Vector3D.java   | 12 ++++++++++++
 .../org/apache/commons/geometry/euclidean/twod/Vector2D.java | 12 ++++++++++++
 3 files changed, 36 insertions(+)

diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Vector1D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Vector1D.java
index 07f3417..56b0af0 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Vector1D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Vector1D.java
@@ -409,6 +409,12 @@ public class Vector1D extends EuclideanVector<Vector1D> {
 
         /** {@inheritDoc} */
         @Override
+        public double normSq() {
+            return 1;
+        }
+
+        /** {@inheritDoc} */
+        @Override
         public Vector1D normalize() {
             return this;
         }
@@ -418,5 +424,11 @@ public class Vector1D extends EuclideanVector<Vector1D> {
         public Vector1D withNorm(final double mag) {
             return multiply(mag);
         }
+
+        /** {@inheritDoc} */
+        @Override
+        public UnitVector negate() {
+            return new UnitVector(-super.x);
+        }
     }
 }
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Vector3D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Vector3D.java
index 977c32a..1ad050b 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Vector3D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Vector3D.java
@@ -622,6 +622,12 @@ public class Vector3D extends MultiDimensionalEuclideanVector<Vector3D> {
 
         /** {@inheritDoc} */
         @Override
+        public double normSq() {
+            return 1;
+        }
+
+        /** {@inheritDoc} */
+        @Override
         public Vector3D normalize() {
             return this;
         }
@@ -631,5 +637,11 @@ public class Vector3D extends MultiDimensionalEuclideanVector<Vector3D> {
         public Vector3D withNorm(final double mag) {
             return multiply(mag);
         }
+
+        /** {@inheritDoc} */
+        @Override
+        public UnitVector negate() {
+            return new UnitVector(-super.x, -super.y, -super.z);
+        }
     }
 }
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Vector2D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Vector2D.java
index 8f3cf7b..27eef71 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Vector2D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Vector2D.java
@@ -556,6 +556,12 @@ public class Vector2D extends MultiDimensionalEuclideanVector<Vector2D> {
 
         /** {@inheritDoc} */
         @Override
+        public double normSq() {
+            return 1;
+        }
+
+        /** {@inheritDoc} */
+        @Override
         public Vector2D normalize() {
             return this;
         }
@@ -565,5 +571,11 @@ public class Vector2D extends MultiDimensionalEuclideanVector<Vector2D> {
         public Vector2D withNorm(final double mag) {
             return multiply(mag);
         }
+
+        /** {@inheritDoc} */
+        @Override
+        public UnitVector negate() {
+            return new UnitVector(-super.x, -super.y);
+        }
     }
 }


[commons-geometry] 02/07: Add unit tests

Posted by er...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 1f52ccfbe29d5b1149ef9d03bd94ece8e5b667fa
Author: Steven Fontaine <si...@gmail.com>
AuthorDate: Tue Sep 24 16:48:17 2019 -0500

    Add unit tests
---
 .../geometry/euclidean/oned/Vector1DTest.java      | 31 ++++++++++++++++++++++
 .../geometry/euclidean/threed/Vector3DTest.java    | 29 ++++++++++++++++++++
 .../geometry/euclidean/twod/Vector2DTest.java      | 31 ++++++++++++++++++++++
 3 files changed, 91 insertions(+)

diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Vector1DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Vector1DTest.java
index e3b015d..377b1fd 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Vector1DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Vector1DTest.java
@@ -113,6 +113,16 @@ public class Vector1DTest {
     }
 
     @Test
+    public void testNorm_unitVectors()
+    {
+        // arrange
+        Vector1D v = Vector1D.of(2.0).normalize();
+        
+        // act/assert
+        Assert.assertEquals(1.0, v.norm(), TEST_TOLERANCE);
+    }
+
+    @Test
     public void testNormSq() {
         // act/assert
         Assert.assertEquals(0.0, Vector1D.of(0).normSq(), TEST_TOLERANCE);
@@ -121,6 +131,16 @@ public class Vector1DTest {
     }
 
     @Test
+    public void testNormSq_unitVectors()
+    {
+        // arrange
+        Vector1D v = Vector1D.of(2.0).normalize();
+        
+        // act/assert
+        Assert.assertEquals(1.0, v.normSq(), TEST_TOLERANCE);
+    }
+
+    @Test
     public void testWithNorm() {
         // act/assert
         checkVector(Vector1D.ONE.withNorm(0.0), 0.0);
@@ -262,6 +282,17 @@ public class Vector1DTest {
     }
 
     @Test
+    public void testNegate_unitVectors() {
+        // arrange
+        Vector1D v1 = Vector1D.of(0.1).normalize();
+        Vector1D v2 = Vector1D.of(-0.1).normalize();
+
+        // act/assert
+        checkVector(v1.negate(), -1);
+        checkVector(v2.negate(), 1);
+    }
+
+    @Test
     public void testScalarMultiply() {
         // act/assert
         checkVector(Vector1D.of(1).multiply(3), 3);
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Vector3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Vector3DTest.java
index 0bb73ab..b8bc4bd 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Vector3DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Vector3DTest.java
@@ -159,6 +159,15 @@ public class Vector3DTest {
         Assert.assertEquals(Math.sqrt(29), Vector3D.of(2, 3, 4).norm(), EPS);
         Assert.assertEquals(Math.sqrt(29), Vector3D.of(-2, -3, -4).norm(), EPS);
     }
+    
+    @Test
+    public void testNorm_unitVectors() {
+        // arrange
+        Vector3D v = Vector3D.of(1.0, 2.0, 3.0).normalize();
+        
+        // act/assert
+        Assert.assertEquals(1.0, v.norm(), EPS);
+    }
 
     @Test
     public void testNormSq() {
@@ -167,6 +176,15 @@ public class Vector3DTest {
         Assert.assertEquals(29, Vector3D.of(2, 3, 4).normSq(), EPS);
         Assert.assertEquals(29, Vector3D.of(-2, -3, -4).normSq(), EPS);
     }
+    
+    @Test
+    public void testNormSq_unitVectors() {
+        // arrange
+        Vector3D v = Vector3D.of(1.0, 2.0, 3.0).normalize();
+        
+        // act/assert
+        Assert.assertEquals(1.0, v.normSq(), EPS);
+    }
 
     @Test
     public void testWithNorm() {
@@ -314,6 +332,17 @@ public class Vector3DTest {
     }
 
     @Test
+    public void testNegate_unitVectors() {
+        // arrange
+        Vector3D v1 = Vector3D.of(1.0, 2.0, 3.0).normalize();
+        Vector3D v2 = Vector3D.of(-2.0, -4.0, -3.0).normalize();
+        
+        // act/assert
+        checkVector(v1.negate(), -1.0 / Math.sqrt(14.0), -Math.sqrt(2.0 / 7.0), -3.0 / Math.sqrt(14.0));
+        checkVector(v2.negate(), 2.0 / Math.sqrt(29.0), 4.0 / Math.sqrt(29.0), 3.0 / Math.sqrt(29.0));
+    }
+
+    @Test
     public void testNormalize() {
         // arrange
         double invSqrt3 = 1 / Math.sqrt(3);
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Vector2DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Vector2DTest.java
index d27e615..2e6ec80 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Vector2DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Vector2DTest.java
@@ -144,6 +144,15 @@ public class Vector2DTest {
     }
 
     @Test
+    public void testNorm_unitVectors() {
+        // arrange
+        Vector2D v = Vector2D.of(2.0, 3.0).normalize();
+
+        // act/assert
+        Assert.assertEquals(1.0, v.norm(), EPS);
+    }
+
+    @Test
     public void testNormSq() {
         // act/assert
         Assert.assertEquals(0.0, Vector2D.of(0, 0).normSq(), EPS);
@@ -157,6 +166,15 @@ public class Vector2DTest {
     }
 
     @Test
+    public void testNormSq_unitVectors() {
+        // arrange
+        Vector2D v = Vector2D.of(2.0, 3.0).normalize();
+
+        // act/assert
+        Assert.assertEquals(1.0, v.normSq(), EPS);
+    }
+
+    @Test
     public void testWithNorm() {
         // act/assert
         checkVector(Vector2D.of(3, 4).withNorm(1.0), 0.6, 0.8);
@@ -309,6 +327,19 @@ public class Vector2DTest {
     }
 
     @Test
+    public void testNegate_unitVectors() {
+        // arrange
+        Vector2D v1 = Vector2D.of(1.0, 1.0).normalize();
+        Vector2D v2 = Vector2D.of(-1.0, -2.0).normalize();
+        Vector2D v3 = Vector2D.of(2.0, -3.0).normalize();
+ 
+        // act/assert
+        checkVector(v1.negate(), -1.0 / Math.sqrt(2.0), -1.0 / Math.sqrt(2.0));
+        checkVector(v2.negate(), 1.0 / Math.sqrt(5.0), 2.0 / Math.sqrt(5.0));
+        checkVector(v3.negate(), -2.0 / Math.sqrt(13.0), 3.0 / Math.sqrt(13.0));
+    }
+
+    @Test
     public void testScalarMultiply() {
         // act/assert
         checkVector(Vector2D.of(1, 2).multiply(0), 0, 0);


[commons-geometry] 05/07: Fix unit vector test precision

Posted by er...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit a0fdcf120947803bfb5d15e403b92da9bfa34be3
Author: Steven Fontaine <si...@gmail.com>
AuthorDate: Wed Sep 25 13:39:50 2019 -0500

    Fix unit vector test precision
    
    (Also fixes several nearby instances of spurious whitespace)
---
 .../commons/geometry/euclidean/oned/Vector1DTest.java      |  8 ++++----
 .../commons/geometry/euclidean/threed/Vector3DTest.java    | 14 +++++++-------
 .../commons/geometry/euclidean/twod/Vector2DTest.java      |  6 +++---
 3 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Vector1DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Vector1DTest.java
index 97a697a..4583d8b 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Vector1DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Vector1DTest.java
@@ -116,9 +116,9 @@ public class Vector1DTest {
     public void testNorm_unitVectors() {
         // arrange
         Vector1D v = Vector1D.of(2.0).normalize();
-        
+
         // act/assert
-        Assert.assertEquals(1.0, v.norm(), TEST_TOLERANCE);
+        Assert.assertEquals(1.0, v.norm(), 0.0);
     }
 
     @Test
@@ -133,9 +133,9 @@ public class Vector1DTest {
     public void testNormSq_unitVectors() {
         // arrange
         Vector1D v = Vector1D.of(2.0).normalize();
-        
+
         // act/assert
-        Assert.assertEquals(1.0, v.normSq(), TEST_TOLERANCE);
+        Assert.assertEquals(1.0, v.normSq(), 0.0);
     }
 
     @Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Vector3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Vector3DTest.java
index b8bc4bd..c4b5de3 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Vector3DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Vector3DTest.java
@@ -159,14 +159,14 @@ public class Vector3DTest {
         Assert.assertEquals(Math.sqrt(29), Vector3D.of(2, 3, 4).norm(), EPS);
         Assert.assertEquals(Math.sqrt(29), Vector3D.of(-2, -3, -4).norm(), EPS);
     }
-    
+
     @Test
     public void testNorm_unitVectors() {
         // arrange
         Vector3D v = Vector3D.of(1.0, 2.0, 3.0).normalize();
-        
+
         // act/assert
-        Assert.assertEquals(1.0, v.norm(), EPS);
+        Assert.assertEquals(1.0, v.norm(), 0.0);
     }
 
     @Test
@@ -176,14 +176,14 @@ public class Vector3DTest {
         Assert.assertEquals(29, Vector3D.of(2, 3, 4).normSq(), EPS);
         Assert.assertEquals(29, Vector3D.of(-2, -3, -4).normSq(), EPS);
     }
-    
+
     @Test
     public void testNormSq_unitVectors() {
         // arrange
         Vector3D v = Vector3D.of(1.0, 2.0, 3.0).normalize();
-        
+
         // act/assert
-        Assert.assertEquals(1.0, v.normSq(), EPS);
+        Assert.assertEquals(1.0, v.normSq(), 0.0);
     }
 
     @Test
@@ -336,7 +336,7 @@ public class Vector3DTest {
         // arrange
         Vector3D v1 = Vector3D.of(1.0, 2.0, 3.0).normalize();
         Vector3D v2 = Vector3D.of(-2.0, -4.0, -3.0).normalize();
-        
+
         // act/assert
         checkVector(v1.negate(), -1.0 / Math.sqrt(14.0), -Math.sqrt(2.0 / 7.0), -3.0 / Math.sqrt(14.0));
         checkVector(v2.negate(), 2.0 / Math.sqrt(29.0), 4.0 / Math.sqrt(29.0), 3.0 / Math.sqrt(29.0));
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Vector2DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Vector2DTest.java
index 2e6ec80..d619342 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Vector2DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Vector2DTest.java
@@ -149,7 +149,7 @@ public class Vector2DTest {
         Vector2D v = Vector2D.of(2.0, 3.0).normalize();
 
         // act/assert
-        Assert.assertEquals(1.0, v.norm(), EPS);
+        Assert.assertEquals(1.0, v.norm(), 0.0);
     }
 
     @Test
@@ -171,7 +171,7 @@ public class Vector2DTest {
         Vector2D v = Vector2D.of(2.0, 3.0).normalize();
 
         // act/assert
-        Assert.assertEquals(1.0, v.normSq(), EPS);
+        Assert.assertEquals(1.0, v.normSq(), 0.0);
     }
 
     @Test
@@ -332,7 +332,7 @@ public class Vector2DTest {
         Vector2D v1 = Vector2D.of(1.0, 1.0).normalize();
         Vector2D v2 = Vector2D.of(-1.0, -2.0).normalize();
         Vector2D v3 = Vector2D.of(2.0, -3.0).normalize();
- 
+
         // act/assert
         checkVector(v1.negate(), -1.0 / Math.sqrt(2.0), -1.0 / Math.sqrt(2.0));
         checkVector(v2.negate(), 1.0 / Math.sqrt(5.0), 2.0 / Math.sqrt(5.0));


[commons-geometry] 04/07: Prefer get methods over use of super

Posted by er...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 91bd0711dcd4ff109dd51f5268aba989260898fb
Author: Steven Fontaine <si...@gmail.com>
AuthorDate: Wed Sep 25 13:36:45 2019 -0500

    Prefer get methods over use of super
---
 .../main/java/org/apache/commons/geometry/euclidean/oned/Vector1D.java  | 2 +-
 .../java/org/apache/commons/geometry/euclidean/threed/Vector3D.java     | 2 +-
 .../main/java/org/apache/commons/geometry/euclidean/twod/Vector2D.java  | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Vector1D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Vector1D.java
index 56b0af0..4be9515 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Vector1D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Vector1D.java
@@ -428,7 +428,7 @@ public class Vector1D extends EuclideanVector<Vector1D> {
         /** {@inheritDoc} */
         @Override
         public UnitVector negate() {
-            return new UnitVector(-super.x);
+            return new UnitVector(-getX());
         }
     }
 }
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Vector3D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Vector3D.java
index 1ad050b..e0f86f3 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Vector3D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Vector3D.java
@@ -641,7 +641,7 @@ public class Vector3D extends MultiDimensionalEuclideanVector<Vector3D> {
         /** {@inheritDoc} */
         @Override
         public UnitVector negate() {
-            return new UnitVector(-super.x, -super.y, -super.z);
+            return new UnitVector(-getX(), -getY(), -getZ());
         }
     }
 }
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Vector2D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Vector2D.java
index 27eef71..1b7c797 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Vector2D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Vector2D.java
@@ -575,7 +575,7 @@ public class Vector2D extends MultiDimensionalEuclideanVector<Vector2D> {
         /** {@inheritDoc} */
         @Override
         public UnitVector negate() {
-            return new UnitVector(-super.x, -super.y);
+            return new UnitVector(-getX(), -getY());
         }
     }
 }


[commons-geometry] 03/07: Fix braces

Posted by er...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit a07e4bdbba71619ad4e9058871458e0cd85222dd
Author: Steven Fontaine <si...@gmail.com>
AuthorDate: Tue Sep 24 19:27:53 2019 -0500

    Fix braces
---
 .../org/apache/commons/geometry/euclidean/oned/Vector1DTest.java    | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Vector1DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Vector1DTest.java
index 377b1fd..97a697a 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Vector1DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Vector1DTest.java
@@ -113,8 +113,7 @@ public class Vector1DTest {
     }
 
     @Test
-    public void testNorm_unitVectors()
-    {
+    public void testNorm_unitVectors() {
         // arrange
         Vector1D v = Vector1D.of(2.0).normalize();
         
@@ -131,8 +130,7 @@ public class Vector1DTest {
     }
 
     @Test
-    public void testNormSq_unitVectors()
-    {
+    public void testNormSq_unitVectors() {
         // arrange
         Vector1D v = Vector1D.of(2.0).normalize();
         


[commons-geometry] 07/07: Enable CheckStyle (based on the configuration for "Commons RNG").

Posted by er...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 2447eaf476127cd745af069a4ae4c22e3eb63f7d
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
AuthorDate: Thu Sep 26 14:32:12 2019 +0200

    Enable CheckStyle (based on the configuration for "Commons RNG").
    
    "validate" requirement is commented out as it would currently fail the build.
---
 pom.xml                                            |  55 +++-
 .../checkstyle/checkstyle-suppressions.xml         |  29 +++
 src/main/resources/checkstyle/checkstyle.xml       | 289 +++++++++++++--------
 3 files changed, 257 insertions(+), 116 deletions(-)

diff --git a/pom.xml b/pom.xml
index 73468b4..80ba963 100644
--- a/pom.xml
+++ b/pom.xml
@@ -239,7 +239,39 @@
           <excludeFilterFile>${geometry.parent.dir}/src/main/resources/spotbugs/spotbugs-exclude-filter.xml</excludeFilterFile>
         </configuration>
       </plugin>
-      <!-- maven-checkstyle-plugin runs in JDK 8+ profile so not included here -->
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-checkstyle-plugin</artifactId>
+        <version>${geometry.checkstyle.version}</version>
+        <dependencies>
+          <dependency>
+            <groupId>com.puppycrawl.tools</groupId>
+            <artifactId>checkstyle</artifactId>
+            <version>${geometry.checkstyle.dep.version}</version>
+          </dependency>
+        </dependencies>
+        <configuration>
+          <includeTestSourceDirectory>true</includeTestSourceDirectory>
+          <configLocation>${geometry.parent.dir}/src/main/resources/checkstyle/checkstyle.xml</configLocation>
+          <headerLocation>${geometry.parent.dir}/src/main/resources/checkstyle/license-header.txt</headerLocation>
+          <suppressionsLocation>${geometry.parent.dir}/src/main/resources/checkstyle/checkstyle-suppressions.xml</suppressionsLocation>
+          <enableRulesSummary>false</enableRulesSummary>
+          <logViolationsToConsole>false</logViolationsToConsole>
+          <failOnViolation>true</failOnViolation>
+          <resourceExcludes>NOTICE.txt,LICENSE.txt,**/maven-archiver/pom.properties,**/resolver-status.properties</resourceExcludes>
+          <excludes>**/generated/**.java</excludes>
+        </configuration>
+        <!-- Uncommenting the lines below currently results in a failed build (see report). -->
+        <!-- <executions> -->
+        <!--   <execution> -->
+        <!--     <id>validate</id> -->
+        <!--     <phase>validate</phase> -->
+        <!--     <goals> -->
+        <!--       <goal>check</goal> -->
+        <!--     </goals> -->
+        <!--   </execution> -->
+        <!-- </executions> -->
+      </plugin>
       <plugin>
         <artifactId>maven-pmd-plugin</artifactId>
         <version>${geometry.pmd.version}</version>
@@ -370,7 +402,26 @@
           <excludeFilterFile>${geometry.parent.dir}/src/main/resources/spotbugs/spotbugs-exclude-filter.xml</excludeFilterFile>
         </configuration>
       </plugin>
-      <!-- maven-checkstyle-plugin runs in JDK 8+ profile so not included here -->
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-checkstyle-plugin</artifactId>
+        <version>${geometry.checkstyle.version}</version>
+        <configuration>
+          <configLocation>${geometry.parent.dir}/src/main/resources/checkstyle/checkstyle.xml</configLocation>
+          <headerLocation>${geometry.parent.dir}/src/main/resources/checkstyle/license-header.txt</headerLocation>
+          <suppressionsLocation>${geometry.parent.dir}/src/main/resources/checkstyle/checkstyle-suppressions.xml</suppressionsLocation>
+          <enableRulesSummary>false</enableRulesSummary>
+          <includeResources>false</includeResources>
+          <excludes>**/generated/**.java</excludes>
+        </configuration>
+        <reportSets>
+          <reportSet>
+            <reports>
+              <report>checkstyle</report>
+            </reports>
+          </reportSet>
+        </reportSets>
+      </plugin>
       <plugin>
         <artifactId>maven-pmd-plugin</artifactId>
         <version>${geometry.pmd.version}</version>
diff --git a/src/main/resources/checkstyle/checkstyle-suppressions.xml b/src/main/resources/checkstyle/checkstyle-suppressions.xml
new file mode 100644
index 0000000..96c8490
--- /dev/null
+++ b/src/main/resources/checkstyle/checkstyle-suppressions.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<!DOCTYPE suppressions PUBLIC
+    "-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
+    "https://checkstyle.org/dtds/suppressions_1_2.dtd">
+<suppressions>
+  <!-- Be more lenient on tests. -->
+  <suppress checks="Javadoc" files=".*[/\\]test[/\\].*" />
+  <suppress checks="MultipleStringLiterals" files=".*[/\\]test[/\\].*" />
+  <suppress checks="DesignForExtension" files=".*[/\\]test[/\\].*" />
+  <suppress checks="LineLength" files=".*[/\\]test[/\\].*" />
+  <suppress checks="IllegalCatch" files=".*[/\\]test[/\\].*" />
+  <suppress checks="MethodLength" files="" />
+</suppressions>
diff --git a/src/main/resources/checkstyle/checkstyle.xml b/src/main/resources/checkstyle/checkstyle.xml
index d498299..d834902 100644
--- a/src/main/resources/checkstyle/checkstyle.xml
+++ b/src/main/resources/checkstyle/checkstyle.xml
@@ -17,86 +17,205 @@
    limitations under the License.
   -->
 
-<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.1//EN" "http://www.puppycrawl.com/dtds/configuration_1_1.dtd">
+<!DOCTYPE module PUBLIC
+          "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
+          "https://checkstyle.org/dtds/configuration_1_3.dtd">
 
-<!-- Commons Geometry customization of default Checkstyle behavior -->
+<!--
+  Commons Geometry customization of default Checkstyle behaviour:
+  https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/sun_checks.xml
+-->
 <module name="Checker">
+  <module name="SuppressionFilter">
+    <!-- Default property set by maven-checkstyle-plugin -->
+    <property name="file" value="${checkstyle.suppressions.file}"/>
+    <property name="optional" value="false"/>
+  </module>
+
   <property name="localeLanguage" value="en"/>
 
-  <module name="TreeWalker">
+  <property name="fileExtensions" value="java, properties, xml" />
 
-    <!-- Operator must be at end of wrapped line -->
-    <module name="OperatorWrap">
-      <property name="option" value="eol"/>
-    </module>
+  <!-- Excludes all 'module-info.java' files -->
+  <!-- See https://checkstyle.org/config_filefilters.html -->
+  <module name="BeforeExecutionExclusionFileFilter">
+    <property name="fileNamePattern" value="module\-info\.java$" />
+  </module>
 
-    <!-- No if/else/do/for/while without braces -->
-    <module name="NeedBraces"/>
+  <!-- Checks that a package-info.java file exists for each package. -->
+  <!-- See http://checkstyle.sourceforge.net/config_javadoc.html#JavadocPackage -->
+  <module name="JavadocPackage" />
+
+  <!-- Checks whether files end with a new line. -->
+  <!-- See http://checkstyle.sourceforge.net/config_misc.html#NewlineAtEndOfFile -->
+  <module name="NewlineAtEndOfFile" />
+
+  <!-- Checks that property files contain the same keys. -->
+  <!-- See http://checkstyle.sourceforge.net/config_misc.html#Translation -->
+  <module name="Translation" />
+
+  <!-- Checks for Size Violations. -->
+  <!-- See http://checkstyle.sourceforge.net/config_sizes.html -->
+  <module name="FileLength" />
+
+  <!-- Checks for whitespace -->
+  <!-- See http://checkstyle.sourceforge.net/config_whitespace.html -->
+  <module name="FileTabCharacter" />
+
+  <!-- Miscellaneous other checks. -->
+  <!-- See http://checkstyle.sourceforge.net/config_misc.html -->
+  <module name="RegexpSingleline">
+    <property name="format" value="\s+$" />
+    <property name="minimum" value="0" />
+    <property name="maximum" value="0" />
+    <property name="message" value="Line has trailing spaces." />
+  </module>
 
-    <!-- Interfaces must be types (not just constants) -->
-    <module name="InterfaceIsType"/>
+  <!-- Checks for Headers -->
+  <!-- See http://checkstyle.sourceforge.net/config_header.html -->
+  <module name="Header">
+    <property name="headerFile" value="${checkstyle.header.file}"/>
+  </module>
 
-    <!-- Must have class / interface header comments -->
-    <module name="JavadocType"/>
+  <module name="TreeWalker">
 
-     <!-- Require method javadocs, allow undeclared RTE -->
+    <!-- Checks for Javadoc comments. -->
+    <!-- See http://checkstyle.sourceforge.net/config_javadoc.html -->
+    <!-- Require method javadocs, allow undeclared RTE -->
     <module name="JavadocMethod">
       <property name="allowUndeclaredRTE" value="true"/>
       <property name="allowThrowsTagsForSubclasses" value="true"/>
       <property name="validateThrows" value="false"/>
     </module>
+    <module name="JavadocType" />
+    <module name="JavadocVariable" />
+    <module name="JavadocStyle" />
+    <!-- <module name="MissingJavadocType"/> -->
 
-    <!-- Require field javadoc -->
-    <module name="JavadocVariable"/>
+    <!-- Checks for Naming Conventions. -->
+    <!-- See http://checkstyle.sourceforge.net/config_naming.html -->
+    <module name="ConstantName" />
+    <module name="LocalFinalVariableName" />
+    <module name="LocalVariableName" />
+    <module name="MemberName" />
+    <module name="MethodName" />
+    <module name="PackageName" />
+    <module name="ParameterName" />
+    <module name="StaticVariableName" />
+    <module name="TypeName" />
+
+    <!-- Checks for imports -->
+    <!-- See http://checkstyle.sourceforge.net/config_import.html -->
+    <module name="AvoidStarImport" />
+    <module name="IllegalImport" /> <!-- defaults to sun.* packages -->
+    <module name="RedundantImport" />
+    <module name="UnusedImports">
+      <property name="processJavadoc" value="false" />
+    </module>
 
-    <!-- No public fields -->
-    <module name="VisibilityModifier">
-       <property name="protectedAllowed" value="true"/>
+    <!-- Checks for Size Violations. -->
+    <!-- See http://checkstyle.sourceforge.net/config_sizes.html -->
+    <module name="LineLength">
+      <!-- Ignore lines that begin with " * ", such as within a Javadoc comment. -->
+      <property name="ignorePattern" value="^ *\* *[^ ]"/>
+      <property name="max" value="120"/>
+    </module>
+    <module name="MethodLength" />
+    <module name="ParameterNumber" />
+
+    <!-- Checks for whitespace -->
+    <!-- See http://checkstyle.sourceforge.net/config_whitespace.html -->
+    <module name="EmptyForIteratorPad" />
+    <module name="GenericWhitespace" />
+    <module name="MethodParamPad" />
+    <module name="NoWhitespaceAfter" />
+    <module name="NoWhitespaceBefore" />
+    <!-- Operator must be at end of wrapped line -->
+    <module name="OperatorWrap">
+      <property name="option" value="eol"/>
+    </module>
+    <module name="ParenPad" />
+    <module name="TypecastParenPad" />
+    <module name="WhitespaceAfter">
+      <property name="tokens" value="COMMA, SEMI, LITERAL_IF, LITERAL_ELSE, LITERAL_WHILE, LITERAL_DO, LITERAL_FOR, DO_WHILE"/>
+    </module>
+    <module name="WhitespaceAround">
+      <property name="allowEmptyConstructors" value="true"/>
+      <property name="allowEmptyTypes" value="true"/>
     </module>
 
-    <!-- Require hash code override when equals is -->
-    <module name="EqualsHashCode"/>
+    <!-- Modifier Checks -->
+    <!-- See http://checkstyle.sourceforge.net/config_modifiers.html -->
+    <module name="ModifierOrder" />
+    <module name="RedundantModifier" />
 
+    <!-- Checks for blocks. You know, those {}'s -->
+    <!-- See http://checkstyle.sourceforge.net/config_blocks.html -->
+    <module name="AvoidNestedBlocks" />
+    <module name="EmptyBlock" />
+    <module name="LeftCurly" />
+    <module name="NeedBraces" />
+    <module name="RightCurly" />
+
+    <!-- Checks for common coding problems -->
+    <!-- See http://checkstyle.sourceforge.net/config_coding.html -->
+    <module name="EmptyStatement" />
+    <module name="EqualsHashCode" />
+    <!-- Method parameters and local variables should not hide fields, except in constructors and setters -->
+    <module name="HiddenField">
+        <property name="ignoreConstructorParameter" value="true" />
+        <property name="ignoreSetter" value="true" />
+    </module>
     <!-- Disallow unnecessary instantiation of Boolean, String -->
     <module name="IllegalInstantiation">
       <property name="classes" value="java.lang.Boolean, java.lang.String"/>
     </module>
+    <!-- Allowed for algorithm implementations. -->
+    <!-- <module name="InnerAssignment" /> -->
+    <!-- <module name="MagicNumber" /> -->
+    <module name="MissingSwitchDefault" />
+    <module name="MultipleVariableDeclarations" />
+    <module name="SimplifyBooleanExpression" />
+    <module name="SimplifyBooleanReturn" />
+
+    <!-- Checks for class design -->
+    <!-- See http://checkstyle.sourceforge.net/config_design.html -->
+    <module name="DesignForExtension" />
+    <module name="FinalClass" />
+    <module name="HideUtilityClassConstructor" />
+    <module name="InterfaceIsType" />
+    <!-- No public fields -->
+    <module name="VisibilityModifier">
+       <property name="protectedAllowed" value="true"/>
+    </module>
 
-    <!-- Required for SuppressionCommentFilter below -->
-    <module name="FileContentsHolder"/>
+    <!-- Miscellaneous other checks. -->
+    <!-- See http://checkstyle.sourceforge.net/config_misc.html -->
+    <module name="ArrayTypeStyle" />
+    <!-- <module name="FinalParameters" />  -->
+    <module name="TodoComment">
+      <property name="severity" value="warning"/>
+    </module>
+    <module name="UpperEll" />
 
-    <!--  Import should be explicit, really needed and only from pure java packages -->
-    <module name="AvoidStarImport" />
-    <module name="UnusedImports" />
-    <module name="IllegalImport" />
+    <!-- Addition to Checkstyle sun_checks.xml  -->
 
-    <!-- Utility class should not be instantiated, they must have a private constructor -->
-    <module name="HideUtilityClassConstructor" />
+    <!-- Indentation of 4 spaces. -->
+    <module name="Indentation">
+      <!-- Indentation style recommended by Oracle -->
+      <property name="caseIndent" value="0"/>
+    </module>
 
-    <!-- Switch statements should be complete and with independent cases -->
+    <!-- Switch statements should have independent cases -->
     <module name="FallThrough" />
-    <module name="MissingSwitchDefault" />
 
     <!-- Constant names should obey the traditional all uppercase naming convention -->
     <module name="ConstantName" />
 
-    <!-- Method parameters and local variables should not hide fields, except in constructors and setters -->
-    <module name="HiddenField">
-        <property name="ignoreConstructorParameter" value="true" />
-        <property name="ignoreSetter" value="true" />
-    </module>
-
-    <!-- No trailing whitespace -->
-    <module name="Regexp">
-      <property name="format" value="[ \t]+$"/>
-      <property name="illegalPattern" value="true"/>
-      <property name="message" value="Trailing whitespace"/>
-    </module>
-
     <!-- No System.out.println() statements -->
     <module name="Regexp">
       <!-- no sysouts -->
-      <property name="format" value="System\.out\.println"/>
+      <property name="format" value="System\.(out|err)\."/>
       <property name="illegalPattern" value="true"/>
     </module>
 
@@ -104,13 +223,9 @@
     <module name="Regexp">
       <property name="format" value="@author"/>
       <property name="illegalPattern" value="true"/>
-      <property name="message" value="developers names should be in pom file"/>
+      <property name="message" value="Developers names should be in pom file"/>
     </module>
 
-    <!-- Use a consistent way to put modifiers -->
-    <module name="RedundantModifier" />
-    <module name="ModifierOrder" />
-
     <!-- Use a consistent way to put declarations -->
     <module name="DeclarationOrder" />
 
@@ -123,9 +238,6 @@
     <!-- Don't use = or != for string comparisons -->
     <module name="StringLiteralEquality" />
 
-   <!-- Don't declare multiple variables in the same statement -->
-    <module name="MultipleVariableDeclarations" />
-
     <!-- String literals more than one character long should not be repeated several times -->
     <!-- the "unchecked" string is also accepted to allow @SuppressWarnings("unchecked") -->
     <module name="MultipleStringLiterals" >
@@ -135,68 +247,17 @@
     <!-- Check if @Override tags are present  -->
     <module name="MissingOverride" />
 
-    <!-- <module name="TodoComment" /> -->
-
-  </module>
+    <!-- Setup special comments to suppress specific checks from source files -->
+    <module name="SuppressionCommentFilter">
+      <property name="offCommentFormat" value="CHECKSTYLE\: stop ([\w\|]+)"/>
+      <property name="onCommentFormat"  value="CHECKSTYLE\: resume ([\w\|]+)"/>
+      <property name="checkFormat"      value="$1"/>
+    </module>
+    <module name="SuppressionCommentFilter">
+      <property name="offCommentFormat" value="CHECKSTYLE\: stop all"/>
+      <property name="onCommentFormat"  value="CHECKSTYLE\: resume all"/>
+    </module>
 
-  <!-- Verify that EVERY source file has the appropriate license -->
-  <module name="Header">
-    <property name="headerFile" value="${checkstyle.header.file}"/>
   </module>
 
-  <!-- No tabs allowed! -->
-  <module name="FileTabCharacter"/>
-
-  <!-- Require files to end with newline characters -->
-  <module name="NewlineAtEndOfFile"/>
-
-  <!-- Require package javadoc -->
-  <module name="JavadocPackage"/>
-
-  <!-- Setup special comments to suppress specific checks from source files -->
-  <module name="SuppressionCommentFilter">
-    <property name="offCommentFormat" value="CHECKSTYLE\: stop JavadocVariable"/>
-    <property name="onCommentFormat"  value="CHECKSTYLE\: resume JavadocVariable"/>
-    <property name="checkFormat"      value="JavadocVariable"/>
-  </module>
-  <module name="SuppressionCommentFilter">
-    <property name="offCommentFormat" value="CHECKSTYLE\: stop JavadocMethodCheck"/>
-    <property name="onCommentFormat"  value="CHECKSTYLE\: resume JavadocMethodCheck"/>
-    <property name="checkFormat"      value="JavadocMethodCheck"/>
-  </module>
-  <module name="SuppressionCommentFilter">
-    <property name="offCommentFormat" value="CHECKSTYLE\: stop ConstantName"/>
-    <property name="onCommentFormat"  value="CHECKSTYLE\: resume ConstantName"/>
-    <property name="checkFormat"      value="ConstantName"/>
-  </module>
-  <module name="SuppressionCommentFilter">
-    <property name="offCommentFormat" value="CHECKSTYLE\: stop HideUtilityClassConstructor"/>
-    <property name="onCommentFormat"  value="CHECKSTYLE\: resume HideUtilityClassConstructor"/>
-    <property name="checkFormat"      value="HideUtilityClassConstructor"/>
-  </module>
-  <module name="SuppressionCommentFilter">
-    <property name="offCommentFormat" value="CHECKSTYLE\: stop MultipleVariableDeclarations"/>
-    <property name="onCommentFormat"  value="CHECKSTYLE\: resume MultipleVariableDeclarations"/>
-    <property name="checkFormat"      value="MultipleVariableDeclarations"/>
-  </module>
-  <module name="SuppressionCommentFilter">
-    <property name="offCommentFormat" value="CHECKSTYLE\: stop IllegalCatch"/>
-    <property name="onCommentFormat"  value="CHECKSTYLE\: resume IllegalCatch"/>
-    <property name="checkFormat"      value="IllegalCatch"/>
-  </module>
-  <module name="SuppressionCommentFilter">
-    <property name="offCommentFormat" value="CHECKSTYLE\: stop DeclarationOrder"/>
-    <property name="onCommentFormat"  value="CHECKSTYLE\: resume DeclarationOrder"/>
-    <property name="checkFormat"      value="DeclarationOrder"/>
-  </module>
-  <module name="SuppressionCommentFilter">
-    <property name="offCommentFormat" value="CHECKSTYLE\: stop RedundantModifier"/>
-    <property name="onCommentFormat"  value="CHECKSTYLE\: resume RedundantModifier"/>
-    <property name="checkFormat"      value="RedundantModifier"/>
-  </module>
-  <module name="SuppressionCommentFilter">
-    <property name="offCommentFormat" value="CHECKSTYLE\: stop all"/>
-    <property name="onCommentFormat" value="CHECKSTYLE\: resume all"/>
-  </module>
 </module>
-


[commons-geometry] 06/07: Merge branch 'GEOMETRY-46__steven'

Posted by er...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit a5a45163806c46e41ddc0d407c6e9436eeba7fad
Merge: 687412e a0fdcf1
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
AuthorDate: Thu Sep 26 13:09:31 2019 +0200

    Merge branch 'GEOMETRY-46__steven'
    
    Closes #39.

 .../commons/geometry/euclidean/oned/Vector1D.java  | 12 +++++++++
 .../geometry/euclidean/threed/Vector3D.java        | 12 +++++++++
 .../commons/geometry/euclidean/twod/Vector2D.java  | 12 +++++++++
 .../geometry/euclidean/oned/Vector1DTest.java      | 29 ++++++++++++++++++++
 .../geometry/euclidean/threed/Vector3DTest.java    | 29 ++++++++++++++++++++
 .../geometry/euclidean/twod/Vector2DTest.java      | 31 ++++++++++++++++++++++
 6 files changed, 125 insertions(+)