Is there a checkstyle rule that will catch something like this:
double result = someInt / someOtherInt;
result
is double (so clearly fractions are desired) yet the right-hand side would do integer division (rounding down).
Does something like this exist?
Each module has a severity property that a Checkstyle audit assigns to all violations of the check. The default severity level of a check is error . You can use the severity property to control the output of the plain formatter for the command line tool and the ANT task.
Each rule can raise notifications, warnings, and errors. For example, Checkstyle can examine the following: Multiple complexity measurements. Checkstyle is available as a JAR file which can run inside a Java VM or as an Apache Ant task.
Each check has a section called 'Violation Messages'. This section lists every key the check uses and links to the default message used by checkstyle. A Checker module has a set of Filter submodules to filter audit events, including the violation messages fired by Checks.
Overview Checkstyle is an open source tool that checks code against a configurable set of rules. In this tutorial, we're going to look at how to integrate Checkstyle into a Java project via Maven and by using IDE plugins.
No, but findbugs can:
ICAST: Integral division result cast to double or float (ICAST_IDIV_CAST_TO_DOUBLE)
This code casts the result of an integral division (e.g., int or long division) operation to double or float. Doing division on integers truncates the result to the integer value closest to zero. The fact that the result was cast to double suggests that this precision should have been retained. What was probably meant was to cast one or both of the operands to double before performing the division.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With