You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ah...@apache.org on 2022/06/25 10:07:12 UTC
[commons-numbers] branch master updated: Update checkstyle
This is an automated email from the ASF dual-hosted git repository.
aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-numbers.git
The following commit(s) were added to refs/heads/master by this push:
new 1497df18 Update checkstyle
1497df18 is described below
commit 1497df18dfb77f454450d71733c31a47560c6845
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Sat Jun 25 11:06:51 2022 +0100
Update checkstyle
plugin 3.1.0 -> 3.1.2
dependency 8.29 -> 8.45
Correct unnecessary parentheses in code or using suppressions
---
.../src/main/java/org/apache/commons/numbers/complex/Complex.java | 6 +++---
.../main/java/org/apache/commons/numbers/core/ArithmeticUtils.java | 6 +++---
.../src/main/java/org/apache/commons/numbers/core/Precision.java | 4 ++--
.../main/java/org/apache/commons/numbers/fraction/BigFraction.java | 4 ++--
.../src/main/java/org/apache/commons/numbers/gamma/BoostMath.java | 2 +-
.../src/main/java/org/apache/commons/numbers/gamma/BoostTools.java | 4 ++--
.../main/java/org/apache/commons/numbers/primes/SmallPrimes.java | 4 ++--
pom.xml | 4 ++--
src/main/resources/checkstyle/checkstyle-suppressions.xml | 4 ++++
9 files changed, 21 insertions(+), 17 deletions(-)
diff --git a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java b/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java
index 4f1a4be5..6dfa59e8 100644
--- a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java
+++ b/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java
@@ -1126,7 +1126,7 @@ public final class Complex implements Serializable {
// Recover infinities and zeros that computed as NaN+iNaN
// the only cases are nonzero/zero, infinite/finite, and finite/infinite, ...
if (Double.isNaN(x) && Double.isNaN(y)) {
- if ((denom == 0.0) &&
+ if (denom == 0.0 &&
(!Double.isNaN(a) || !Double.isNaN(b))) {
// nonzero/zero
// This case produces the same result as divide by a real-only zero
@@ -2869,7 +2869,7 @@ public final class Complex implements Serializable {
// if x or y are large, then the formula:
// atan2(2y, (1-x)(1+x) - y^2)
// evaluates to +(PI - theta) where theta is negligible compared to PI.
- if ((x >= SAFE_UPPER) || (y >= SAFE_UPPER)) {
+ if (x >= SAFE_UPPER || y >= SAFE_UPPER) {
im = Math.PI;
} else if (x <= SAFE_LOWER) {
// (1-x)^2 -> 1
@@ -3460,7 +3460,7 @@ public final class Complex implements Serializable {
* @return true if inside the region.
*/
private static boolean inRegion(double x, double y, double min, double max) {
- return (x < max) && (x > min) && (y < max) && (y > min);
+ return x < max && x > min && y < max && y > min;
}
/**
diff --git a/commons-numbers-core/src/main/java/org/apache/commons/numbers/core/ArithmeticUtils.java b/commons-numbers-core/src/main/java/org/apache/commons/numbers/core/ArithmeticUtils.java
index 48450acc..11c55147 100644
--- a/commons-numbers-core/src/main/java/org/apache/commons/numbers/core/ArithmeticUtils.java
+++ b/commons-numbers-core/src/main/java/org/apache/commons/numbers/core/ArithmeticUtils.java
@@ -141,8 +141,8 @@ public final class ArithmeticUtils {
public static long gcd(final long p, final long q) {
long u = p;
long v = q;
- if ((u == 0) || (v == 0)) {
- if ((u == Long.MIN_VALUE) || (v == Long.MIN_VALUE)) {
+ if (u == 0 || v == 0) {
+ if (u == Long.MIN_VALUE || v == Long.MIN_VALUE) {
throw new NumbersArithmeticException(OVERFLOW_GCD_MESSAGE_2_POWER_63,
p, q);
}
@@ -460,7 +460,7 @@ public final class ArithmeticUtils {
* @return true if the argument is a power of two
*/
public static boolean isPowerOfTwo(long n) {
- return (n > 0) && ((n & (n - 1)) == 0);
+ return n > 0 && (n & (n - 1)) == 0;
}
/**
diff --git a/commons-numbers-core/src/main/java/org/apache/commons/numbers/core/Precision.java b/commons-numbers-core/src/main/java/org/apache/commons/numbers/core/Precision.java
index 8d3f2320..a0a19ec6 100644
--- a/commons-numbers-core/src/main/java/org/apache/commons/numbers/core/Precision.java
+++ b/commons-numbers-core/src/main/java/org/apache/commons/numbers/core/Precision.java
@@ -197,7 +197,7 @@ public final class Precision {
* or both are NaN.
*/
public static boolean equalsIncludingNaN(float x, float y, float eps) {
- return equalsIncludingNaN(x, y, 1) || (Math.abs(y - x) <= eps);
+ return equalsIncludingNaN(x, y, 1) || Math.abs(y - x) <= eps;
}
/**
@@ -341,7 +341,7 @@ public final class Precision {
* or both are NaN.
*/
public static boolean equalsIncludingNaN(double x, double y, double eps) {
- return equalsIncludingNaN(x, y) || (Math.abs(y - x) <= eps);
+ return equalsIncludingNaN(x, y) || Math.abs(y - x) <= eps;
}
/**
diff --git a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/BigFraction.java b/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/BigFraction.java
index bc71783c..927b18ba 100644
--- a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/BigFraction.java
+++ b/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/BigFraction.java
@@ -1273,8 +1273,8 @@ public final class BigFraction
BigInteger result = value.shiftRight(bits);
if (value.testBit(bits - 1) &&
(hasFractionalBits ||
- (value.getLowestSetBit() < bits - 1) ||
- value.testBit(bits))) {
+ value.getLowestSetBit() < bits - 1) ||
+ value.testBit(bits)) {
result = result.add(BigInteger.ONE); //round up
}
diff --git a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/BoostMath.java b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/BoostMath.java
index 0098f52c..b5fac2cf 100644
--- a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/BoostMath.java
+++ b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/BoostMath.java
@@ -54,7 +54,7 @@ final class BoostMath {
// Assume log(x) ~ (x - 1) [true when x is close to 1]
// => |(x-1) * y| < 0.5
- if ((Math.abs(y * (x - 1)) < 0.5) || (Math.abs(y) < 0.2)) {
+ if (Math.abs(y * (x - 1)) < 0.5 || Math.abs(y) < 0.2) {
// We don't have any good/quick approximation for log(x) * y
// so just try it and see:
final double l = y * Math.log(x);
diff --git a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/BoostTools.java b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/BoostTools.java
index ef492d0f..506adc9e 100644
--- a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/BoostTools.java
+++ b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/BoostTools.java
@@ -132,7 +132,7 @@ final class BoostTools {
do {
nextTerm = func.getAsDouble();
result += nextTerm;
- } while ((Math.abs(eps * result) < Math.abs(nextTerm)) && --counter > 0);
+ } while (Math.abs(eps * result) < Math.abs(nextTerm) && --counter > 0);
if (counter <= 0) {
throw new ArithmeticException(
@@ -189,7 +189,7 @@ final class BoostTools {
carry = t - result;
carry -= y;
result = t;
- } while ((Math.abs(eps * result) < Math.abs(nextTerm)) && --counter > 0);
+ } while (Math.abs(eps * result) < Math.abs(nextTerm) && --counter > 0);
if (counter <= 0) {
throw new ArithmeticException(
diff --git a/commons-numbers-primes/src/main/java/org/apache/commons/numbers/primes/SmallPrimes.java b/commons-numbers-primes/src/main/java/org/apache/commons/numbers/primes/SmallPrimes.java
index 2d85f593..5cac3c66 100644
--- a/commons-numbers-primes/src/main/java/org/apache/commons/numbers/primes/SmallPrimes.java
+++ b/commons-numbers-primes/src/main/java/org/apache/commons/numbers/primes/SmallPrimes.java
@@ -269,9 +269,9 @@ final class SmallPrimes {
final BigInteger a = BigInteger.valueOf(SmallPrimes.PRIMES[i]);
final BigInteger bPow = a.modPow(br, bn);
int y = bPow.intValue();
- if ((1 != y) && (y != nMinus1)) {
+ if (1 != y && y != nMinus1) {
int j = 1;
- while ((j <= s - 1) && (nMinus1 != y)) {
+ while (j <= s - 1 && nMinus1 != y) {
final long square = ((long) y) * y;
y = (int) (square % n);
if (1 == y) {
diff --git a/pom.xml b/pom.xml
index 59a044e4..a6d24a17 100644
--- a/pom.xml
+++ b/pom.xml
@@ -58,8 +58,8 @@
<maven.compiler.target>1.8</maven.compiler.target>
<numbers.pmd.version>3.13.0</numbers.pmd.version>
<numbers.pmd.dep.version>6.21.0</numbers.pmd.dep.version>
- <numbers.checkstyle.version>3.1.0</numbers.checkstyle.version>
- <numbers.checkstyle.dep.version>8.29</numbers.checkstyle.dep.version>
+ <numbers.checkstyle.version>3.1.2</numbers.checkstyle.version>
+ <numbers.checkstyle.dep.version>8.45</numbers.checkstyle.dep.version>
<numbers.mathjax.version>2.7.2</numbers.mathjax.version>
<numbers.junit.bom.version>5.4.2</numbers.junit.bom.version>
<numbers.commons.math3.version>3.6.1</numbers.commons.math3.version>
diff --git a/src/main/resources/checkstyle/checkstyle-suppressions.xml b/src/main/resources/checkstyle/checkstyle-suppressions.xml
index 687f5f8f..73b2ae14 100644
--- a/src/main/resources/checkstyle/checkstyle-suppressions.xml
+++ b/src/main/resources/checkstyle/checkstyle-suppressions.xml
@@ -36,6 +36,9 @@
<suppress checks="ParameterNumber" files=".*[/\\]BoostBeta\.java" />
<!-- Method "hashCode()" is defined in the "Angle" parent class; subclasses have no additional fields to include in the hash. -->
<suppress checks="EqualsHashCode" files=".*[/\\]Angle\.java" />
+ <suppress checks="UnnecessaryParentheses" files=".*[/\\]BrentSolver\.java" />
+ <suppress checks="UnnecessaryParentheses" files=".*[/\\]gamma[/\\]BoostBeta.java" />
+ <suppress checks="UnnecessaryParentheses" files=".*[/\\]gamma[/\\]BoostGamma.java" />
<!-- Be more lenient on tests. -->
<suppress checks="Javadoc" files=".*[/\\]test[/\\].*" />
@@ -48,4 +51,5 @@
<suppress checks="MethodLength" files=".*/LinearCombination.*Test.java" />
<suppress checks="FileLengthCheck" files=".*[/\\]gamma[/\\]BoostGammaTest.java" />
<suppress checks="MethodLength" files=".*/BoostBetaTest.java" />
+ <suppress checks="UnnecessaryParentheses" files=".*[/\\]gamma[/\\]BoostGammaTest.java" />
</suppressions>