[build] Upgrade to PMD 7.2.0 (#6718)

This commit is contained in:
Gold856
2024-06-09 01:08:23 -04:00
committed by GitHub
parent e2dcbd016d
commit b0cc84a9c7
64 changed files with 148 additions and 183 deletions

View File

@@ -299,11 +299,9 @@ public interface Measure<U extends Unit<U>> extends Comparable<Measure<U>> {
* @return true if this measure is equivalent, false otherwise
*/
default boolean isEquivalent(Measure<?> other) {
if (!this.unit().getBaseUnit().equals(other.unit().getBaseUnit())) {
return false; // Disjoint units, not compatible
}
return Math.abs(baseUnitMagnitude() - other.baseUnitMagnitude()) <= EQUIVALENCE_THRESHOLD;
// Check for disjoint units that aren't compatible
return this.unit().getBaseUnit().equals(other.unit().getBaseUnit())
&& Math.abs(baseUnitMagnitude() - other.baseUnitMagnitude()) <= EQUIVALENCE_THRESHOLD;
}
/** {@inheritDoc} */

View File

@@ -66,9 +66,9 @@ public class Mult<A extends Unit<A>, B extends Unit<B>> extends Unit<Mult<A, B>>
* @param b the second unit
* @return the combined unit
*/
@SuppressWarnings({"unchecked", "rawtypes"})
@SuppressWarnings("unchecked")
public static <A extends Unit<A>, B extends Unit<B>> Mult<A, B> combine(A a, B b) {
final long key = ((long) a.hashCode()) << 32L | (((long) b.hashCode()) & 0xFFFFFFFFL);
final long key = ((long) a.hashCode()) << 32L | (b.hashCode() & 0xFFFFFFFFL);
if (cache.containsKey(key)) {
return cache.get(key);
}

View File

@@ -78,8 +78,7 @@ public class Per<N extends Unit<N>, D extends Unit<D>> extends Unit<Per<N, D>> {
@SuppressWarnings("unchecked")
public static <N extends Unit<N>, D extends Unit<D>> Per<N, D> combine(
N numerator, D denominator) {
final long key =
((long) numerator.hashCode()) << 32L | (((long) denominator.hashCode()) & 0xFFFFFFFFL);
final long key = ((long) numerator.hashCode()) << 32L | (denominator.hashCode() & 0xFFFFFFFFL);
var existing = cache.get(key);
if (existing != null) {

View File

@@ -286,13 +286,11 @@ public class Unit<U extends Unit<U>> {
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
return o instanceof Unit<?> that
&& m_name.equals(that.m_name)
&& m_symbol.equals(that.m_symbol)
&& this.equivalent(that);
return this == o
|| o instanceof Unit<?> that
&& m_name.equals(that.m_name)
&& m_symbol.equals(that.m_symbol)
&& this.equivalent(that);
}
@Override

View File

@@ -69,7 +69,7 @@ public final class UnitBuilder<U extends Unit<U>> {
}
/** Helper class used for safely chaining mapping builder calls. */
public class MappingBuilder {
public final class MappingBuilder {
private final double m_minInput;
private final double m_maxInput;
@@ -271,7 +271,7 @@ public final class UnitBuilder<U extends Unit<U>> {
});
}
@SuppressWarnings("unchecked")
@SuppressWarnings({"unchecked", "PMD.AvoidAccessibilityAlteration"})
private static <U extends Unit<U>> Constructor<? extends Unit<U>> getConstructor(U baseUnit)
throws NoSuchMethodException {
var baseClass = baseUnit.getClass();

View File

@@ -419,7 +419,7 @@ public final class Units {
* @param symbol the symbol of the new derived unit
* @return the milli-unit
*/
@SuppressWarnings({"PMD.MethodName", "checkstyle:methodname"})
@SuppressWarnings("checkstyle:methodname")
public static <U extends Unit<U>> U Milli(Unit<U> baseUnit, String name, String symbol) {
return derive(baseUnit).splitInto(1000).named(name).symbol(symbol).make();
}
@@ -431,7 +431,7 @@ public final class Units {
* @param baseUnit the unit being derived from. This does not have to be the base unit of measure
* @return the milli-unit
*/
@SuppressWarnings({"PMD.MethodName", "checkstyle:methodname"})
@SuppressWarnings("checkstyle:methodname")
public static <U extends Unit<U>> U Milli(Unit<U> baseUnit) {
return Milli(
baseUnit, "Milli" + baseUnit.name().toLowerCase(Locale.ROOT), "m" + baseUnit.symbol());
@@ -447,7 +447,7 @@ public final class Units {
* @param symbol the symbol of the new derived unit
* @return the micro-unit
*/
@SuppressWarnings({"PMD.MethodName", "checkstyle:methodname"})
@SuppressWarnings("checkstyle:methodname")
public static <U extends Unit<U>> U Micro(Unit<U> baseUnit, String name, String symbol) {
return derive(baseUnit).splitInto(1_000_000).named(name).symbol(symbol).make();
}
@@ -459,7 +459,7 @@ public final class Units {
* @param baseUnit the unit being derived from. This does not have to be the base unit of measure
* @return the micro-unit
*/
@SuppressWarnings({"PMD.MethodName", "checkstyle:methodname"})
@SuppressWarnings("checkstyle:methodname")
public static <U extends Unit<U>> U Micro(Unit<U> baseUnit) {
return Micro(
baseUnit, "Micro" + baseUnit.name().toLowerCase(Locale.ROOT), "u" + baseUnit.symbol());
@@ -474,7 +474,7 @@ public final class Units {
* @param symbol the symbol of the new derived unit
* @return the kilo-unit
*/
@SuppressWarnings({"PMD.MethodName", "checkstyle:methodname"})
@SuppressWarnings("checkstyle:methodname")
public static <U extends Unit<U>> U Kilo(Unit<U> baseUnit, String name, String symbol) {
return derive(baseUnit).aggregate(1000).named(name).symbol(symbol).make();
}
@@ -486,7 +486,7 @@ public final class Units {
* @param baseUnit the unit being derived from. This does not have to be the base unit of measure
* @return the kilo-unit
*/
@SuppressWarnings({"PMD.MethodName", "checkstyle:methodname"})
@SuppressWarnings("checkstyle:methodname")
public static <U extends Unit<U>> U Kilo(Unit<U> baseUnit) {
return Kilo(
baseUnit, "Kilo" + baseUnit.name().toLowerCase(Locale.ROOT), "K" + baseUnit.symbol());

View File

@@ -33,7 +33,7 @@ public class Velocity<D extends Unit<D>> extends Unit<Velocity<D>> {
/** Generates a cache key used for cache lookups. */
private static long cacheKey(Unit<?> numerator, Unit<?> denominator) {
return ((long) numerator.hashCode()) << 32L | (((long) denominator.hashCode()) & 0xFFFFFFFFL);
return ((long) numerator.hashCode()) << 32L | (denominator.hashCode() & 0xFFFFFFFFL);
}
/**