From: Fabrice Bellingard This code contains a sequence of calls to a concurrent abstraction (such as a concurrent hash map). These calls will not be executed atomically. A boxed value is unboxed and then immediately reboxed. In some situation, this compareTo or compare method returns the constant Integer.MIN_VALUE,
+which is an exceptionally bad practice. The only thing that matters about the return value of
+compareTo is the sign of the result. But people will sometimes negate the return value of compareTo,
+expecting that this will negate the sign of the result. And it will, except in the case where
+the value returned is Integer.MIN_VALUE. So just return -1 rather than Integer.MIN_VALUE. This instruction assigns a value to a local variable, but the value is not read or used in
+any subsequent instruction. Often, this indicates an error, because the value computed is never
+used. There is a field with the same name as the local variable. Did you mean to assign to that
+variable instead? The arguments to this method call seem to be in the wrong order. For example, a call
+ This code creates a BigDecimal from a double value that doesn't translate well to a decimal number. For example,
+one might assume that writing This partical method invocation doesn't make sense, for reasons that should be apparent from inspection. The entrySet() method is allowed to return a view of the underlying Map in which a single Entry
+ object is reused and returned during the iteration. As of Java 1.6, both IdentityHashMap and EnumMap
+ did so. When iterating through such a Map, the Entry value is only valid until you advance to the
+ next iteration. If, for example, you try to pass such an entrySet to an addAll method, things will
+ go badly wrong. Found a call to a method which will perform a byte to String (or String to byte) conversion,
+and will assume that the default platform encoding is suitable. This will cause the application
+behaviour to vary between platforms. Use an alternative API and specify a charset name or
+Charset object explicitly. This code converts a 32-bit int value to a 64-bit long value, and then passes that value for a
+method parameter that requires an absolute time value. An absolute time value is the number of
+milliseconds since the standard base time known as "the epoch", namely January 1, 1970, 00:00:00 GMT.
+For example, the following method, intended to convert seconds since the epoc into a Date, is badly broken:
+Preconditions.checkNotNull("message", message)
has reserved arguments: the value
+to be checked is the first argument.new BigDecimal(0.1)
in Java creates a BigDecimal which is exactly equal to 0.1
+(an unscaled value of 1, with a scale of 1), but it is actually equal to 0.1000000000000000055511151231257827021181583404541015625.
+You probably want to use the BigDecimal.valueOf(double d)
method, which uses the String representation of the double to
+create the BigDecimal (e.g., BigDecimal.valueOf(0.1)
gives 0.1).
+Date getDate(int seconds) { return new Date(seconds * 1000); }
+
+
The multiplication is done using 32-bit arithmetic, and then converted to a 64-bit value. When a 32-bit +value is converted to 64-bits and used to express an absolute time value, only dates in December 1969 and +January 1970 can be represented.
+Correct implementations for the above method are: +
+// Fails for dates after 2037 +Date getDate(int seconds) { return new Date(seconds * 1000L); } + +// better, works for all dates +Date getDate(long seconds) { return new Date(seconds * 1000); } ++ \ No newline at end of file diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/findbugs/rules/findbugs/INT_BAD_COMPARISON_WITH_INT_VALUE.html b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/findbugs/rules/findbugs/INT_BAD_COMPARISON_WITH_INT_VALUE.html new file mode 100644 index 00000000000..fc96ac19118 --- /dev/null +++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/findbugs/rules/findbugs/INT_BAD_COMPARISON_WITH_INT_VALUE.html @@ -0,0 +1,2 @@ +
This code compares an int value with a long constant that is outside the range of values that can + be represented as an int value. This comparison is vacuous and possibily to be incorrect.
\ No newline at end of file diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/findbugs/rules/findbugs/JML_JSR166_CALLING_WAIT_RATHER_THAN_AWAIT.html b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/findbugs/rules/findbugs/JML_JSR166_CALLING_WAIT_RATHER_THAN_AWAIT.html new file mode 100644 index 00000000000..f4e02a85d54 --- /dev/null +++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/findbugs/rules/findbugs/JML_JSR166_CALLING_WAIT_RATHER_THAN_AWAIT.html @@ -0,0 +1,4 @@ +This method calls wait()
, notify()
or notifyAll()
on an object that also
+provides an await()
, signal()
, signalAll()
method (such as util.concurrent
+Condition objects). This probably isn't what you want, and even if you do want it, you should consider changing your
+design, as other developers will find it exceptionally confusing.
The program is dereferencing a public or protected field that does not seem to ever have a non-null + value written to it. Unless the field is initialized via some mechanism not seen by the analysis, + dereferencing this value will generate a null pointer exception.
\ No newline at end of file diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/findbugs/rules/findbugs/OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE.html b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/findbugs/rules/findbugs/OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE.html new file mode 100644 index 00000000000..2b410336e5d --- /dev/null +++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/findbugs/rules/findbugs/OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE.html @@ -0,0 +1,6 @@ +This method may fail to clean up (close, dispose of) a stream, database object, or other resource requiring an
+explicit cleanup operation.
In general, if a method opens a stream or other resource, the method should use a try/finally block to ensure
+that the stream or resource is cleaned up before the method returns.
This bug pattern is essentially the same as the OS_OPEN_STREAM and ODR_OPEN_DATABASE_RESOURCE bug patterns, but is based on a different +(and hopefully better) static analysis technique. See Weimer and Necula, Finding and Preventing Run-Time Error Handling Mistakes, for a +description of the analysis technique. .
\ No newline at end of file diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/findbugs/rules/findbugs/PZ_DONT_REUSE_ENTRY_OBJECTS_IN_ITERATORS.html b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/findbugs/rules/findbugs/PZ_DONT_REUSE_ENTRY_OBJECTS_IN_ITERATORS.html new file mode 100644 index 00000000000..353b2d70334 --- /dev/null +++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/findbugs/rules/findbugs/PZ_DONT_REUSE_ENTRY_OBJECTS_IN_ITERATORS.html @@ -0,0 +1,4 @@ +The entrySet() method is allowed to return a view of the underlying Map in which an Iterator
+and Map.Entry
. This clever idea was used in several Map implementations, but introduces the possibility of
+ nasty coding mistakes. If a map m returns such an iterator for an entrySet, then c.addAll(m.entrySet())
will
+ go badly wrong. All of the Map implementations in OpenJDK 1.7 have been rewritten to avoid this, you should to.
This code invoked a compareTo or compare method, and checks to see if the return value is a specific +value, such as 1 or -1. When invoking these methods, you should only check the sign of the result, not +for any specific non-zero value. While many or most compareTo and compare methods only return -1, 0 or 1, +some of them will return other values.
\ No newline at end of file diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/findbugs/rules/findbugs/RV_NEGATING_RESULT_OF_COMPARETO.html b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/findbugs/rules/findbugs/RV_NEGATING_RESULT_OF_COMPARETO.html new file mode 100644 index 00000000000..96e92b5e4e6 --- /dev/null +++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/findbugs/rules/findbugs/RV_NEGATING_RESULT_OF_COMPARETO.html @@ -0,0 +1,4 @@ +This code negatives the return value of a compareTo or compare method. This is a questionable or bad +programming practice, since if the return value is Integer.MIN_VALUE, negating the return value won't +negate the sign of the result. You can achieve the same intended result by reversing the order of the +operands rather than by negating the results.
\ No newline at end of file diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/findbugs/rules/findbugs/RV_RETURN_VALUE_IGNORED_INFERRED.html b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/findbugs/rules/findbugs/RV_RETURN_VALUE_IGNORED_INFERRED.html new file mode 100644 index 00000000000..c50a2185d2f --- /dev/null +++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/findbugs/rules/findbugs/RV_RETURN_VALUE_IGNORED_INFERRED.html @@ -0,0 +1,8 @@ +This code calls a method and ignores the return value. The return value is the same type as the type the
+method is invoked on, and from our analysis it looks like the return value might be important (e.g., like
+ignoring the return value of String.toLowerCase()
).
+
We are guessing that ignoring the return value might be a bad idea just from a simple analysis of the
+body of the method. You can use a @CheckReturnValue
annotation to instruct FindBugs as to whether
+ignoring the return value of this method is important or acceptable.
+
Please investigate this closely to decide whether it is OK to ignore the return value.
\ No newline at end of file diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/findbugs/rules/findbugs/SA_LOCAL_SELF_ASSIGNMENT_INSTEAD_OF_FIELD.html b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/findbugs/rules/findbugs/SA_LOCAL_SELF_ASSIGNMENT_INSTEAD_OF_FIELD.html new file mode 100644 index 00000000000..0b150015a7a --- /dev/null +++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/findbugs/rules/findbugs/SA_LOCAL_SELF_ASSIGNMENT_INSTEAD_OF_FIELD.html @@ -0,0 +1,9 @@ +This method contains a self assignment of a local variable, and there is a field with an identical name. +Assignment appears to have been ; e.g. +
+ int foo; + public void setFoo(int foo) { + foo = foo; + } ++The assignment is useless. Did you mean to assign to the field instead? \ No newline at end of file diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/findbugs/rules/findbugs/URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD.html b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/findbugs/rules/findbugs/URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD.html new file mode 100644 index 00000000000..9626b396733 --- /dev/null +++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/findbugs/rules/findbugs/URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD.html @@ -0,0 +1,2 @@ +
This field is never read. The field is public or protected, so perhaps it is intended to be +used with classes not seen as part of the analysis. If not, consider removing it from the class.
\ No newline at end of file diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/findbugs/rules/findbugs/UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD.html b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/findbugs/rules/findbugs/UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD.html new file mode 100644 index 00000000000..5132a784703 --- /dev/null +++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/findbugs/rules/findbugs/UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD.html @@ -0,0 +1,2 @@ +This field is never used. The field is public or protected, so perhaps it is intended to be used +with classes not seen as part of the analysis. If not, consider removing it from the class.
\ No newline at end of file diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/findbugs/rules/findbugs/UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD.html b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/findbugs/rules/findbugs/UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD.html new file mode 100644 index 00000000000..287196216ba --- /dev/null +++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/findbugs/rules/findbugs/UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD.html @@ -0,0 +1,2 @@ +No writes were seen to this public/protected field. All reads of it will return the default value. +Check for errors (should it have been initialized?), or remove it if it is useless.
\ No newline at end of file diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/findbugs/rules/findbugs/VA_FORMAT_STRING_USES_NEWLINE.html b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/findbugs/rules/findbugs/VA_FORMAT_STRING_USES_NEWLINE.html new file mode 100644 index 00000000000..eba4c7386a5 --- /dev/null +++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/findbugs/rules/findbugs/VA_FORMAT_STRING_USES_NEWLINE.html @@ -0,0 +1,2 @@ +This format string include a newline character (\n). In format strings, it is generally preferable +better to use %n, which will produce the platform-specific line separator.
\ No newline at end of file diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/findbugs/rules/findbugs/VO_VOLATILE_INCREMENT.html b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/findbugs/rules/findbugs/VO_VOLATILE_INCREMENT.html new file mode 100644 index 00000000000..ebf2745165b --- /dev/null +++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/findbugs/rules/findbugs/VO_VOLATILE_INCREMENT.html @@ -0,0 +1,2 @@ +This code increments a volatile field. Increments of volatile fields aren't atomic. If more +than one thread is incrementing the field at the same time, increments could be lost.
\ No newline at end of file