rspec/rules/S2201/java/comments-and-links.adoc

28 lines
803 B
Plaintext

=== on 12 Aug 2019, 23:58:32 Andreas Knees wrote:
I suggest an Exception for this rule.
I use this code to determine whether a number has the desired number of fraction digits:
----
BigDecimal bd = new BigDecimal("12.00");
try {
bd.setScale(allowedFractionDigits);
} catch (final ArithmeticException ex) {
// thrown if the specified scaling operation would require
// rounding.
if (allowedFractionDigits == 0) {
putError("validation.number.integer");
} else {
putError("validation.number.fractionDigits", allowedFractionDigits);
}
}
----
So in my opinion ``++BigDecimal.setScale(int)++`` should be excluded from this rule, because I don't use and don't need the return value in this case.
include::../comments-and-links.adoc[]