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 {
|
||||
return getClass(classLoader, className.substring(0, lastDotIndex) + INNER_CLASS_SEPARATOR_CHAR + className.substring(lastDotIndex + 1),
|
||||
initialize);
|
||||
} catch (final ClassNotFoundException ex2) { // NOPMD
|
||||
} catch (final ClassNotFoundException ignored) {
|
||||
// ignore exception
|
||||
}
|
||||
}
|
||||
|
|
|
@ -743,7 +743,7 @@ public class NumberUtils {
|
|||
&& (!numeric.isEmpty() && numeric.charAt(0) == '-' && isDigits(numeric.substring(1)) || isDigits(numeric))) {
|
||||
try {
|
||||
return createLong(numeric);
|
||||
} catch (final NumberFormatException nfe) { // NOPMD
|
||||
} catch (final NumberFormatException ignored) {
|
||||
// Too big for a long
|
||||
}
|
||||
return createBigInteger(numeric);
|
||||
|
@ -760,7 +760,7 @@ public class NumberUtils {
|
|||
return f;
|
||||
}
|
||||
|
||||
} catch (final NumberFormatException nfe) { // NOPMD
|
||||
} catch (final NumberFormatException ignored) {
|
||||
// ignore the bad number
|
||||
}
|
||||
//$FALL-THROUGH$
|
||||
|
@ -771,12 +771,12 @@ public class NumberUtils {
|
|||
if (!(d.isInfinite() || d.doubleValue() == 0.0D && !isZero(mant, dec))) {
|
||||
return d;
|
||||
}
|
||||
} catch (final NumberFormatException nfe) { // NOPMD
|
||||
} catch (final NumberFormatException ignored) {
|
||||
// ignore the bad number
|
||||
}
|
||||
try {
|
||||
return createBigDecimal(numeric);
|
||||
} catch (final NumberFormatException e) { // NOPMD
|
||||
} catch (final NumberFormatException ignored) {
|
||||
// ignore the bad number
|
||||
}
|
||||
//$FALL-THROUGH$
|
||||
|
@ -796,12 +796,12 @@ public class NumberUtils {
|
|||
//Must be an Integer, Long, Biginteger
|
||||
try {
|
||||
return createInteger(str);
|
||||
} catch (final NumberFormatException nfe) { // NOPMD
|
||||
} catch (final NumberFormatException ignored) {
|
||||
// ignore the bad number
|
||||
}
|
||||
try {
|
||||
return createLong(str);
|
||||
} catch (final NumberFormatException nfe) { // NOPMD
|
||||
} catch (final NumberFormatException ignored) {
|
||||
// ignore the bad number
|
||||
}
|
||||
return createBigInteger(str);
|
||||
|
@ -823,7 +823,7 @@ public class NumberUtils {
|
|||
}
|
||||
return b;
|
||||
}
|
||||
} catch (final NumberFormatException nfe) { // NOPMD
|
||||
} catch (final NumberFormatException ignored) {
|
||||
// ignore the bad number
|
||||
}
|
||||
return createBigDecimal(str);
|
||||
|
|
|
@ -244,7 +244,8 @@ public class ConstructorUtils {
|
|||
// most of the time this works and it's much faster
|
||||
try {
|
||||
return MemberUtils.setAccessibleWorkaround(cls.getConstructor(parameterTypes));
|
||||
} catch (final NoSuchMethodException e) { // NOPMD - Swallow
|
||||
} catch (final NoSuchMethodException ignored) {
|
||||
// ignore
|
||||
}
|
||||
Constructor<T> result = null;
|
||||
/*
|
||||
|
|
|
@ -112,7 +112,7 @@ public class FieldUtils {
|
|||
field.setAccessible(true);
|
||||
}
|
||||
return field;
|
||||
} catch (final NoSuchFieldException ex) { // NOPMD
|
||||
} catch (final NoSuchFieldException ignored) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ public class FieldUtils {
|
|||
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);
|
||||
match = test;
|
||||
} catch (final NoSuchFieldException ex) { // NOPMD
|
||||
} catch (final NoSuchFieldException ignored) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ public class FieldUtils {
|
|||
field.setAccessible(true);
|
||||
}
|
||||
return field;
|
||||
} catch (final NoSuchFieldException e) { // NOPMD
|
||||
} catch (final NoSuchFieldException ignored) {
|
||||
// ignore
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -61,7 +61,7 @@ final class MemberUtils {
|
|||
try {
|
||||
obj.setAccessible(true);
|
||||
return obj;
|
||||
} catch (final SecurityException e) { // NOPMD
|
||||
} catch (final SecurityException ignored) {
|
||||
// ignore in favor of subsequent IllegalAccessException
|
||||
}
|
||||
}
|
||||
|
|
|
@ -625,7 +625,7 @@ public class MethodUtils {
|
|||
try {
|
||||
return anInterface.getDeclaredMethod(methodName,
|
||||
parameterTypes);
|
||||
} catch (final NoSuchMethodException e) { // NOPMD
|
||||
} catch (final NoSuchMethodException ignored) {
|
||||
/*
|
||||
* Swallow, if no method is found after the loop then this
|
||||
* method returns null.
|
||||
|
@ -668,7 +668,8 @@ public class MethodUtils {
|
|||
final String methodName, final Class<?>... parameterTypes) {
|
||||
try {
|
||||
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
|
||||
final Method[] methods = cls.getMethods();
|
||||
|
|
|
@ -350,7 +350,7 @@ public class ExtendedMessageFormat extends MessageFormat {
|
|||
if ((c == START_FMT || c == END_FE) && result.length() > 0) {
|
||||
try {
|
||||
return Integer.parseInt(result.toString());
|
||||
} catch (final NumberFormatException e) { // NOPMD
|
||||
} catch (final NumberFormatException ignored) {
|
||||
// we've already ensured only digits, so unless something
|
||||
// outlandishly large was specified we should be okay.
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue