Better way to deal with ignored exceptions and PMD checks.
Gets rid of output like: <suppressedviolation filename="...\src\main\java\org\apache\commons\lang3\reflect\MemberUtils.java" suppressiontype="nopmd" msg="Avoid empty catch blocks" usermsg=" "></suppressedviolation>
This commit is contained in:
parent
c55962646a
commit
bdde0e1c13
|
@ -567,7 +567,7 @@ public class ClassUtils {
|
||||||
try {
|
try {
|
||||||
return getClass(classLoader, className.substring(0, lastDotIndex) + INNER_CLASS_SEPARATOR_CHAR + className.substring(lastDotIndex + 1),
|
return getClass(classLoader, className.substring(0, lastDotIndex) + INNER_CLASS_SEPARATOR_CHAR + className.substring(lastDotIndex + 1),
|
||||||
initialize);
|
initialize);
|
||||||
} catch (final ClassNotFoundException ex2) { // NOPMD
|
} catch (final ClassNotFoundException ignored) {
|
||||||
// ignore exception
|
// ignore exception
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -743,7 +743,7 @@ public class NumberUtils {
|
||||||
&& (!numeric.isEmpty() && numeric.charAt(0) == '-' && isDigits(numeric.substring(1)) || isDigits(numeric))) {
|
&& (!numeric.isEmpty() && numeric.charAt(0) == '-' && isDigits(numeric.substring(1)) || isDigits(numeric))) {
|
||||||
try {
|
try {
|
||||||
return createLong(numeric);
|
return createLong(numeric);
|
||||||
} catch (final NumberFormatException nfe) { // NOPMD
|
} catch (final NumberFormatException ignored) {
|
||||||
// Too big for a long
|
// Too big for a long
|
||||||
}
|
}
|
||||||
return createBigInteger(numeric);
|
return createBigInteger(numeric);
|
||||||
|
@ -760,7 +760,7 @@ public class NumberUtils {
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (final NumberFormatException nfe) { // NOPMD
|
} catch (final NumberFormatException ignored) {
|
||||||
// ignore the bad number
|
// ignore the bad number
|
||||||
}
|
}
|
||||||
//$FALL-THROUGH$
|
//$FALL-THROUGH$
|
||||||
|
@ -771,12 +771,12 @@ public class NumberUtils {
|
||||||
if (!(d.isInfinite() || d.doubleValue() == 0.0D && !isZero(mant, dec))) {
|
if (!(d.isInfinite() || d.doubleValue() == 0.0D && !isZero(mant, dec))) {
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
} catch (final NumberFormatException nfe) { // NOPMD
|
} catch (final NumberFormatException ignored) {
|
||||||
// ignore the bad number
|
// ignore the bad number
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return createBigDecimal(numeric);
|
return createBigDecimal(numeric);
|
||||||
} catch (final NumberFormatException e) { // NOPMD
|
} catch (final NumberFormatException ignored) {
|
||||||
// ignore the bad number
|
// ignore the bad number
|
||||||
}
|
}
|
||||||
//$FALL-THROUGH$
|
//$FALL-THROUGH$
|
||||||
|
@ -796,12 +796,12 @@ public class NumberUtils {
|
||||||
//Must be an Integer, Long, Biginteger
|
//Must be an Integer, Long, Biginteger
|
||||||
try {
|
try {
|
||||||
return createInteger(str);
|
return createInteger(str);
|
||||||
} catch (final NumberFormatException nfe) { // NOPMD
|
} catch (final NumberFormatException ignored) {
|
||||||
// ignore the bad number
|
// ignore the bad number
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return createLong(str);
|
return createLong(str);
|
||||||
} catch (final NumberFormatException nfe) { // NOPMD
|
} catch (final NumberFormatException ignored) {
|
||||||
// ignore the bad number
|
// ignore the bad number
|
||||||
}
|
}
|
||||||
return createBigInteger(str);
|
return createBigInteger(str);
|
||||||
|
@ -823,7 +823,7 @@ public class NumberUtils {
|
||||||
}
|
}
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
} catch (final NumberFormatException nfe) { // NOPMD
|
} catch (final NumberFormatException ignored) {
|
||||||
// ignore the bad number
|
// ignore the bad number
|
||||||
}
|
}
|
||||||
return createBigDecimal(str);
|
return createBigDecimal(str);
|
||||||
|
|
|
@ -244,7 +244,8 @@ public class ConstructorUtils {
|
||||||
// most of the time this works and it's much faster
|
// most of the time this works and it's much faster
|
||||||
try {
|
try {
|
||||||
return MemberUtils.setAccessibleWorkaround(cls.getConstructor(parameterTypes));
|
return MemberUtils.setAccessibleWorkaround(cls.getConstructor(parameterTypes));
|
||||||
} catch (final NoSuchMethodException e) { // NOPMD - Swallow
|
} catch (final NoSuchMethodException ignored) {
|
||||||
|
// ignore
|
||||||
}
|
}
|
||||||
Constructor<T> result = null;
|
Constructor<T> result = null;
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -112,7 +112,7 @@ public class FieldUtils {
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
}
|
}
|
||||||
return field;
|
return field;
|
||||||
} catch (final NoSuchFieldException ex) { // NOPMD
|
} catch (final NoSuchFieldException ignored) {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ public class FieldUtils {
|
||||||
Validate.isTrue(match == null, "Reference to field %s is ambiguous relative to %s"
|
Validate.isTrue(match == null, "Reference to field %s is ambiguous relative to %s"
|
||||||
+ "; a matching field exists on two or more implemented interfaces.", fieldName, cls);
|
+ "; a matching field exists on two or more implemented interfaces.", fieldName, cls);
|
||||||
match = test;
|
match = test;
|
||||||
} catch (final NoSuchFieldException ex) { // NOPMD
|
} catch (final NoSuchFieldException ignored) {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -177,7 +177,7 @@ public class FieldUtils {
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
}
|
}
|
||||||
return field;
|
return field;
|
||||||
} catch (final NoSuchFieldException e) { // NOPMD
|
} catch (final NoSuchFieldException ignored) {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -61,7 +61,7 @@ final class MemberUtils {
|
||||||
try {
|
try {
|
||||||
obj.setAccessible(true);
|
obj.setAccessible(true);
|
||||||
return obj;
|
return obj;
|
||||||
} catch (final SecurityException e) { // NOPMD
|
} catch (final SecurityException ignored) {
|
||||||
// ignore in favor of subsequent IllegalAccessException
|
// ignore in favor of subsequent IllegalAccessException
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -625,7 +625,7 @@ public class MethodUtils {
|
||||||
try {
|
try {
|
||||||
return anInterface.getDeclaredMethod(methodName,
|
return anInterface.getDeclaredMethod(methodName,
|
||||||
parameterTypes);
|
parameterTypes);
|
||||||
} catch (final NoSuchMethodException e) { // NOPMD
|
} catch (final NoSuchMethodException ignored) {
|
||||||
/*
|
/*
|
||||||
* Swallow, if no method is found after the loop then this
|
* Swallow, if no method is found after the loop then this
|
||||||
* method returns null.
|
* method returns null.
|
||||||
|
@ -668,7 +668,8 @@ public class MethodUtils {
|
||||||
final String methodName, final Class<?>... parameterTypes) {
|
final String methodName, final Class<?>... parameterTypes) {
|
||||||
try {
|
try {
|
||||||
return MemberUtils.setAccessibleWorkaround(cls.getMethod(methodName, parameterTypes));
|
return MemberUtils.setAccessibleWorkaround(cls.getMethod(methodName, parameterTypes));
|
||||||
} catch (final NoSuchMethodException e) { // NOPMD - Swallow the exception
|
} catch (final NoSuchMethodException ignored) {
|
||||||
|
// Swallow the exception
|
||||||
}
|
}
|
||||||
// search through all methods
|
// search through all methods
|
||||||
final Method[] methods = cls.getMethods();
|
final Method[] methods = cls.getMethods();
|
||||||
|
|
|
@ -350,7 +350,7 @@ public class ExtendedMessageFormat extends MessageFormat {
|
||||||
if ((c == START_FMT || c == END_FE) && result.length() > 0) {
|
if ((c == START_FMT || c == END_FE) && result.length() > 0) {
|
||||||
try {
|
try {
|
||||||
return Integer.parseInt(result.toString());
|
return Integer.parseInt(result.toString());
|
||||||
} catch (final NumberFormatException e) { // NOPMD
|
} catch (final NumberFormatException ignored) {
|
||||||
// we've already ensured only digits, so unless something
|
// we've already ensured only digits, so unless something
|
||||||
// outlandishly large was specified we should be okay.
|
// outlandishly large was specified we should be okay.
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue