Quality profiles / java / Sonar way with Findbugs
525 results
Active/Severity | Name [expand/collapse] |
---|---|
Active/Severity | Name [expand/collapse] | ||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
The software uses an HTTP request parameter to construct a pathname that should be within a restricted directory, but it does not properly neutralize absolute path sequences such as "/abs/path" that can resolve to a location that is outside of that directory. See http://cwe.mitre.org/data/definitions/36.html for more information. FindBugs looks only for the most blatant, obvious cases of absolute path traversal. If FindBugs found any, you almost certainly have more vulnerabilities that FindBugs doesn't report. If you are concerned about absolute path traversal, you should seriously consider using a commercial static analysis or pen-testing tool.
findbugs:PT_ABSOLUTE_PATH_TRAVERSAL
|
|||||||||||||||||||||||||||||||||||||||||||||||||
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.
findbugs:DMI_ENTRY_SETS_MAY_REUSE_ENTRY_OBJECTS
|
|||||||||||||||||||||||||||||||||||||||||||||||||
Here are the main reasons why commented code is a code smell :
squid:CommentedOutCodeLine
|
|||||||||||||||||||||||||||||||||||||||||||||||||
When several packages are involved in a cycle (package A > package B > package C > package A where ">" means "depends upon"), that means that those packages are highly coupled and that there is no way to reuse/extract one of those packages without importing all the other packages. Such cycle could quickly increase the effort required to maintain an application and to embrace business change. Sonar not only detect cycles between packages but also determines what is the minimum effort to break those cycles. This rule log a violation on each source file having an outgoing dependency to be but in order to break a cycle.
squid:CycleBetweenPackages
|
|||||||||||||||||||||||||||||||||||||||||||||||||
One might assume that new BigDecimal(.1) is exactly equal to .1, but it is actually equal to .1000000000000000055511151231257827021181583404541015625. This is so because .1 cannot be represented exactly as a double (or, for that matter, as a binary fraction of any finite length). Thus, the long value that is being passed in to the constructor is not exactly equal to .1, appearances notwithstanding. The (String) constructor, on the other hand, is perfectly predictable: 'new BigDecimal(.1)' is exactly equal to .1, as one would expect. Therefore, it is generally recommended that the (String) constructor be used in preference to this one.
pmd:AvoidDecimalLiteralsInBigDecimalConstructor
|
|||||||||||||||||||||||||||||||||||||||||||||||||
Code containing duplicate String literals can usually be improved by declaring the String as a constant field. Example : public class Foo { private void bar() { buz("Howdy"); buz("Howdy"); buz("Howdy"); buz("Howdy"); } private void buz(String x) {} }
pmd:AvoidDuplicateLiterals
|
|||||||||||||||||||||||||||||||||||||||||||||||||
(From JDC Tech Tip): The Swing methods show(), setVisible(), and pack() will create the associated peer for the frame. With the creation of the peer, the system creates the event dispatch thread. This makes things problematic because the event dispatch thread could be notifying listeners while pack and validate are still processing. This situation could result in two threads going through the Swing component-based GUI -- it's a serious flaw that could result in deadlocks or other related threading issues. A pack call causes components to be realized. As they are being realized (that is, not necessarily visible), they could trigger listener notification on the event dispatch thread.
findbugs:SW_SWING_METHODS_INVOKED_IN_SWING_THREAD
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This method compares an expression such as ((event.detail & SWT.SELECTED) > 0). Using bit arithmetic and then comparing with the greater than operator can lead to unexpected results (of course depending on the value of SWT.SELECTED). If SWT.SELECTED is a negative number, this is a candidate for a bug. Even when SWT.SELECTED is not negative, it seems good practice to use '!= 0' instead of '> 0'. Boris Bokowski
findbugs:BIT_SIGNED_CHECK
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This class defines a From the JavaDoc for the compareTo method in the Comparable interface:
It is strongly recommended, but not strictly required that
findbugs:EQ_COMPARETO_USE_OBJECT_EQUALS
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This class overrides If you don't think instances of this class will ever be inserted into a HashMap/HashTable,
the recommended public int hashCode() { assert false : "hashCode not designed"; return 42; // any arbitrary constant will do }
findbugs:HE_EQUALS_USE_HASHCODE
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This class defines a If you don't think instances of this class will ever be inserted into a HashMap/HashTable,
the recommended public int hashCode() { assert false : "hashCode not designed"; return 42; // any arbitrary constant will do }
findbugs:HE_HASHCODE_USE_OBJECT_EQUALS
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This class inherits If you don't want to define a hashCode method, and/or don't
believe the object will ever be put into a HashMap/Hashtable,
define the
findbugs:HE_INHERITS_EQUALS_USE_HASHCODE
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This class implements the
findbugs:SE_NO_SUITABLE_CONSTRUCTOR_FOR_EXTERNALIZATION
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This class implements the
findbugs:SE_NO_SUITABLE_CONSTRUCTOR
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This class implements the
findbugs:SE_NO_SERIALVERSIONID
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This class/interface has a simple name that is identical to that of an implemented/extended interface, except
that the interface is in a different package (e.g.,
findbugs:NM_SAME_SIMPLE_NAME_AS_INTERFACE
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This class has a simple name that is identical to that of its superclass, except
that its superclass is in a different package (e.g.,
findbugs:NM_SAME_SIMPLE_NAME_AS_SUPERCLASS
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This code creates a classloader, which requires a security manager. If this code will be granted security permissions, but might be invoked by code that does not have security permissions, then the classloader creation needs to occur inside a doPrivileged block.
findbugs:DP_CREATE_CLASSLOADER_INSIDE_DO_PRIVILEGED
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This non-final class defines a clone() method that does not call super.clone(). If this class ("A") is extended by a subclass ("B"), and the subclass B calls super.clone(), then it is likely that B's clone() method will return an object of type A, which violates the standard contract for clone(). If all clone() methods call super.clone(), then they are guaranteed to use Object.clone(), which always returns an object of the correct type.
findbugs:CN_IDIOM_NO_SUPER_CALL
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This class implements the
findbugs:SE_COMPARATOR_SHOULD_BE_SERIALIZABLE
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This code compares
findbugs:ES_COMPARING_STRINGS_WITH_EQ
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This code compares a
findbugs:ES_COMPARING_PARAMETER_STRING_WITH_EQ
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This equals method is checking to see if the argument is some incompatible type (i.e., a class that is neither a supertype nor subtype of the class that defines the equals method). For example, the Foo class might have an equals method that looks like:
This is considered bad practice, as it makes it very hard to implement an equals method that is symmetric and transitive. Without those properties, very unexpected behavoirs are possible.
findbugs:EQ_CHECK_FOR_OPERAND_NOT_COMPATIBLE_WITH_THIS
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This class has an equals method that will be broken if it is inherited by subclasses.
It compares a class literal with the class of the argument (e.g., in class
findbugs:EQ_GETCLASS_AND_CLASS_CONSTANT
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This method contains an explicit invocation of the If a connected set of objects beings finalizable, then the VM will invoke the finalize method on all the finalizable object, possibly at the same time in different threads. Thus, it is a particularly bad idea, in the finalize method for a class X, invoke finalize on objects referenced by X, because they may already be getting finalized in a separate thread.
findbugs:FI_EXPLICIT_INVOCATION
|
|||||||||||||||||||||||||||||||||||||||||||||||||
The method in the subclass doesn't override a similar method in a superclass because the type of a parameter doesn't exactly match the type of the corresponding parameter in the superclass. For example, if you have: import alpha.Foo; public class A { public int f(Foo x) { return 17; } } ---- import beta.Foo; public class B extends A { public int f(Foo x) { return 42; } public int f(alpha.Foo x) { return 27; } } The In this case, the subclass does define a method with a signature identical to the method in the superclass, so this is presumably understood. However, such methods are exceptionally confusing. You should strongly consider removing or deprecating the method with the similar but not identical signature.
findbugs:NM_WRONG_PACKAGE_INTENTIONAL
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This method returns a value that is not checked. The return value should be checked
since it can indicate an unusual or unexpected function execution. For
example, the
findbugs:RV_RETURN_VALUE_IGNORED_BAD_PRACTICE
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This method ignores the return value of one of the variants of
findbugs:RR_NOT_CHECKED
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This method ignores the return value of
findbugs:SR_NOT_CHECKED
|
|||||||||||||||||||||||||||||||||||||||||||||||||
The method creates a database resource (such as a database connection or row set), does not assign it to any fields, pass it to other methods, or return it, and does not appear to close the object on all paths out of the method. Failure to close database resources on all paths out of a method may result in poor performance, and could cause the application to have problems communicating with the database.
findbugs:ODR_OPEN_DATABASE_RESOURCE
|
|||||||||||||||||||||||||||||||||||||||||||||||||
The method creates a database resource (such as a database connection or row set), does not assign it to any fields, pass it to other methods, or return it, and does not appear to close the object on all exception paths out of the method. Failure to close database resources on all paths out of a method may result in poor performance, and could cause the application to have problems communicating with the database.
findbugs:ODR_OPEN_DATABASE_RESOURCE_EXCEPTION_PATH
|
|||||||||||||||||||||||||||||||||||||||||||||||||
The method creates an IO stream object, does not assign it to any
fields, pass it to other methods that might close it,
or return it, and does not appear to close
the stream on all paths out of the method. This may result in
a file descriptor leak. It is generally a good
idea to use a
findbugs:OS_OPEN_STREAM
|
|||||||||||||||||||||||||||||||||||||||||||||||||
The method creates an IO stream object, does not assign it to any
fields, pass it to other methods, or return it, and does not appear to close
it on all possible exception paths out of the method.
This may result in a file descriptor leak. It is generally a good
idea to use a
findbugs:OS_OPEN_STREAM_EXCEPTION_PATH
|
|||||||||||||||||||||||||||||||||||||||||||||||||
A method that returns either Boolean.TRUE, Boolean.FALSE or null is an accident waiting to happen. This method can be invoked as though it returned a value of type boolean, and the compiler will insert automatic unboxing of the Boolean value. If a null value is returned, this will result in a NullPointerException.
findbugs:NP_BOOLEAN_RETURN_NULL
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This Serializable class is an inner class of a non-serializable class. Thus, attempts to serialize it will also attempt to associate instance of the outer class with which it is associated, leading to a runtime error. If possible, making the inner class a static inner class should solve the problem. Making the outer class serializable might also work, but that would mean serializing an instance of the inner class would always also serialize the instance of the outer class, which it often not what you really want.
findbugs:SE_BAD_FIELD_INNER_CLASS
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This code creates a java.util.Random object, uses it to generate one random number, and then discards the Random object. This produces mediocre quality random numbers and is inefficient. If possible, rewrite the code so that the Random object is created once and saved, and each time a new random number is required invoke a method on the existing Random object to obtain it. If it is important that the generated Random numbers not be guessable, you must not create a new Random for each random number; the values are too easily guessable. You should strongly consider using a java.security.SecureRandom instead (and avoid allocating a new SecureRandom for each random number needed).
findbugs:DMI_RANDOM_USED_ONLY_ONCE
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This Serializable class is an inner class. Any attempt to serialize it will also serialize the associated outer instance. The outer instance is serializable, so this won't fail, but it might serialize a lot more data than intended. If possible, making the inner class a static inner class (also known as a nested class) should solve the problem.
findbugs:SE_INNER_CLASS
|
|||||||||||||||||||||||||||||||||||||||||||||||||
During the initialization of a class, the class makes an active use of a subclass.
That subclass will not yet be initialized at the time of this use.
For example, in the following code, public class CircularClassInitialization { static class InnerClassSingleton extends CircularClassInitialization { static InnerClassSingleton singleton = new InnerClassSingleton(); } static CircularClassInitialization foo = InnerClassSingleton.singleton; }
findbugs:IC_SUPERCLASS_USES_SUBCLASS_DURING_INITIALIZATION
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This method compares two reference values using the == or != operator, where the correct way to compare instances of this type is generally with the equals() method. Examples of classes which should generally not be compared by reference are java.lang.Integer, java.lang.Float, etc.
findbugs:RC_REF_COMPARISON
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This toString method seems to return null in some circumstances. A liberal reading of the spec could be interpreted as allowing this, but it is probably a bad idea and could cause other code to break. Return the empty string or some other appropriate string rather than null.
findbugs:NP_TOSTRING_COULD_RETURN_NULL
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This class contains a field that is updated at multiple places in the class, thus it seems to be part of the state of the class. However, since the field is marked as transient and not set in readObject or readResolve, it will contain the default value in any deserialized instance of the class.
findbugs:SE_TRANSIENT_FIELD_NOT_RESTORED
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This call to a generic collection method passes an argument while compile type Object where a specific type from the generic type parameters is expected. Thus, neither the standard Java type system nor static analysis can provide useful information on whether the object being passed as a parameter is of an appropriate type.
findbugs:GC_UNCHECKED_TYPE_IN_GENERIC_CALL
|
|||||||||||||||||||||||||||||||||||||||||||||||||
The referenced methods have names that differ only by capitalization. This is very confusing because if the capitalization were identical then one of the methods would override the other. From the existence of other methods, it seems that the existence of both of these methods is intentional, but is sure is confusing. You should try hard to eliminate one of them, unless you are forced to have both due to frozen APIs.
findbugs:NM_VERY_CONFUSING_INTENTIONAL
|
|||||||||||||||||||||||||||||||||||||||||||||||||
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
findbugs:DMI_BIGDECIMAL_CONSTRUCTED_FROM_DOUBLE
|
|||||||||||||||||||||||||||||||||||||||||||||||||
Class names should be nouns, in mixed case with the first letter of each internal word capitalized. Try to keep your class names simple and descriptive. Use whole words-avoid acronyms and abbreviations (unless the abbreviation is much more widely used than the long form, such as URL or HTML).
findbugs:NM_CLASS_NAMING_CONVENTION
|
|||||||||||||||||||||||||||||||||||||||||||||||||
Checks that class parameter names conform to the specified format The following code snippet illustrates this rule for format "^[A-Z]$": class Something<type> { // Non-compliant } class Something<T> { // Compliant }
checkstyle:com.puppycrawl.tools.checkstyle.checks.naming.ClassTypeParameterNameCheck
|
|||||||||||||||||||||||||||||||||||||||||||||||||
The method clone() should only be implemented if the class implements the Cloneable interface with the exception of a final method that only throws CloneNotSupportedException. This version uses PMD's type resolution facilities, and can detect if the class implements or extends a Cloneable class
pmd:CloneMethodMustImplementCloneable
|
|||||||||||||||||||||||||||||||||||||||||||||||||
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.
findbugs:RV_CHECK_COMPARETO_FOR_SPECIFIC_RETURN_VALUE
|
|||||||||||||||||||||||||||||||||||||||||||||||||
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.
findbugs:CO_COMPARETO_RESULTS_MIN_VALUE
|
|||||||||||||||||||||||||||||||||||||||||||||||||
A value specified as carrying a type qualifier annotation is compared with a value that doesn't ever carry that qualifier. More precisely, a value annotated with a type qualifier specifying when=ALWAYS is compared with a value that where the same type qualifier specifies when=NEVER. For example, say that @NonNegative is a nickname for the type qualifier annotation @Negative(when=When.NEVER). The following code will generate this warning because the return statement requires a @NonNegative value, but receives one that is marked as @Negative. public boolean example(@Negative Integer value1, @NonNegative Integer value2) { return value1.equals(value2); }
findbugs:TQ_COMPARING_VALUES_WITH_INCOMPATIBLE_TYPE_QUALIFIERS
|
|||||||||||||||||||||||||||||||||||||||||||||||||
Calling overridable methods during construction poses a risk of invoking methods on an incompletely constructed object
and can be difficult to discern. It may leave the sub-class unable to construct its superclass or forced to replicate
the construction process completely within itself, losing the ability to call super().
If the default constructor contains a call to an overridable method, the subclass may be completely uninstantiable.
Note that this includes method calls throughout the control flow graph - i.e., if a constructor Foo() calls
a private method bar() that calls a public method buz(), this denotes a problem.
public class SeniorClass { public SeniorClass(){ toString(); //may throw NullPointerException if overridden } public String toString(){ return "IAmSeniorClass"; } } public class JuniorClass extends SeniorClass { private String name; public JuniorClass(){ super(); //Automatic call leads to NullPointerException name = "JuniorClass"; } public String toString(){ return name.toUpperCase(); } }
pmd:ConstructorCallsOverridableMethod
|
|||||||||||||||||||||||||||||||||||||||||||||||||
A String function is being invoked and "." is being passed to a parameter that takes a regular expression as an argument. Is this what you intended? For example s.replaceAll(".", "/") will return a String in which every character has been replaced by a / character.
findbugs:RE_POSSIBLE_UNINTENDED_PATTERN
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This regular method has the same name as the class it is defined in. It is likely that this was intended to be a constructor. If it was intended to be a constructor, remove the declaration of a void return value. If you had accidently defined this method, realized the mistake, defined a proper constructor but can't get rid of this method due to backwards compatibility, deprecate the method.
findbugs:NM_METHOD_CONSTRUCTOR_CONFUSION
|
|||||||||||||||||||||||||||||||||||||||||||||||||
One of the arguments being formatted with a format string is an array. This will be formatted
using a fairly useless format, such as [I@304282, which doesn't actually show the contents
of the array.
Consider wrapping the array using
findbugs:VA_FORMAT_STRING_BAD_CONVERSION_FROM_ARRAY
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This code generates a random signed integer and then computes
the absolute value of that random integer. If the number returned by the random number
generator is
findbugs:RV_ABSOLUTE_VALUE_OF_RANDOM_INT
|
|||||||||||||||||||||||||||||||||||||||||||||||||
Adds a byte value and a value which is known to the 8 lower bits clear.
Values loaded from a byte array are sign extended to 32 bits
before any any bitwise operations are performed on the value.
Thus, if In particular, the following code for packing a byte array into an int is badly wrong: int result = 0; for(int i = 0; i < 4; i++) result = ((result << 8) + b[i]); The following idiom will work instead: int result = 0; for(int i = 0; i < 4; i++) result = ((result << 8) + (b[i] & 0xff));
findbugs:BIT_ADD_OF_SIGNED_BYTE
|
|||||||||||||||||||||||||||||||||||||||||||||||||
Loads a value from a byte array and performs a bitwise OR with
that value. Values loaded from a byte array are sign extended to 32 bits
before any any bitwise operations are performed on the value.
Thus, if In particular, the following code for packing a byte array into an int is badly wrong: int result = 0; for(int i = 0; i < 4; i++) result = ((result << 8) | b[i]); The following idiom will work instead: int result = 0; for(int i = 0; i < 4; i++) result = ((result << 8) | (b[i] & 0xff));
findbugs:BIT_IOR_OF_SIGNED_BYTE
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This method calls equals(Object) on two references of unrelated interface types, where neither is a subtype of the other, and there are no known non-abstract classes which implement both interfaces. Therefore, the objects being compared are unlikely to be members of the same class at runtime (unless some application classes were not analyzed, or dynamic class loading can occur at runtime). According to the contract of equals(), objects of different classes should always compare as unequal; therefore, according to the contract defined by java.lang.Object.equals(Object), the result of this comparison will always be false at runtime.
findbugs:EC_UNRELATED_INTERFACES
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This method calls equals(Object) on two references of different class types with no common subclasses. Therefore, the objects being compared are unlikely to be members of the same class at runtime (unless some application classes were not analyzed, or dynamic class loading can occur at runtime). According to the contract of equals(), objects of different classes should always compare as unequal; therefore, according to the contract defined by java.lang.Object.equals(Object), the result of this comparison will always be false at runtime.
findbugs:EC_UNRELATED_TYPES
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This method calls equals(Object) on two references, one of which is a class and the other an interface, where neither the class nor any of its non-abstract subclasses implement the interface. Therefore, the objects being compared are unlikely to be members of the same class at runtime (unless some application classes were not analyzed, or dynamic class loading can occur at runtime). According to the contract of equals(), objects of different classes should always compare as unequal; therefore, according to the contract defined by java.lang.Object.equals(Object), the result of this comparison will always be false at runtime.
findbugs:EC_UNRELATED_CLASS_AND_INTERFACE
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This method compares an expression such as ((event.detail & SWT.SELECTED) > 0). Using bit arithmetic and then comparing with the greater than operator can lead to unexpected results (of course depending on the value of SWT.SELECTED). If SWT.SELECTED is a negative number, this is a candidate for a bug. Even when SWT.SELECTED is not negative, it seems good practice to use '!= 0' instead of '> 0'. Boris Bokowski
findbugs:BIT_SIGNED_CHECK_HIGH_BIT
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This call to a generic collection's method would only make sense if a collection contained
itself (e.g., if
findbugs:DMI_COLLECTIONS_SHOULD_NOT_CONTAIN_THEMSELVES
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This class defines an enumeration, and equality on enumerations are defined using object identity. Defining a covariant equals method for an enumeration value is exceptionally bad practice, since it would likely result in having two different enumeration values that compare as equals using the covariant enum method, and as not equal when compared normally. Don't do it.
findbugs:EQ_DONT_DEFINE_EQUALS_FOR_ENUM
|
|||||||||||||||||||||||||||||||||||||||||||||||||
(Javadoc) A ScheduledThreadPoolExecutor with zero core threads will never execute anything; changes to the max pool size are ignored.
findbugs:DMI_SCHEDULED_THREAD_POOL_EXECUTOR_WITH_ZERO_CORE_THREADS
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This instruction assigns a class literal to a variable and then never uses it.
The behavior of this differs in Java 1.4 and in Java 5.
In Java 1.4 and earlier, a reference to See Sun's article on Java SE compatibility for more details and examples, and suggestions on how to force class initialization in Java 5.
findbugs:DLS_DEAD_STORE_OF_CLASS_LITERAL
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This class is an inner class, but should probably be a static inner class. As it is, there is a serious danger of a deadly embrace between the inner class and the thread local in the outer class. Because the inner class isn't static, it retains a reference to the outer class. If the thread local contains a reference to an instance of the inner class, the inner and outer instance will both be reachable and not eligible for garbage collection.
findbugs:SIC_THREADLOCAL_DEADLY_EMBRACE
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This code opens a file in append mode and then wraps the result in an object output stream. This won't allow you to append to an existing object output stream stored in a file. If you want to be able to append to an object output stream, you need to keep the object output stream open. The only situation in which opening a file in append mode and the writing an object output stream could work is if on reading the file you plan to open it in random access mode and seek to the byte offset where the append started. TODO: example.
findbugs:IO_APPENDING_TO_OBJECT_OUTPUT_STREAM
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This code checks to see if a floating point value is equal to the special
Not A Number value (e.g.,
findbugs:FE_TEST_IF_EQUAL_TO_NOT_A_NUMBER
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This class defines an equals method that always returns false. This means that an object is not equal to itself, and it is impossible to create useful Maps or Sets of this class. More fundamentally, it means that equals is not reflexive, one of the requirements of the equals method. The likely intended semantics are object identity: that an object is equal to itself. This is the behavior inherited from class public boolean equals(Object o) { return this == o; }
findbugs:EQ_ALWAYS_FALSE
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This method checks to see if two objects are the same class by checking to see if the names of their classes are equal. You can have different classes with the same name if they are loaded by different class loaders. Just check to see if the class objects are the same.
findbugs:EQ_COMPARING_CLASS_NAMES
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This class defines an equals method that overrides an equals method in a superclass. Both equals methods
methods use
findbugs:EQ_OVERRIDING_EQUALS_NOT_SYMMETRIC
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This method invokes the .equals(Object o) to compare an array and a reference that doesn't seem to be an array. If things being compared are of different types, they are guaranteed to be unequal and the comparison is almost certainly an error. Even if they are both arrays, the equals method on arrays only determines of the two arrays are the same object. To compare the contents of the arrays, use java.util.Arrays.equals(Object[], Object[]).
findbugs:EC_ARRAY_AND_NONARRAY
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This method invokes the .equals(Object o) to compare two arrays, but the arrays of of incompatible types (e.g., String[] and StringBuffer[], or String[] and int[]). They will never be equal. In addition, when equals(...) is used to compare arrays it only checks to see if they are the same array, and ignores the contents of the arrays.
findbugs:EC_INCOMPATIBLE_ARRAY_COMPARE
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This code creates an exception (or error) object, but doesn't do anything with it. For example, something like if (x < 0) new IllegalArgumentException("x must be nonnegative"); It was probably the intent of the programmer to throw the created exception: if (x < 0) throw new IllegalArgumentException("x must be nonnegative");
findbugs:RV_EXCEPTION_NOT_THROWN
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This field is never initialized within any constructor, and is therefore could be null after the object is constructed. This could be a either an error or a questionable design, since it means a null pointer exception will be generated if that field is dereferenced before being initialized.
findbugs:UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR
|
|||||||||||||||||||||||||||||||||||||||||||||||||
The code here uses
findbugs:RE_CANT_USE_FILE_SEPARATOR_AS_REGULAR_EXPRESSION
|
|||||||||||||||||||||||||||||||||||||||||||||||||
The format string placeholder is incompatible with the corresponding
argument. For example,
The %d placeholder requires a numeric argument, but a string value is passed instead. A runtime exception will occur when this statement is executed.
findbugs:VA_FORMAT_STRING_BAD_ARGUMENT
|
|||||||||||||||||||||||||||||||||||||||||||||||||
(Javadoc) While ScheduledThreadPoolExecutor inherits from ThreadPoolExecutor, a few of the inherited tuning methods are not useful for it. In particular, because it acts as a fixed-sized pool using corePoolSize threads and an unbounded queue, adjustments to maximumPoolSize have no useful effect.
findbugs:DMI_FUTILE_ATTEMPT_TO_CHANGE_MAXPOOL_SIZE_OF_SCHEDULED_THREAD_POOL_EXECUTOR
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This code is casting the result of calling toArray() on a collection to a type more specific than Object[], as in: String[] getAsArray(Collection This will usually fail by throwing a ClassCastException. The The correct way to do get an array of a specific type from a collection is to use There is one common/known exception exception to this. The toArray() method of lists returned by Arrays.asList(...) will return a covariantly typed array. For example,
findbugs:BC_IMPOSSIBLE_DOWNCAST_OF_TOARRAY
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This method compares an expression of the form (e | C) to D. which will always compare unequal due to the specific values of constants C and D. This may indicate a logic error or typo. Typically, this bug occurs because the code wants to perform a membership test in a bit set, but uses the bitwise OR operator ("|") instead of bitwise AND ("&").
findbugs:BIT_IOR
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This code converts an int value to a double precision floating point number and then passing the result to the Math.ceil() function, which rounds a double to the next higher integer value. This operation should always be a no-op, since the converting an integer to a double should give a number with no fractional part. It is likely that the operation that generated the value to be passed to Math.ceil was intended to be performed using double precision floating point arithmetic.
findbugs:ICAST_INT_CAST_TO_DOUBLE_PASSED_TO_CEIL
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This code converts an int value to a float precision floating point number and then passing the result to the Math.round() function, which returns the int/long closest to the argument. This operation should always be a no-op, since the converting an integer to a float should give a number with no fractional part. It is likely that the operation that generated the value to be passed to Math.round was intended to be performed using floating point arithmetic.
findbugs:ICAST_INT_CAST_TO_FLOAT_PASSED_TO_ROUND
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This method invokes the .equals(Object o) method on an array. Since arrays do not override the equals method of Object, calling equals on an array is the same as comparing their addresses. To compare the contents of the arrays, use java.util.Arrays.equals(Object[], Object[]).
findbugs:EC_BAD_ARRAY_COMPARE
|
|||||||||||||||||||||||||||||||||||||||||||||||||
The code invokes hashCode on an array. Calling hashCode on
an array returns the same value as System.identityHashCode, and ingores
the contents and length of the array. If you need a hashCode that
depends on the contents of an array
findbugs:DMI_INVOKING_HASHCODE_ON_ARRAY
|
|||||||||||||||||||||||||||||||||||||||||||||||||
The code invokes toString on an (anonymous) array. Calling toString on an array generates a fairly useless result such as [C@16f0472. Consider using Arrays.toString to convert the array into a readable String that gives the contents of the array. See Programming Puzzlers, chapter 3, puzzle 12.
findbugs:DMI_INVOKING_TOSTRING_ON_ANONYMOUS_ARRAY
|
|||||||||||||||||||||||||||||||||||||||||||||||||
The code invokes toString on an array, which will generate a fairly useless result such as [C@16f0472. Consider using Arrays.toString to convert the array into a readable String that gives the contents of the array. See Programming Puzzlers, chapter 3, puzzle 12.
findbugs:DMI_INVOKING_TOSTRING_ON_ARRAY
|
|||||||||||||||||||||||||||||||||||||||||||||||||
A JUnit assertion is performed in a run method. Failed JUnit assertions just result in exceptions being thrown. Thus, if this exception occurs in a thread other than the thread that invokes the test method, the exception will terminate the thread but not result in the test failing.
findbugs:IJU_ASSERT_METHOD_INVOKED_FROM_RUN_METHOD
|
|||||||||||||||||||||||||||||||||||||||||||||||||
A method is called that expects a Java printf format string and a list of arguments. However, the format string doesn't contain any format specifiers (e.g., %s) but does contain message format elements (e.g., {0}). It is likely that the code is supplying a MessageFormat string when a printf-style format string is required. At runtime, all of the arguments will be ignored and the format string will be returned exactly as provided without any formatting.
findbugs:VA_FORMAT_STRING_EXPECTED_MESSAGE_FORMAT_SUPPLIED
|
|||||||||||||||||||||||||||||||||||||||||||||||||
A possibly-null value is passed at a call site where all known target methods require the parameter to be nonnull. Either the parameter is annotated as a parameter that should always be nonnull, or analysis has shown that it will always be dereferenced.
findbugs:NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS
|
|||||||||||||||||||||||||||||||||||||||||||||||||
The method in the subclass doesn't override a similar method in a superclass because the type of a parameter doesn't exactly match the type of the corresponding parameter in the superclass. For example, if you have: import alpha.Foo; public class A { public int f(Foo x) { return 17; } } ---- import beta.Foo; public class B extends A { public int f(Foo x) { return 42; } } The
findbugs:NM_WRONG_PACKAGE
|
|||||||||||||||||||||||||||||||||||||||||||||||||
The return value of this method should be checked. One common cause of this warning is to invoke a method on an immutable object, thinking that it updates the object. For example, in the following code fragment, String dateString = getHeaderField(name); dateString.trim(); the programmer seems to be thinking that the trim() method will update the String referenced by dateString. But since Strings are immutable, the trim() function returns a new String value, which is being ignored here. The code should be corrected to: String dateString = getHeaderField(name); dateString = dateString.trim();
findbugs:RV_RETURN_VALUE_IGNORED2
|
|||||||||||||||||||||||||||||||||||||||||||||||||
The return value of this method should be checked. One common cause of this warning is to invoke a method on an immutable object, thinking that it updates the object. For example, in the following code fragment, String dateString = getHeaderField(name); dateString.trim(); the programmer seems to be thinking that the trim() method will update the String referenced by dateString. But since Strings are immutable, the trim() function returns a new String value, which is being ignored here. The code should be corrected to: String dateString = getHeaderField(name); dateString = dateString.trim();
findbugs:RV_RETURN_VALUE_IGNORED
|
|||||||||||||||||||||||||||||||||||||||||||||||||
A format-string method with a variable number of arguments is called, but more arguments are passed than are actually used by the format string. This won't cause a runtime exception, but the code may be silently omitting information that was intended to be included in the formatted string.
findbugs:VA_FORMAT_STRING_EXTRA_ARGUMENTS_PASSED
|
|||||||||||||||||||||||||||||||||||||||||||||||||
The format string specifies a relative index to request that the argument for the previous format specifier be reused. However, there is no previous argument. For example,
would throw a MissingFormatArgumentException when executed.
findbugs:VA_FORMAT_STRING_NO_PREVIOUS_ARGUMENT
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This call to a generic collection method contains an argument with an incompatible class from that of the collection's parameter (i.e., the type of the argument is neither a supertype nor a subtype of the corresponding generic type argument). Therefore, it is unlikely that the collection contains any objects that are equal to the method argument used here. Most likely, the wrong value is being passed to the method. In general, instances of two unrelated classes are not equal.
For example, if the In rare cases, people do define nonsymmetrical equals methods and still manage to make
their code work. Although none of the APIs document or guarantee it, it is typically
the case that if you check if a
findbugs:GC_UNRELATED_TYPES
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This method performs a nonsensical computation of a field with another reference to the same field (e.g., x&x or x-x). Because of the nature of the computation, this operation doesn't seem to make sense, and may indicate a typo or a logic error. Double check the computation.
findbugs:SA_FIELD_SELF_COMPUTATION
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This method performs a nonsensical computation of a local variable with another reference to the same variable (e.g., x&x or x-x). Because of the nature of the computation, this operation doesn't seem to make sense, and may indicate a typo or a logic error. Double check the computation.
findbugs:SA_LOCAL_SELF_COMPUTATION
|
|||||||||||||||||||||||||||||||||||||||||||||||||
A pointer which is null on an exception path is dereferenced here.
This will lead to a Also note that FindBugs considers the default case of a switch statement to be an exception path, since the default case is often infeasible.
findbugs:NP_ALWAYS_NULL_EXCEPTION
|
|||||||||||||||||||||||||||||||||||||||||||||||||
A value is checked here to see whether it is null, but this value can't be null because it was previously dereferenced and if it were null a null pointer exception would have occurred at the earlier dereference. Essentially, this code and the previous dereference disagree as to whether this value is allowed to be null. Either the check is redundant or the previous dereference is erroneous.
findbugs:RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE
|
|||||||||||||||||||||||||||||||||||||||||||||||||
There is a branch of statement that, if executed, guarantees that
a null value will be dereferenced, which
would generate a
findbugs:NP_NULL_ON_SOME_PATH
|
|||||||||||||||||||||||||||||||||||||||||||||||||
A reference value which is null on some exception control path is
dereferenced here. This may lead to a Also note that FindBugs considers the default case of a switch statement to be an exception path, since the default case is often infeasible.
findbugs:NP_NULL_ON_SOME_PATH_EXCEPTION
|
|||||||||||||||||||||||||||||||||||||||||||||||||
A wrapped primitive value is unboxed and converted to another primitive type as part of the
evaluation of a conditional ternary operator (the
findbugs:BX_UNBOXED_AND_COERCED_FOR_TERNARY_OPERATOR
|
|||||||||||||||||||||||||||||||||||||||||||||||||
The putIfAbsent method is typically used to ensure that a single value is associated with a given key (the first value for which put if absent succeeds). If you ignore the return value and retain a reference to the value passed in, you run the risk of retaining a value that is not the one that is associated with the key in the map. If it matters which one you use and you use the one that isn't stored in the map, your program will behave incorrectly.
findbugs:RV_RETURN_VALUE_OF_PUTIFABSENT_IGNORED
|
|||||||||||||||||||||||||||||||||||||||||||||||||
A method, field or class declares a generic signature where a non-hashable class is used in context where a hashable class is required. A class that declares an equals method but inherits a hashCode() method from Object is unhashable, since it doesn't fulfill the requirement that equal objects have equal hashCodes.
findbugs:HE_SIGNATURE_DECLARES_HASHING_OF_UNHASHABLE_CLASS
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This method invokes the Thread.interrupted() method on a Thread object that appears to be a Thread object that is not the current thread. As the interrupted() method is static, the interrupted method will be called on a different object than the one the author intended.
findbugs:STI_INTERRUPTED_ON_UNKNOWNTHREAD
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This method compares two Boolean values using the == or != operator. Normally, there are only two Boolean values (Boolean.TRUE and Boolean.FALSE), but it is possible to create other Boolean objects using the new Boolean(b) constructor. It is best to avoid such objects, but if they do exist, then checking Boolean objects for equality using == or != will give results than are different than you would get using .equals(...)
findbugs:RC_REF_COMPARISON_BAD_PRACTICE_BOOLEAN
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This method compares a reference value to a constant using the == or != operator, where the correct way to compare instances of this type is generally with the equals() method. It is possible to create distinct instances that are equal but do not compare as == since they are different objects. Examples of classes which should generally not be compared by reference are java.lang.Integer, java.lang.Float, etc.
findbugs:RC_REF_COMPARISON_BAD_PRACTICE
|
|||||||||||||||||||||||||||||||||||||||||||||||||
One of the arguments is uncompatible with the corresponding format string specifier.
As a result, this will generate a runtime exception when executed.
For example,
findbugs:VA_FORMAT_STRING_BAD_CONVERSION
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This anonymous class defined a method that is not directly invoked and does not override a method in a superclass. Since methods in other classes cannot directly invoke methods declared in an anonymous class, it seems that this method is uncallable. The method might simply be dead code, but it is also possible that the method is intended to override a method declared in a superclass, and due to an typo or other error the method does not, in fact, override the method it is intended to.
findbugs:UMAC_UNCALLABLE_METHOD_OF_ANONYMOUS_CLASS
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This method is invoked in the constructor of of the superclass. At this point, the fields of the class have not yet initialized. To make this more concrete, consider the following classes: abstract class A { int hashCode; abstract Object getValue(); A() { hashCode = getValue().hashCode(); } } class B extends A { Object value; B(Object v) { this.value = v; } Object getValue() { return value; } } When a B is constructed, the constructor for the A class is invoked before the constructor for B sets value. Thus, when the constructor for A invokes getValue, an uninitialized value is read for value.
findbugs:UR_UNINIT_READ_CALLED_FROM_SUPER_CONSTRUCTOR
|
|||||||||||||||||||||||||||||||||||||||||||||||||
A class defines an equals(Object) method but not a hashCode() method, and thus doesn't fulfill the requirement that equal objects have equal hashCodes. An instance of this class is used in a hash data structure, making the need to fix this problem of highest importance.
findbugs:HE_USE_OF_UNHASHABLE_CLASS
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This method contains a useless control flow statement in which control
flow follows to the same or following line regardless of whether or not
the branch is taken.
Often, this is caused by inadvertently using an empty statement as the
body of an if (argv.length == 1); System.out.println("Hello, " + argv[0]);
findbugs:UCF_USELESS_CONTROL_FLOW_NEXT_LINE
|
|||||||||||||||||||||||||||||||||||||||||||||||||
A value specified as carrying a type qualifier annotation is consumed in a location or locations requiring that the value not carry that annotation. More precisely, a value annotated with a type qualifier specifying when=ALWAYS is guaranteed to reach a use or uses where the same type qualifier specifies when=NEVER. For example, say that @NonNegative is a nickname for the type qualifier annotation @Negative(when=When.NEVER). The following code will generate this warning because the return statement requires a @NonNegative value, but receives one that is marked as @Negative. public @NonNegative Integer example(@Negative Integer value) { return value; }
findbugs:TQ_ALWAYS_VALUE_USED_WHERE_NEVER_REQUIRED
|
|||||||||||||||||||||||||||||||||||||||||||||||||
A value specified as not carrying a type qualifier annotation is guaranteed to be consumed in a location or locations requiring that the value does carry that annotation. More precisely, a value annotated with a type qualifier specifying when=NEVER is guaranteed to reach a use or uses where the same type qualifier specifies when=ALWAYS. TODO: example
findbugs:TQ_NEVER_VALUE_USED_WHERE_ALWAYS_REQUIRED
|
|||||||||||||||||||||||||||||||||||||||||||||||||
A value is used in a way that requires it to be always be a value denoted by a type qualifier, but there is an explicit annotation stating that it is not known where the value is required to have that type qualifier. Either the usage or the annotation is incorrect.
findbugs:TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_ALWAYS_SINK
|
|||||||||||||||||||||||||||||||||||||||||||||||||
A value is used in a way that requires it to be never be a value denoted by a type qualifier, but there is an explicit annotation stating that it is not known where the value is prohibited from having that type qualifier. Either the usage or the annotation is incorrect.
findbugs:TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_NEVER_SINK
|
|||||||||||||||||||||||||||||||||||||||||||||||||
Checks cyclomatic complexity of methods against a specified limit. The complexity is measured by the number of if, while, do, for, ?:, catch, switch, case statements, and operators && and || (plus one) in the body of a constructor, method, static initializer, or instance initializer. It is a measure of the minimum number of possible paths through the source and therefore the number of required tests. Generally 1-4 is considered good, 5-7 ok, 8-10 consider re-factoring, and 11+ re-factor now !
checkstyle:com.puppycrawl.tools.checkstyle.checks.metrics.CyclomaticComplexityCheck
|
|||||||||||||||||||||||||||||||||||||||||||||||||
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?
findbugs:DLS_DEAD_LOCAL_STORE_SHADOWS_FIELD
|
|||||||||||||||||||||||||||||||||||||||||||||||||
An inner class is invoking a method that could be resolved to either a inherited method or a method defined in an outer class. By the Java semantics, it will be resolved to invoke the inherited method, but this may not be want you intend. If you really intend to invoke the inherited method, invoke it by invoking the method on super (e.g., invoke super.foo(17)), and thus it will be clear to other readers of your code and to FindBugs that you want to invoke the inherited method, not the method in the outer class.
findbugs:IA_AMBIGUOUS_INVOCATION_OF_INHERITED_OR_OUTER_METHOD
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This class extends a class that defines an equals method and adds fields, but doesn't define an equals method itself. Thus, equality on instances of this class will ignore the identity of the subclass and the added fields. Be sure this is what is intended, and that you don't need to override the equals method. Even if you don't need to override the equals method, consider overriding it anyway to document the fact that the equals method for the subclass just return the result of invoking super.equals(o).
findbugs:EQ_DOESNT_OVERRIDE_EQUALS
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This class uses synchronization along with wait(), notify() or notifyAll() on itself (the this reference). Client classes that use this class, may, in addition, use an instance of this class as a synchronizing object. Because two classes are using the same object for synchronization, Multithread correctness is suspect. You should not synchronize nor call semaphore methods on a public reference. Consider using a internal private member variable to control synchronization.
findbugs:PS_PUBLIC_SEMAPHORES
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This class extends from a Servlet class, and uses an instance member variable. Since only one instance of a Servlet class is created by the J2EE framework, and used in a multithreaded way, this paradigm is highly discouraged and most likely problematic. Consider only using method local variables.
findbugs:MTIA_SUSPECT_SERVLET_INSTANCE_FIELD
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This class extends from a Struts Action class, and uses an instance member variable. Since only one instance of a struts Action class is created by the Struts framework, and used in a multithreaded way, this paradigm is highly discouraged and most likely problematic. Consider only using method local variables. Only instance fields that are written outside of a monitor are reported.
findbugs:MTIA_SUSPECT_STRUTS_INSTANCE_FIELD
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This class declares that it implements an interface that is also implemented by a superclass. This is redundant because once a superclass implements an interface, all subclasses by default also implement this interface. It may point out that the inheritance hierarchy has changed since this class was created, and consideration should be given to the ownership of the interface's implementation.
findbugs:RI_REDUNDANT_INTERFACES
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This class is declared to be final, but declares fields to be protected. Since the class is final, it can not be derived from, and the use of protected is confusing. The access modifier for the field should be changed to private or public to represent the true use for the field.
findbugs:CI_CONFUSED_INHERITANCE
|
|||||||||||||||||||||||||||||||||||||||||||||||||
The code computes the average of two integers using either division or signed right shift,
and then uses the result as the index of an array.
If the values being averaged are very large, this can overflow (resulting in the computation
of a negative average). Assuming that the result is intended to be nonnegative, you
can use an unsigned right shift instead. In other words, rather that using This bug exists in many earlier implementations of binary search and merge sort. Martin Buchholz found and fixed it in the JDK libraries, and Joshua Bloch widely publicized the bug pattern.
findbugs:IM_AVERAGE_COMPUTATION_COULD_OVERFLOW
|
|||||||||||||||||||||||||||||||||||||||||||||||||
It is often a better design to return a length zero array rather than a null reference to indicate that there are no results (i.e., an empty list of results). This way, no explicit check for null is needed by clients of the method. On the other hand, using null to indicate
"there is no answer to this question" is probably appropriate.
For example,
findbugs:PZLA_PREFER_ZERO_LENGTH_ARRAYS
|
|||||||||||||||||||||||||||||||||||||||||||||||||
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. Note that Sun's javac compiler often generates dead stores for final local variables. Because FindBugs is a bytecode-based tool, there is no easy way to eliminate these false positives.
findbugs:DLS_DEAD_LOCAL_STORE
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This method uses a try-catch block that catches Exception objects, but Exception is not thrown within the try block, and RuntimeException is not explicitly caught. It is a common bug pattern to say try { ... } catch (Exception e) { something } as a shorthand for catching a number of types of exception each of whose catch blocks is identical, but this construct also accidentally catches RuntimeException as well, masking potential bugs.
findbugs:REC_CATCH_EXCEPTION
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This instanceof test will always return true (unless the value being tested is null). Although this is safe, make sure it isn't an indication of some misunderstanding or some other logic error. If you really want to test the value for being null, perhaps it would be clearer to do better to do a null test rather than an instanceof test.
findbugs:BC_VACUOUS_INSTANCEOF
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This code casts the result of an integer 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. Here is an example: int x = 2; int y = 5; // Wrong: yields result 0.0 double value1 = x / y; // Right: yields result 0.4 double value2 = x / (double) y;
findbugs:ICAST_IDIV_CAST_TO_DOUBLE
|
|||||||||||||||||||||||||||||||||||||||||||||||||
The variable referenced at this point is known to be null due to an earlier check against null. Although this is valid, it might be a mistake (perhaps you intended to refer to a different variable, or perhaps the earlier check to see if the variable is null should have been a check to see if it was nonnull).
findbugs:NP_LOAD_OF_KNOWN_NULL_VALUE
|
|||||||||||||||||||||||||||||||||||||||||||||||||
The method invokes String.indexOf and checks to see if the result is positive or non-positive. It is much more typical to check to see if the result is negative or non-negative. It is positive only if the substring checked for occurs at some place other than at the beginning of the String.
findbugs:RV_CHECK_FOR_POSITIVE_INDEXOF
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This method allocates a specific implementation of an xml interface. It is preferable to use the supplied factory classes to create these objects so that the implementation can be changed at runtime. See
for details.
findbugs:XFB_XML_FACTORY_BYPASS
|
|||||||||||||||||||||||||||||||||||||||||||||||||
An argument not of type Boolean is being formatted with a %b format specifier. This won't throw an exception; instead, it will print true for any nonnull value, and false for null. This feature of format strings is strange, and may not be what you intended.
findbugs:VA_FORMAT_STRING_BAD_CONVERSION_TO_BOOLEAN
|
|||||||||||||||||||||||||||||||||||||||||||||||||
There is a branch of statement that, if executed, guarantees that
a null value will be dereferenced, which
would generate a
findbugs:NP_NULL_ON_SOME_PATH_MIGHT_BE_INFEASIBLE
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This code seems to be using non-short-circuit logic (e.g., & or |) rather than short-circuit logic (&& or ||). In addition, it seem possible that, depending on the value of the left hand side, you might not want to evaluate the right hand side (because it would have side effects, could cause an exception or could be expensive. Non-short-circuit logic causes both sides of the expression to be evaluated even when the result can be inferred from knowing the left-hand side. This can be less efficient and can result in errors if the left-hand side guards cases when evaluating the right-hand side can generate an error. See the Java Language Specification for details
findbugs:NS_DANGEROUS_NON_SHORT_CIRCUIT
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This code casts a Collection to an abstract collection
(such as
findbugs:BC_BAD_CAST_TO_ABSTRACT_COLLECTION
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This code casts an abstract collection (such as a Collection, List, or Set) to a specific concrete implementation (such as an ArrayList or HashSet). This might not be correct, and it may make your code fragile, since it makes it harder to switch to other concrete implementations at a future point. Unless you have a particular reason to do so, just use the abstract collection class.
findbugs:BC_BAD_CAST_TO_CONCRETE_COLLECTION
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This code seems to be using non-short-circuit logic (e.g., & or |) rather than short-circuit logic (&& or ||). Non-short-circuit logic causes both sides of the expression to be evaluated even when the result can be inferred from knowing the left-hand side. This can be less efficient and can result in errors if the left-hand side guards cases when evaluating the right-hand side can generate an error. See the Java Language Specification for details
findbugs:NS_NON_SHORT_CIRCUIT
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This code generates a random signed integer and then computes the remainder of that value modulo another value. Since the random number can be negative, the result of the remainder operation can also be negative. Be sure this is intended, and strongly consider using the Random.nextInt(int) method instead.
findbugs:RV_REM_OF_RANDOM_INT
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This code computes a hashCode, and then computes the remainder of that value modulo another value. Since the hashCode can be negative, the result of the remainder operation can also be negative. Assuming you want to ensure that the result of your computation is nonnegative,
you may need to change your code.
If you know the divisor is a power of 2,
you can use a bitwise and operator instead (i.e., instead of
using
findbugs:RV_REM_OF_HASHCODE
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This code performs integer multiply and then converts the result to a long,
as in:
findbugs:ICAST_INTEGER_MULTIPLY_CAST_TO_LONG
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This operation compares two floating point values for equality.
Because floating point calculations may involve rounding,
calculated float and double values may not be accurate.
For values that must be precise, such as monetary values,
consider using a fixed-precision type such as BigDecimal.
For values that need not be precise, consider comparing for equality
within some range, for example:
findbugs:FE_FLOATING_POINT_EQUALITY
|
|||||||||||||||||||||||||||||||||||||||||||||||||
The field is marked as transient, but the class isn't Serializable, so marking it as transient has absolutely no effect. This may be leftover marking from a previous version of the code in which the class was transient, or it may indicate a misunderstanding of how serialization works.
findbugs:SE_TRANSIENT_FIELD_OF_NONSERIALIZABLE_CLASS
|
|||||||||||||||||||||||||||||||||||||||||||||||||
The code performs an unsigned right shift, whose result is then cast to a short or byte, which discards the upper bits of the result. Since the upper bits are discarded, there may be no difference between a signed and unsigned right shift (depending upon the size of the shift).
findbugs:ICAST_QUESTIONABLE_UNSIGNED_RIGHT_SHIFT
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This method contains a useless control flow statement, where
control flow continues onto the same place regardless of whether or not
the branch is taken. For example,
this is caused by having an empty statement
block for an if (argv.length == 0) { // TODO: handle this case }
findbugs:UCF_USELESS_CONTROL_FLOW
|
|||||||||||||||||||||||||||||||||||||||||||||||||
The entrySet() method is allowed to return a view of the underlying Map in which an
findbugs:PZ_DONT_REUSE_ENTRY_OBJECTS_IN_ITERATORS
|
|||||||||||||||||||||||||||||||||||||||||||||||||
OpenJDK introduces a potential incompatibility. In particular, the java.util.logging.Logger behavior has changed. Instead of using strong references, it now uses weak references internally. That's a reasonable change, but unfortunately some code relies on the old behavior - when changing logger configuration, it simply drops the logger reference. That means that the garbage collector is free to reclaim that memory, which means that the logger configuration is lost. For example, consider: public static void initLogging() throws Exception { Logger logger = Logger.getLogger("edu.umd.cs"); logger.addHandler(new FileHandler()); // call to change logger configuration logger.setUseParentHandlers(false); // another call to change logger configuration } The logger reference is lost at the end of the method (it doesn't escape the method), so if you have a garbage collection cycle just after the call to initLogging, the logger configuration is lost (because Logger only keeps weak references). public static void main(String[] args) throws Exception { initLogging(); // adds a file handler to the logger System.gc(); // logger configuration lost Logger.getLogger("edu.umd.cs").info("Some message"); // this isn't logged to the file as expected } Ulf Ochsenfahrt and Eric Fellheimer
findbugs:LG_LOST_LOGGER_DUE_TO_WEAK_REFERENCE
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This static field public but not final, and could be changed by malicious code or by accident from another package. The field could be made final to avoid this vulnerability. However, the static initializer contains more than one write to the field, so doing so will require some refactoring.
findbugs:MS_SHOULD_BE_REFACTORED_TO_BE_FINAL
|
|||||||||||||||||||||||||||||||||||||||||||||||||
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: 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); }
findbugs:ICAST_INT_2_LONG_AS_INSTANT
|
|||||||||||||||||||||||||||||||||||||||||||||||||
A final static field that is defined in an interface references a mutable object such as an array or hashtable. This mutable object could be changed by malicious code or by accident from another package. To solve this, the field needs to be moved to a class and made package protected to avoid this vulnerability.
findbugs:MS_OOI_PKGPROTECT
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This code stores a reference to an externally mutable object into the internal representation of the object. If instances are accessed by untrusted code, and unchecked changes to the mutable object would compromise security or other important properties, you will need to do something different. Storing a copy of the object is better approach in many situations.
findbugs:EI_EXPOSE_REP2
|
|||||||||||||||||||||||||||||||||||||||||||||||||
Returning a reference to a mutable object value stored in one of the object's fields exposes the internal representation of the object. If instances are accessed by untrusted code, and unchecked changes to the mutable object would compromise security or other important properties, you will need to do something different. Returning a new copy of the object is better approach in many situations.
findbugs:EI_EXPOSE_REP
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This code stores a reference to an externally mutable object into a static field. If unchecked changes to the mutable object would compromise security or other important properties, you will need to do something different. Storing a copy of the object is better approach in many situations.
findbugs:EI_EXPOSE_STATIC_REP2
|
|||||||||||||||||||||||||||||||||||||||||||||||||
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 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
Please investigate this closely to decide whether it is OK to ignore the return value.
findbugs:RV_RETURN_VALUE_IGNORED_INFERRED
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This method may fail to clean up (close, dispose of) a stream, database object, or other resource requiring an
explicit cleanup operation. 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. .
findbugs:OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE
|
|||||||||||||||||||||||||||||||||||||||||||||||||
Checks that method type parameter names conform to the specified format The following code snippet illustrates this rule for format "^[A-Z]$": public <type> boolean containsAll(Collection<type> c) { // Non-compliant return null; } public <T> boolean containsAll(Collection<T> c) { // Compliant }
checkstyle:com.puppycrawl.tools.checkstyle.checks.naming.MethodTypeParameterNameCheck
|
|||||||||||||||||||||||||||||||||||||||||||||||||
Checks that the order of modifiers conforms to the suggestions in the Java Language specification, sections 8.1.1, 8.3.1 and 8.4.3. The correct order is : public, protected, private, abstract, static, final, transient, volatile, synchronized, native, strictfp.
checkstyle:com.puppycrawl.tools.checkstyle.checks.modifier.ModifierOrderCheck
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This declares a volatile reference to an array, which might not be what you want. With a volatile reference to an array, reads and writes of the reference to the array are treated as volatile, but the array elements are non-volatile. To get volatile array elements, you will need to use one of the atomic array classes in java.util.concurrent (provided in Java 5.0).
findbugs:VO_VOLATILE_REFERENCE_TO_ARRAY
|
|||||||||||||||||||||||||||||||||||||||||||||||||
Even though the JavaDoc does not contain a hint about it, Calendars are inherently unsafe for multihtreaded use. The detector has found a call to an instance of Calendar that has been obtained via a static field. This looks suspicous. For more information on this see Sun Bug #6231579 and Sun Bug #6178997.
findbugs:STCAL_INVOKE_ON_STATIC_CALENDAR_INSTANCE
|
|||||||||||||||||||||||||||||||||||||||||||||||||
As the JavaDoc states, DateFormats are inherently unsafe for multithreaded use. The detector has found a call to an instance of DateFormat that has been obtained via a static field. This looks suspicous. For more information on this see Sun Bug #6231579 and Sun Bug #6178997.
findbugs:STCAL_INVOKE_ON_STATIC_DATE_FORMAT_INSTANCE
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This serializable class defines a
findbugs:RS_READOBJECT_SYNC
|
|||||||||||||||||||||||||||||||||||||||||||||||||
The fields of this class appear to be accessed inconsistently with respect to synchronization. This bug report indicates that the bug pattern detector judged that
A typical bug matching this bug pattern is forgetting to synchronize one of the methods in a class that is intended to be thread-safe. You can select the nodes labeled "Unsynchronized access" to show the code locations where the detector believed that a field was accessed without synchronization. Note that there are various sources of inaccuracy in this detector; for example, the detector cannot statically detect all situations in which a lock is held. Also, even when the detector is accurate in distinguishing locked vs. unlocked accesses, the code in question may still be correct.
findbugs:IS2_INCONSISTENT_SYNC
|
|||||||||||||||||||||||||||||||||||||||||||||||||
The fields of this class appear to be accessed inconsistently with respect to synchronization. This bug report indicates that the bug pattern detector judged that
A typical bug matching this bug pattern is forgetting to synchronize one of the methods in a class that is intended to be thread-safe. Note that there are various sources of inaccuracy in this detector; for example, the detector cannot statically detect all situations in which a lock is held. Also, even when the detector is accurate in distinguishing locked vs. unlocked accesses, the code in question may still be correct.
findbugs:IS_INCONSISTENT_SYNC
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This method contains an unsynchronized lazy initialization of a static field. After the field is set, the object stored into that location is further accessed. The setting of the field is visible to other threads as soon as it is set. If the futher accesses in the method that set the field serve to initialize the object, then you have a very serious multithreading bug, unless something else prevents any other thread from accessing the stored object until it is fully initialized.
findbugs:LI_LAZY_INIT_UPDATE_STATIC
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This method contains an unsynchronized lazy initialization of a non-volatile static field. Because the compiler or processor may reorder instructions, threads are not guaranteed to see a completely initialized object, if the method can be called by multiple threads. You can make the field volatile to correct the problem. For more information, see the Java Memory Model web site.
findbugs:LI_LAZY_INIT_STATIC
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This method calls Thread.sleep() with a lock held. This may result in very poor performance and scalability, or a deadlock, since other threads may be waiting to acquire the lock. It is a much better idea to call wait() on the lock, which releases the lock and allows other threads to run.
findbugs:SWL_SLEEP_WITH_LOCK_HELD
|
|||||||||||||||||||||||||||||||||||||||||||||||||
A web server generally only creates one instance of servlet or jsp class (i.e., treats the class as a Singleton), and will have multiple threads invoke methods on that instance to service multiple simultaneous requests. Thus, having a mutable instance field generally creates race conditions.
findbugs:MSF_MUTABLE_SERVLET_FIELD
|
|||||||||||||||||||||||||||||||||||||||||||||||||
A call to This bug does not necessarily indicate an error, since the change to mutable object state may have taken place in a method which then called the method containing the notification.
findbugs:NN_NAKED_NOTIFY
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This method may contain an instance of double-checked locking. This idiom is not correct according to the semantics of the Java memory model. For more information, see the web page http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html.
findbugs:DC_DOUBLECHECK
|
|||||||||||||||||||||||||||||||||||||||||||||||||
Even though the JavaDoc does not contain a hint about it, Calendars are inherently unsafe for multihtreaded use. Sharing a single instance across thread boundaries without proper synchronization will result in erratic behavior of the application. Under 1.4 problems seem to surface less often than under Java 5 where you will probably see random ArrayIndexOutOfBoundsExceptions or IndexOutOfBoundsExceptions in sun.util.calendar.BaseCalendar.getCalendarDateFromFixedDate(). You may also experience serialization problems. Using an instance field is recommended. For more information on this see Sun Bug #6231579 and Sun Bug #6178997.
findbugs:STCAL_STATIC_CALENDAR_INSTANCE
|
|||||||||||||||||||||||||||||||||||||||||||||||||
As the JavaDoc states, DateFormats are inherently unsafe for multithreaded use. Sharing a single instance across thread boundaries without proper synchronization will result in erratic behavior of the application. You may also experience serialization problems. Using an instance field is recommended. For more information on this see Sun Bug #6231579 and Sun Bug #6178997.
findbugs:STCAL_STATIC_SIMPLE_DATE_FORMAT_INSTANCE
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This instance method synchronizes on private static final String base = "label"; private static int nameCounter = 0; String constructComponentName() { synchronized (getClass()) { return base + nameCounter++; } } Subclasses of private static final String base = "label"; private static int nameCounter = 0; String constructComponentName() { synchronized (Label.class) { return base + nameCounter++; } } Bug pattern contributed by Jason Mehrens
findbugs:WL_USING_GETCLASS_RATHER_THAN_CLASS_LITERAL
|
|||||||||||||||||||||||||||||||||||||||||||||||||
The code synchronizes on a boxed primitive constant, such as an Boolean. private static Boolean inited = Boolean.FALSE; ... synchronized(inited) { if (!inited) { init(); inited = Boolean.TRUE; } } ... Since there normally exist only two Boolean objects, this code could be synchronizing on the same object as other, unrelated code, leading to unresponsiveness and possible deadlock
findbugs:DL_SYNCHRONIZATION_ON_BOOLEAN
|
|||||||||||||||||||||||||||||||||||||||||||||||||
The code synchronizes on a boxed primitive constant, such as an Integer. private static Integer count = 0; ... synchronized(count) { count++; } ... Since Integer objects can be cached and shared, this code could be synchronizing on the same object as other, unrelated code, leading to unresponsiveness and possible deadlock
findbugs:DL_SYNCHRONIZATION_ON_BOXED_PRIMITIVE
|
|||||||||||||||||||||||||||||||||||||||||||||||||
The code synchronizes on an apparently unshared boxed primitive, such as an Integer. private static final Integer fileLock = new Integer(1); ... synchronized(fileLock) { .. do something .. } ... It would be much better, in this code, to redeclare fileLock as private static final Object fileLock = new Object();The existing code might be OK, but it is confusing and a future refactoring, such as the "Remove Boxing" refactoring in IntelliJ, might replace this with the use of an interned Integer object shared throughout the JVM, leading to very confusing behavior and potential deadlock.
findbugs:DL_SYNCHRONIZATION_ON_UNSHARED_BOXED_PRIMITIVE
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This method synchronizes on a field in what appears to be an attempt to guard against simultaneous updates to that field. But guarding a field gets a lock on the referenced object, not on the field. This may not provide the mutual exclusion you need, and other threads might be obtaining locks on the referenced objects (for other purposes). An example of this pattern would be: private Long myNtfSeqNbrCounter = new Long(0); private Long getNotificationSequenceNumber() { Long result = null; synchronized(myNtfSeqNbrCounter) { result = new Long(myNtfSeqNbrCounter.longValue() + 1); myNtfSeqNbrCounter = new Long(result.longValue()); } return result; }
findbugs:ML_SYNC_ON_FIELD_TO_GUARD_CHANGING_THAT_FIELD
|
|||||||||||||||||||||||||||||||||||||||||||||||||
The code synchronizes on interned String. private static String LOCK = "LOCK"; ... synchronized(LOCK) { ...} ... Constant Strings are interned and shared across all other classes loaded by the JVM. Thus, this could is locking on something that other code might also be locking. This could result in very strange and hard to diagnose blocking and deadlock behavior. See http://www.javalobby.org/java/forums/t96352.html and http://jira.codehaus.org/browse/JETTY-352.
findbugs:DL_SYNCHRONIZATION_ON_SHARED_CONSTANT
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This class contains similarly-named get and set methods where the set method is synchronized and the get method is not. This may result in incorrect behavior at runtime, as callers of the get method will not necessarily see a consistent state for the object. The get method should be made synchronized.
findbugs:UG_SYNC_SET_UNSYNC_GET
|
|||||||||||||||||||||||||||||||||||||||||||||||||
A field name is all in uppercase characters, which in Sun's Java naming conventions indicate a constant. However, the field is not final. Example : public class Foo { // this is bad, since someone could accidentally // do PI = 2.71828; which is actualy e // final double PI = 3.16; is ok double PI = 3.16; }
pmd:SuspiciousConstantFieldName
|
|||||||||||||||||||||||||||||||||||||||||||||||||
The method name and parameter number are suspiciously close to equals(Object), which may mean you are intending to override the equals(Object) method. Example : public class Foo { public int equals(Object o) { // oops, this probably was supposed to be boolean equals } public boolean equals(String s) { // oops, this probably was supposed to be equals(Object) } }
pmd:SuspiciousEqualsMethodName
|
|||||||||||||||||||||||||||||||||||||||||||||||||
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.
findbugs:RV_NEGATING_RESULT_OF_COMPARETO
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This Serializable class defines a non-primitive instance field which is neither transient,
Serializable, or
findbugs:SE_BAD_FIELD
|
|||||||||||||||||||||||||||||||||||||||||||||||||
Checks that package names conform to the specified format. The default value of format has been chosen to match the requirements in the Java Language specification and the Sun coding conventions. However both underscores and uppercase letters are rather uncommon, so most configurations should probably assign value ^[a-z]+(\.[a-z][a-z0-9]*)*$ to format
checkstyle:com.puppycrawl.tools.checkstyle.checks.naming.PackageNameCheck
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This class is an inner class, but does not use its embedded reference to the object which created it. This reference makes the instances of the class larger, and may keep the reference to the creator object alive longer than necessary. If possible, the class should be made into a static inner class. Since anonymous inner classes cannot be marked as static, doing this will require refactoring the inner class so that it is a named inner class.
findbugs:SIC_INNER_SHOULD_BE_STATIC_ANON
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This class is an inner class, but does not use its embedded reference to the object which created it except during construction of the inner object. This reference makes the instances of the class larger, and may keep the reference to the creator object alive longer than necessary. If possible, the class should be made into a static inner class. Since the reference to the outer object is required during construction of the inner instance, the inner class will need to be refactored so as to pass a reference to the outer instance to the constructor for the inner class.
findbugs:SIC_INNER_SHOULD_BE_STATIC_NEEDS_THIS
|
|||||||||||||||||||||||||||||||||||||||||||||||||
Code explicitly invokes garbage collection. Except for specific use in benchmarking, this is very dubious. In the past, situations where people have explicitly invoked the garbage collector in routines such as close or finalize methods has led to huge performance black holes. Garbage collection can be expensive. Any situation that forces hundreds or thousands of garbage collections will bring the machine to a crawl.
findbugs:DM_GC
|
|||||||||||||||||||||||||||||||||||||||||||||||||
A large String constant is duplicated across multiple class files. This is likely because a final field is initialized to a String constant, and the Java language mandates that all references to a final field from other classes be inlined into that classfile. See JDK bug 6447475 for a description of an occurrence of this bug in the JDK and how resolving it reduced the size of the JDK by 1 megabyte.
findbugs:HSC_HUGE_SHARED_STRING_CONSTANT
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This method or field is or uses a Map or Set of URLs. Since both the equals and hashCode
method of URL perform domain name resolution, this can result in a big performance hit.
See http://michaelscharf.blogspot.com/2006/11/javaneturlequals-and-hashcode-make.html for more information.
Consider using
findbugs:DMI_COLLECTION_OF_URLS
|
|||||||||||||||||||||||||||||||||||||||||||||||||
A boxed primitive is allocated just to call toString(). It is more effective to just use the static form of toString which takes the primitive value. So,
findbugs:DM_BOXED_PRIMITIVE_TOSTRING
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This method uses a static method from java.lang.Math on a constant value. This method's result in this case, can be determined statically, and is faster and sometimes more accurate to just use the constant. Methods detected are:
findbugs:UM_UNNECESSARY_MATH
|
|||||||||||||||||||||||||||||||||||||||||||||||||
The method seems to be building a String using concatenation in a loop. In each iteration, the String is converted to a StringBuffer/StringBuilder, appended to, and converted back to a String. This can lead to a cost quadratic in the number of iterations, as the growing string is recopied in each iteration. Better performance can be obtained by using a StringBuffer (or StringBuilder in Java 1.5) explicitly. For example: // This is bad String s = ""; for (int i = 0; i < field.length; ++i) { s = s + field[i]; } // This is better StringBuffer buf = new StringBuffer(); for (int i = 0; i < field.length; ++i) { buf.append(field[i]); } String s = buf.toString();
findbugs:SBSC_USE_STRINGBUFFER_CONCATENATION
|
|||||||||||||||||||||||||||||||||||||||||||||||||
Using
Unless the class must be compatible with JVMs predating Java 1.5,
use either autoboxing or the
findbugs:DM_FP_NUMBER_CTOR
|
|||||||||||||||||||||||||||||||||||||||||||||||||
Creating a new
findbugs:DM_STRING_VOID_CTOR
|
|||||||||||||||||||||||||||||||||||||||||||||||||
Using
Values between -128 and 127 are guaranteed to have corresponding cached instances
and using
Unless the class must be compatible with JVMs predating Java 1.5,
use either autoboxing or the
findbugs:DM_NUMBER_CTOR
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This method uses the toArray() method of a collection derived class, and passes
in a zero-length prototype array argument. It is more efficient to use
findbugs:ITA_INEFFICIENT_TO_ARRAY
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This class is an inner class, but does not use its embedded reference to the object which created it. This reference makes the instances of the class larger, and may keep the reference to the creator object alive longer than necessary. If possible, the class should be made static.
findbugs:SIC_INNER_SHOULD_BE_STATIC
|
|||||||||||||||||||||||||||||||||||||||||||||||||
The equals and hashCode
method of URL perform domain name resolution, this can result in a big performance hit.
See http://michaelscharf.blogspot.com/2006/11/javaneturlequals-and-hashcode-make.html for more information.
Consider using
findbugs:DMI_BLOCKING_METHODS_ON_URL
|
|||||||||||||||||||||||||||||||||||||||||||||||||
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.
findbugs:NP_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD
|
|||||||||||||||||||||||||||||||||||||||||||||||||
The software uses an HTTP request parameter to construct a pathname that should be within a restricted directory, but it does not properly neutralize sequences such as ".." that can resolve to a location that is outside of that directory. See http://cwe.mitre.org/data/definitions/23.html for more information. FindBugs looks only for the most blatant, obvious cases of relative path traversal. If FindBugs found any, you almost certainly have more vulnerabilities that FindBugs doesn't report. If you are concerned about relative path traversal, you should seriously consider using a commercial static analysis or pen-testing tool.
findbugs:PT_RELATIVE_PATH_TRAVERSAL
|
|||||||||||||||||||||||||||||||||||||||||||||||||
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.
findbugs:DM_DEFAULT_ENCODING
|
|||||||||||||||||||||||||||||||||||||||||||||||||
The code creates an SQL prepared statement from a nonconstant String. If unchecked, tainted data from a user is used in building this String, SQL injection could be used to make the prepared statement do something unexpected and undesirable.
findbugs:SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This code constructs an HTTP Cookie using an untrusted HTTP parameter. If this cookie is added to an HTTP response, it will allow a HTTP response splitting vulnerability. See http://en.wikipedia.org/wiki/HTTP_response_splitting for more information. FindBugs looks only for the most blatant, obvious cases of HTTP response splitting. If FindBugs found any, you almost certainly have more vulnerabilities that FindBugs doesn't report. If you are concerned about HTTP response splitting, you should seriously consider using a commercial static analysis or pen-testing tool.
findbugs:HRS_REQUEST_PARAMETER_TO_COOKIE
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This code directly writes an HTTP parameter to an HTTP header, which allows for a HTTP response splitting vulnerability. See http://en.wikipedia.org/wiki/HTTP_response_splitting for more information. FindBugs looks only for the most blatant, obvious cases of HTTP response splitting. If FindBugs found any, you almost certainly have more vulnerabilities that FindBugs doesn't report. If you are concerned about HTTP response splitting, you should seriously consider using a commercial static analysis or pen-testing tool.
findbugs:HRS_REQUEST_PARAMETER_TO_HTTP_HEADER
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This code directly writes an HTTP parameter to JSP output, which allows for a cross site scripting vulnerability. See http://en.wikipedia.org/wiki/Cross-site_scripting for more information. FindBugs looks only for the most blatant, obvious cases of cross site scripting. If FindBugs found any, you almost certainly have more cross site scripting vulnerabilities that FindBugs doesn't report. If you are concerned about cross site scripting, you should seriously consider using a commercial static analysis or pen-testing tool.
findbugs:XSS_REQUEST_PARAMETER_TO_JSP_WRITER
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This code directly writes an HTTP parameter to Servlet output, which allows for a reflected cross site scripting vulnerability. See http://en.wikipedia.org/wiki/Cross-site_scripting for more information. FindBugs looks only for the most blatant, obvious cases of cross site scripting. If FindBugs found any, you almost certainly have more cross site scripting vulnerabilities that FindBugs doesn't report. If you are concerned about cross site scripting, you should seriously consider using a commercial static analysis or pen-testing tool.
findbugs:XSS_REQUEST_PARAMETER_TO_SERVLET_WRITER
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This code directly writes an HTTP parameter to a Server error page (using HttpServletResponse.sendError). Echoing this untrusted input allows for a reflected cross site scripting vulnerability. See http://en.wikipedia.org/wiki/Cross-site_scripting for more information. FindBugs looks only for the most blatant, obvious cases of cross site scripting. If FindBugs found any, you almost certainly have more cross site scripting vulnerabilities that FindBugs doesn't report. If you are concerned about cross site scripting, you should seriously consider using a commercial static analysis or pen-testing tool.
findbugs:XSS_REQUEST_PARAMETER_TO_SEND_ERROR
|
|||||||||||||||||||||||||||||||||||||||||||||||||
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?
findbugs:SA_LOCAL_SELF_ASSIGNMENT_INSTEAD_OF_FIELD
|
|||||||||||||||||||||||||||||||||||||||||||||||||
The check to ensure that requires that comments be the only thing on a line. For the case of // comments that means that the only thing that should precede it is whitespace. It doesn't check comments if they do not end line, i.e. it accept the following: Thread.sleep( 10 <some comment here> ); Format property is intended to deal with the "} // while" example. Rationale: Steve McConnel in "Code Complete" suggests that endline comments are a bad practice. An end line comment would be one that is on the same line as actual code. For example:
Quoting "Code Complete" for the justfication:
His comments on being hard to maintain when the size of the line changes are even more important in the age of automated refactorings.
checkstyle:com.puppycrawl.tools.checkstyle.checks.TrailingCommentCheck
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This code performs an unchecked cast of the return value of a method. The code might be calling the method in such a way that the cast is guaranteed to be safe, but FindBugs is unable to verify that the cast is safe. Check that your program logic ensures that this cast will not fail.
findbugs:BC_UNCONFIRMED_CAST_OF_RETURN_VALUE
|
|||||||||||||||||||||||||||||||||||||||||||||||||
Fields in interfaces are automatically public static final, and methods are public abstract. Classes or interfaces nested in an interface are automatically public and static (all nested interfaces are automatically static). For historical reasons, modifiers which are implied by the context are accepted by the compiler, but are superfluous.
pmd:UnusedModifier
|
|||||||||||||||||||||||||||||||||||||||||||||||||
This method calls
findbugs:JML_JSR166_CALLING_WAIT_RATHER_THAN_AWAIT
|
|||||||||||||||||||||||||||||||||||||||||||||||||
Checks visibility of class members. Only static final members may be public; other class members must be private unless property protectedAllowed or packageAllowed is set.
checkstyle:com.puppycrawl.tools.checkstyle.checks.design.VisibilityModifierCheck
|
|||||||||||||||||||||||||||||||||||||||||||||||||