How to use nFloat method of td Package

Best Go-testdeep code snippet using td.nFloat

messages_en.go

Source:messages_en.go Github

copy

Full Screen

1package main2// BugDescriptionEn is bug description3var BugDescriptionEn = map[string]string{4 "CNT_ROUGH_CONSTANT_VALUE": "Rough value of known constant found\n\n<p>It's recommended to use the predefined library constant for code clarity and better precision.</p>",5 "SKIPPED_CLASS_TOO_BIG": "Class too big for analysis\n\n<p>This class is bigger than can be effectively handled, and was not fully analyzed for errors.\n</p>",6 "NOISE_NULL_DEREFERENCE": "Bogus warning about a null pointer dereference\n\n<p>Bogus warning.</p>",7 "NOISE_METHOD_CALL": "Bogus warning about a method call\n\n<p>Bogus warning.</p>",8 "NOISE_FIELD_REFERENCE": "Bogus warning about a field reference\n\n<p>Bogus warning.</p>",9 "NOISE_OPERATION": "Bogus warning about an operation\n\n<p>Bogus warning.</p>",10 "DMI_BIGDECIMAL_CONSTRUCTED_FROM_DOUBLE": "BigDecimal constructed from double that isn't represented precisely\n\n<p>\nThis code creates a BigDecimal from a double value that doesn't translate well to a\ndecimal number.\nFor example, one might assume that writing new BigDecimal(0.1) in Java creates a BigDecimal which is exactly equal to 0.1 (an unscaled value of 1, with a scale of 1), but it is actually equal to 0.1000000000000000055511151231257827021181583404541015625.\nYou probably want to use the BigDecimal.valueOf(double d) method, which uses the String representation\nof the double to create the BigDecimal (e.g., BigDecimal.valueOf(0.1) gives 0.1).\n</p>",11 "DMI_DOH": "D'oh! A nonsensical method invocation\n\n<p>\nThis partical method invocation doesn't make sense, for reasons that should be apparent from inspection.\n</p>",12 "DMI_VACUOUS_CALL_TO_EASYMOCK_METHOD": "Useless/vacuous call to EasyMock method\n\n<p>This call doesn't pass any objects to the EasyMock method, so the call doesn't do anything.\n</p>",13 "DMI_SCHEDULED_THREAD_POOL_EXECUTOR_WITH_ZERO_CORE_THREADS": "Creation of ScheduledThreadPoolExecutor with zero core threads\n\n<p>(<a href=\"http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/ScheduledThreadPoolExecutor.html#ScheduledThreadPoolExecutor%28int%29\">Javadoc</a>)\nA ScheduledThreadPoolExecutor with zero core threads will never execute anything; changes to the max pool size are ignored.\n</p>",14 "DMI_FUTILE_ATTEMPT_TO_CHANGE_MAXPOOL_SIZE_OF_SCHEDULED_THREAD_POOL_EXECUTOR": "Futile attempt to change max pool size of ScheduledThreadPoolExecutor\n\n<p>(<a href=\"http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/ScheduledThreadPoolExecutor.html\">Javadoc</a>)\nWhile 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.\n </p>",15 "DMI_UNSUPPORTED_METHOD": "Call to unsupported method\n\n<p>All targets of this method invocation throw an UnsupportedOperationException.\n</p>",16 "DMI_EMPTY_DB_PASSWORD": "Empty database password\n\n<p>This code creates a database connect using a blank or empty password. This indicates that the database is not protected by a password.\n</p>",17 "DMI_CONSTANT_DB_PASSWORD": "Hardcoded constant database password\n\n<p>This code creates a database connect using a hardcoded, constant password. Anyone with access to either the source code or the compiled code can\n easily learn the password.\n</p>",18 "HRS_REQUEST_PARAMETER_TO_COOKIE": "HTTP cookie formed from untrusted input\n\n<p>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\nvulnerability. See <a href=\"http://en.wikipedia.org/wiki/HTTP_response_splitting\">http://en.wikipedia.org/wiki/HTTP_response_splitting</a>\nfor more information.</p>\n<p>SpotBugs looks only for the most blatant, obvious cases of HTTP response splitting.\nIf SpotBugs found <em>any</em>, you <em>almost certainly</em> have more\nvulnerabilities that SpotBugs doesn't report. If you are concerned about HTTP response splitting, you should seriously\nconsider using a commercial static analysis or pen-testing tool.\n</p>",19 "HRS_REQUEST_PARAMETER_TO_HTTP_HEADER": "HTTP Response splitting vulnerability\n\n<p>This code directly writes an HTTP parameter to an HTTP header, which allows for a HTTP response splitting\nvulnerability. See <a href=\"http://en.wikipedia.org/wiki/HTTP_response_splitting\">http://en.wikipedia.org/wiki/HTTP_response_splitting</a>\nfor more information.</p>\n<p>SpotBugs looks only for the most blatant, obvious cases of HTTP response splitting.\nIf SpotBugs found <em>any</em>, you <em>almost certainly</em> have more\nvulnerabilities that SpotBugs doesn't report. If you are concerned about HTTP response splitting, you should seriously\nconsider using a commercial static analysis or pen-testing tool.\n</p>",20 "PT_RELATIVE_PATH_TRAVERSAL": "Relative path traversal in servlet\n\n<p>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.\n\nSee <a href=\"http://cwe.mitre.org/data/definitions/23.html\">http://cwe.mitre.org/data/definitions/23.html</a>\nfor more information.</p>\n<p>SpotBugs looks only for the most blatant, obvious cases of relative path traversal.\nIf SpotBugs found <em>any</em>, you <em>almost certainly</em> have more\nvulnerabilities that SpotBugs doesn't report. If you are concerned about relative path traversal, you should seriously\nconsider using a commercial static analysis or pen-testing tool.\n</p>",21 "PT_ABSOLUTE_PATH_TRAVERSAL": "Absolute path traversal in servlet\n\n<p>The software uses an HTTP request parameter to construct a pathname that should be within a restricted directory,\nbut it does not properly neutralize absolute path sequences such as \"/abs/path\" that can resolve to a location that is outside of that directory.\n\nSee <a href=\"http://cwe.mitre.org/data/definitions/36.html\">http://cwe.mitre.org/data/definitions/36.html</a>\nfor more information.</p>\n<p>SpotBugs looks only for the most blatant, obvious cases of absolute path traversal.\nIf SpotBugs found <em>any</em>, you <em>almost certainly</em> have more\nvulnerabilities that SpotBugs doesn't report. If you are concerned about absolute path traversal, you should seriously\nconsider using a commercial static analysis or pen-testing tool.\n</p>",22 "XSS_REQUEST_PARAMETER_TO_SERVLET_WRITER": "Servlet reflected cross site scripting vulnerability\n\n<p>This code directly writes an HTTP parameter to Servlet output, which allows for a reflected cross site scripting\nvulnerability. See <a href=\"http://en.wikipedia.org/wiki/Cross-site_scripting\">http://en.wikipedia.org/wiki/Cross-site_scripting</a>\nfor more information.</p>\n<p>SpotBugs looks only for the most blatant, obvious cases of cross site scripting.\nIf SpotBugs found <em>any</em>, you <em>almost certainly</em> have more cross site scripting\nvulnerabilities that SpotBugs doesn't report. If you are concerned about cross site scripting, you should seriously\nconsider using a commercial static analysis or pen-testing tool.\n</p>",23 "XSS_REQUEST_PARAMETER_TO_SEND_ERROR": "Servlet reflected cross site scripting vulnerability in error page\n\n<p>This code directly writes an HTTP parameter to a Server error page (using HttpServletResponse.sendError). Echoing this untrusted input allows\nfor a reflected cross site scripting\nvulnerability. See <a href=\"http://en.wikipedia.org/wiki/Cross-site_scripting\">http://en.wikipedia.org/wiki/Cross-site_scripting</a>\nfor more information.</p>\n<p>SpotBugs looks only for the most blatant, obvious cases of cross site scripting.\nIf SpotBugs found <em>any</em>, you <em>almost certainly</em> have more cross site scripting\nvulnerabilities that SpotBugs doesn't report. If you are concerned about cross site scripting, you should seriously\nconsider using a commercial static analysis or pen-testing tool.\n</p>",24 "XSS_REQUEST_PARAMETER_TO_JSP_WRITER": "JSP reflected cross site scripting vulnerability\n\n<p>This code directly writes an HTTP parameter to JSP output, which allows for a cross site scripting\nvulnerability. See <a href=\"http://en.wikipedia.org/wiki/Cross-site_scripting\">http://en.wikipedia.org/wiki/Cross-site_scripting</a>\nfor more information.</p>\n<p>SpotBugs looks only for the most blatant, obvious cases of cross site scripting.\nIf SpotBugs found <em>any</em>, you <em>almost certainly</em> have more cross site scripting\nvulnerabilities that SpotBugs doesn't report. If you are concerned about cross site scripting, you should seriously\nconsider using a commercial static analysis or pen-testing tool.\n</p>",25 "SW_SWING_METHODS_INVOKED_IN_SWING_THREAD": "Certain swing methods needs to be invoked in Swing thread\n\n<p>(<a href=\"http://web.archive.org/web/20090526170426/http://java.sun.com/developer/JDCTechTips/2003/tt1208.html\">From JDC Tech Tip</a>): The Swing methods\nshow(), setVisible(), and pack() will create the associated peer for the frame.\nWith the creation of the peer, the system creates the event dispatch thread.\nThis makes things problematic because the event dispatch thread could be notifying\nlisteners while pack and validate are still processing. This situation could result in\ntwo threads going through the Swing component-based GUI -- it's a serious flaw that\ncould result in deadlocks or other related threading issues. A pack call causes\ncomponents to be realized. As they are being realized (that is, not necessarily\nvisible), they could trigger listener notification on the event dispatch thread.</p>",26 "IL_INFINITE_LOOP": "An apparent infinite loop\n\n<p>This loop doesn't seem to have a way to terminate (other than by perhaps\nthrowing an exception).</p>",27 "IL_INFINITE_RECURSIVE_LOOP": "An apparent infinite recursive loop\n\n<p>This method unconditionally invokes itself. This would seem to indicate\nan infinite recursive loop that will result in a stack overflow.</p>",28 "IL_CONTAINER_ADDED_TO_ITSELF": "A collection is added to itself\n\n<p>A collection is added to itself. As a result, computing the hashCode of this\nset will throw a StackOverflowException.\n</p>",29 "VO_VOLATILE_REFERENCE_TO_ARRAY": "A volatile reference to an array doesn't treat the array elements as volatile\n\n<p>This declares a volatile reference to an array, which might not be what\nyou want. With a volatile reference to an array, reads and writes of\nthe reference to the array are treated as volatile, but the array elements\nare non-volatile. To get volatile array elements, you will need to use\none of the atomic array classes in java.util.concurrent (provided\nin Java 5.0).</p>",30 "VO_VOLATILE_INCREMENT": "An increment to a volatile field isn't atomic\n\n<p>This code increments a volatile field. Increments of volatile fields aren't\natomic. If more than one thread is incrementing the field at the same time,\nincrements could be lost.\n</p>",31 "UI_INHERITANCE_UNSAFE_GETRESOURCE": "Usage of GetResource may be unsafe if class is extended\n\n<p>Calling <code>this.getClass().getResource(...)</code> could give\nresults other than expected if this class is extended by a class in\nanother package.</p>",32 "NP_BOOLEAN_RETURN_NULL": "Method with Boolean return type returns explicit null\n\n<p>\n A method that returns either Boolean.TRUE, Boolean.FALSE or null is an accident waiting to happen.\n This method can be invoked as though it returned a value of type boolean, and\n the compiler will insert automatic unboxing of the Boolean value. If a null value is returned,\n this will result in a NullPointerException.\n </p>",33 "NP_OPTIONAL_RETURN_NULL": "Method with Optional return type returns explicit null\n\n<p>\n The usage of Optional return type (java.util.Optional or com.google.common.base.Optional)\n always means that explicit null returns were not desired by design.\n Returning a null value in such case is a contract violation and will most likely break client code.\n </p>",34 "NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR": "Non-null field is not initialized\n\n<p> The field is marked as non-null, but isn't written to by the constructor.\n The field might be initialized elsewhere during constructor, or might always\n be initialized before use.\n </p>",35 "NP_SYNC_AND_NULL_CHECK_FIELD": "Synchronize and null check on the same field.\n\n<p>Since the field is synchronized on, it seems not likely to be null.\nIf it is null and then synchronized on a NullPointerException will be\nthrown and the check would be pointless. Better to synchronize on\nanother field.</p>",36 "RpC_REPEATED_CONDITIONAL_TEST": "Repeated conditional tests\n\n<p>The code contains a conditional test is performed twice, one right after the other\n(e.g., <code>x == 0 || x == 0</code>). Perhaps the second occurrence is intended to be something else\n(e.g., <code>x == 0 || y == 0</code>).\n</p>",37 "TESTING": "Testing\n\n<p>This bug pattern is only generated by new, incompletely implemented\nbug detectors.</p>",38 "TESTING1": "Testing 1 \n\n<p>This bug pattern is only generated by new, incompletely implemented\nbug detectors.</p>",39 "TESTING2": "Testing 2\n\n<p>This bug pattern is only generated by new, incompletely implemented\nbug detectors.</p>",40 "TESTING3": "Testing 3\n\n<p>This bug pattern is only generated by new, incompletely implemented\nbug detectors.</p>",41 "UNKNOWN": "Unknown bug pattern\n\n<p>A warning was recorded, but SpotBugs can't find the description of this bug pattern\nand so can't describe it. This should occur only in cases of a bug in SpotBugs or its configuration,\nor perhaps if an analysis was generated using a plugin, but that plugin is not currently loaded.\n.</p>",42 "AM_CREATES_EMPTY_ZIP_FILE_ENTRY": "Creates an empty zip file entry\n\n<p>The code calls <code>putNextEntry()</code>, immediately\nfollowed by a call to <code>closeEntry()</code>. This results\nin an empty ZipFile entry. The contents of the entry\nshould be written to the ZipFile between the calls to\n<code>putNextEntry()</code> and\n<code>closeEntry()</code>.</p>",43 "AM_CREATES_EMPTY_JAR_FILE_ENTRY": "Creates an empty jar file entry\n\n<p>The code calls <code>putNextEntry()</code>, immediately\nfollowed by a call to <code>closeEntry()</code>. This results\nin an empty JarFile entry. The contents of the entry\nshould be written to the JarFile between the calls to\n<code>putNextEntry()</code> and\n<code>closeEntry()</code>.</p>",44 "IMSE_DONT_CATCH_IMSE": "Dubious catching of IllegalMonitorStateException\n\n<p>IllegalMonitorStateException is generally only\n thrown in case of a design flaw in your code (calling wait or\n notify on an object you do not hold a lock on).</p>",45 "FL_MATH_USING_FLOAT_PRECISION": "Method performs math using floating point precision\n\n<p>\n The method performs math operations using floating point precision.\n Floating point precision is very imprecise. For example,\n 16777216.0f + 1.0f = 16777216.0f. Consider using double math instead.</p>",46 "CAA_COVARIANT_ARRAY_FIELD": "Covariant array assignment to a field\n\n<p>Array of covariant type is assigned to a field. This is confusing and may lead to ArrayStoreException at runtime\nif the reference of some other type will be stored in this array later like in the following code:\n</p>\n<pre><code>Number[] arr = new Integer[10];\narr[0] = 1.0;\n</code></pre>\n<p>Consider changing the type of created array or the field type.</p>",47 "CAA_COVARIANT_ARRAY_LOCAL": "Covariant array assignment to a local variable\n\n<p>Array of covariant type is assigned to a local variable. This is confusing and may lead to ArrayStoreException at runtime\nif the reference of some other type will be stored in this array later like in the following code:\n</p>\n<pre><code>Number[] arr = new Integer[10];\narr[0] = 1.0;\n</code></pre>\n<p>Consider changing the type of created array or the local variable type.</p>",48 "CAA_COVARIANT_ARRAY_RETURN": "Covariant array is returned from the method\n\n<p>Array of covariant type is returned from the method. This is confusing and may lead to ArrayStoreException at runtime\nif the calling code will try to store the reference of some other type in the returned array.\n</p>\n<p>Consider changing the type of created array or the method return type.</p>",49 "CAA_COVARIANT_ARRAY_ELEMENT_STORE": "Possibly incompatible element is stored in covariant array\n\n<p>Value is stored into the array and the value type doesn't match the array type.\nIt's known from the analysis that actual array type is narrower than the declared type of its variable or field\nand this assignment doesn't satisfy the original array type. This assignment may cause ArrayStoreException\nat runtime.\n</p>",50 "CN_IDIOM": "Class implements Cloneable but does not define or use clone method\n\n<p>\n Class implements Cloneable but does not define or\n use the clone method.</p>",51 "CN_IMPLEMENTS_CLONE_BUT_NOT_CLONEABLE": "Class defines clone() but doesn't implement Cloneable\n\n<p> This class defines a clone() method but the class doesn't implement Cloneable.\nThere are some situations in which this is OK (e.g., you want to control how subclasses\ncan clone themselves), but just make sure that this is what you intended.\n</p>",52 "CN_IDIOM_NO_SUPER_CALL": "clone method does not call super.clone()\n\n<p> This non-final class defines a clone() method that does not call super.clone().\nIf this class (\"<i>A</i>\") is extended by a subclass (\"<i>B</i>\"),\nand the subclass <i>B</i> calls super.clone(), then it is likely that\n<i>B</i>'s clone() method will return an object of type <i>A</i>,\nwhich violates the standard contract for clone().</p>\n\n<p> If all clone() methods call super.clone(), then they are guaranteed\nto use Object.clone(), which always returns an object of the correct type.</p>",53 "NM_FUTURE_KEYWORD_USED_AS_IDENTIFIER": "Use of identifier that is a keyword in later versions of Java\n\n<p>The identifier is a word that is reserved as a keyword in later versions of Java, and your code will need to be changed\nin order to compile it in later versions of Java.</p>",54 "NM_FUTURE_KEYWORD_USED_AS_MEMBER_IDENTIFIER": "Use of identifier that is a keyword in later versions of Java\n\n<p>This identifier is used as a keyword in later versions of Java. This code, and\nany code that references this API,\nwill need to be changed in order to compile it in later versions of Java.</p>",55 "DE_MIGHT_DROP": "Method might drop exception\n\n<p> This method might drop an exception.&nbsp; In general, exceptions\n should be handled or reported in some way, or they should be thrown\n out of the method.</p>",56 "DE_MIGHT_IGNORE": "Method might ignore exception\n\n<p> This method might ignore an exception.&nbsp; In general, exceptions\n should be handled or reported in some way, or they should be thrown\n out of the method.</p>",57 "DP_DO_INSIDE_DO_PRIVILEGED": "Method invoked that should be only be invoked inside a doPrivileged block\n\n<p> This code invokes a method that requires a security permission check.\n If this code will be granted security permissions, but might be invoked by code that does not\n have security permissions, then the invocation needs to occur inside a doPrivileged block.</p>",58 "DP_DO_INSIDE_DO_PRIVILEDGED": "Method invoked that should be only be invoked inside a doPrivileged block\n\n<p> This code invokes a method that requires a security permission check.\n If this code will be granted security permissions, but might be invoked by code that does not\n have security permissions, then the invocation needs to occur inside a doPrivileged block.</p>",59 "DP_CREATE_CLASSLOADER_INSIDE_DO_PRIVILEGED": "Classloaders should only be created inside doPrivileged block\n\n<p> This code creates a classloader, which needs permission if a security manage is installed.\n If this code might be invoked by code that does not\n have security permissions, then the classloader creation needs to occur inside a doPrivileged block.</p>",60 "JCIP_FIELD_ISNT_FINAL_IN_IMMUTABLE_CLASS": "Fields of immutable classes should be final\n\n<p> The class is annotated with net.jcip.annotations.Immutable or javax.annotation.concurrent.Immutable,\n and the rules for those annotations require that all fields are final.\n .</p>",61 "DMI_THREAD_PASSED_WHERE_RUNNABLE_EXPECTED": "Thread passed where Runnable expected\n\n<p> A Thread object is passed as a parameter to a method where\na Runnable is expected. This is rather unusual, and may indicate a logic error\nor cause unexpected behavior.\n </p>",62 "DMI_COLLECTION_OF_URLS": "Maps and sets of URLs can be performance hogs\n\n<p> This method or field is or uses a Map or Set of URLs. Since both the equals and hashCode\nmethod of URL perform domain name resolution, this can result in a big performance hit.\nSee <a href=\"http://michaelscharf.blogspot.com/2006/11/javaneturlequals-and-hashcode-make.html\">http://michaelscharf.blogspot.com/2006/11/javaneturlequals-and-hashcode-make.html</a> for more information.\nConsider using <code>java.net.URI</code> instead.\n </p>",63 "DMI_BLOCKING_METHODS_ON_URL": "The equals and hashCode methods of URL are blocking\n\n<p> The equals and hashCode\nmethod of URL perform domain name resolution, this can result in a big performance hit.\nSee <a href=\"http://michaelscharf.blogspot.com/2006/11/javaneturlequals-and-hashcode-make.html\">http://michaelscharf.blogspot.com/2006/11/javaneturlequals-and-hashcode-make.html</a> for more information.\nConsider using <code>java.net.URI</code> instead.\n </p>",64 "DMI_ANNOTATION_IS_NOT_VISIBLE_TO_REFLECTION": "Can't use reflection to check for presence of annotation without runtime retention\n\n<p> Unless an annotation has itself been annotated with @Retention(RetentionPolicy.RUNTIME), the annotation can't be observed using reflection\n(e.g., by using the isAnnotationPresent method).\n .</p>",65 "DM_EXIT": "Method invokes System.exit(...)\n\n<p> Invoking System.exit shuts down the entire Java virtual machine. This\n should only been done when it is appropriate. Such calls make it\n hard or impossible for your code to be invoked by other code.\n Consider throwing a RuntimeException instead.</p>",66 "DM_RUN_FINALIZERS_ON_EXIT": "Method invokes dangerous method runFinalizersOnExit\n\n<p> <em>Never call System.runFinalizersOnExit\nor Runtime.runFinalizersOnExit for any reason: they are among the most\ndangerous methods in the Java libraries.</em> -- Joshua Bloch</p>",67 "DM_STRING_CTOR": "Method invokes inefficient new String(String) constructor\n\n<p> Using the <code>java.lang.String(String)</code> constructor wastes memory\n because the object so constructed will be functionally indistinguishable\n from the <code>String</code> passed as a parameter.&nbsp; Just use the\n argument <code>String</code> directly.</p>",68 "DM_STRING_VOID_CTOR": "Method invokes inefficient new String() constructor\n\n<p> Creating a new <code>java.lang.String</code> object using the\n no-argument constructor wastes memory because the object so created will\n be functionally indistinguishable from the empty string constant\n <code>\"\"</code>.&nbsp; Java guarantees that identical string constants\n will be represented by the same <code>String</code> object.&nbsp; Therefore,\n you should just use the empty string constant directly.</p>",69 "DM_STRING_TOSTRING": "Method invokes toString() method on a String\n\n<p> Calling <code>String.toString()</code> is just a redundant operation.\n Just use the String.</p>",70 "DM_GC": "Explicit garbage collection; extremely dubious except in benchmarking code\n\n<p> Code explicitly invokes garbage collection.\n Except for specific use in benchmarking, this is very dubious.</p>\n <p>In the past, situations where people have explicitly invoked\n the garbage collector in routines such as close or finalize methods\n has led to huge performance black holes. Garbage collection\n can be expensive. Any situation that forces hundreds or thousands\n of garbage collections will bring the machine to a crawl.</p>",71 "DM_BOOLEAN_CTOR": "Method invokes inefficient Boolean constructor; use Boolean.valueOf(...) instead\n\n<p> Creating new instances of <code>java.lang.Boolean</code> wastes\n memory, since <code>Boolean</code> objects are immutable and there are\n only two useful values of this type.&nbsp; Use the <code>Boolean.valueOf()</code>\n method (or Java 1.5 autoboxing) to create <code>Boolean</code> objects instead.</p>",72 "DM_NUMBER_CTOR": "Method invokes inefficient Number constructor; use static valueOf instead\n\n<p>\n Using <code>new Integer(int)</code> is guaranteed to always result in a new object whereas\n <code>Integer.valueOf(int)</code> allows caching of values to be done by the compiler, class library, or JVM.\n Using of cached values avoids object allocation and the code will be faster.\n </p>\n <p>\n Values between -128 and 127 are guaranteed to have corresponding cached instances\n and using <code>valueOf</code> is approximately 3.5 times faster than using constructor.\n For values outside the constant range the performance of both styles is the same.\n </p>\n <p>\n Unless the class must be compatible with JVMs predating Java 1.5,\n use either autoboxing or the <code>valueOf()</code> method when creating instances of\n <code>Long</code>, <code>Integer</code>, <code>Short</code>, <code>Character</code>, and <code>Byte</code>.\n </p>",73 "DM_FP_NUMBER_CTOR": "Method invokes inefficient floating-point Number constructor; use static valueOf instead\n\n<p>\n Using <code>new Double(double)</code> is guaranteed to always result in a new object whereas\n <code>Double.valueOf(double)</code> allows caching of values to be done by the compiler, class library, or JVM.\n Using of cached values avoids object allocation and the code will be faster.\n </p>\n <p>\n Unless the class must be compatible with JVMs predating Java 1.5,\n use either autoboxing or the <code>valueOf()</code> method when creating instances of <code>Double</code> and <code>Float</code>.\n </p>",74 "DM_CONVERT_CASE": "Consider using Locale parameterized version of invoked method\n\n<p> A String is being converted to upper or lowercase, using the platform's default encoding. This may\n result in improper conversions when used with international characters. Use the </p>\n <ul>\n <li>String.toUpperCase( Locale l )</li>\n <li>String.toLowerCase( Locale l )</li>\n </ul>\n <p>versions instead.</p>",75 "BX_UNBOXED_AND_COERCED_FOR_TERNARY_OPERATOR": "Primitive value is unboxed and coerced for ternary operator\n\n<p>A wrapped primitive value is unboxed and converted to another primitive type as part of the\nevaluation of a conditional ternary operator (the <code> b ? e1 : e2</code> operator). The\nsemantics of Java mandate that if <code>e1</code> and <code>e2</code> are wrapped\nnumeric values, the values are unboxed and converted/coerced to their common type (e.g,\nif <code>e1</code> is of type <code>Integer</code>\nand <code>e2</code> is of type <code>Float</code>, then <code>e1</code> is unboxed,\nconverted to a floating point value, and boxed. See JLS Section 15.25.\n</p>",76 "BX_BOXING_IMMEDIATELY_UNBOXED": "Primitive value is boxed and then immediately unboxed\n\n<p>A primitive is boxed, and then immediately unboxed. This probably is due to a manual\n boxing in a place where an unboxed value is required, thus forcing the compiler\nto immediately undo the work of the boxing.\n</p>",77 "BX_UNBOXING_IMMEDIATELY_REBOXED": "Boxed value is unboxed and then immediately reboxed\n\n<p>A boxed value is unboxed and then immediately reboxed.\n</p>",78 "BX_BOXING_IMMEDIATELY_UNBOXED_TO_PERFORM_COERCION": "Primitive value is boxed then unboxed to perform primitive coercion\n\n<p>A primitive boxed value constructed and then immediately converted into a different primitive type\n(e.g., <code>new Double(d).intValue()</code>). Just perform direct primitive coercion (e.g., <code>(int) d</code>).</p>",79 "DM_BOXED_PRIMITIVE_TOSTRING": "Method allocates a boxed primitive just to call toString\n\n<p>A boxed primitive is allocated just to call toString(). It is more effective to just use the static\n form of toString which takes the primitive value. So,</p>\n <table>\n <tr><th>Replace...</th><th>With this...</th></tr>\n <tr><td>new Integer(1).toString()</td><td>Integer.toString(1)</td></tr>\n <tr><td>new Long(1).toString()</td><td>Long.toString(1)</td></tr>\n <tr><td>new Float(1.0).toString()</td><td>Float.toString(1.0)</td></tr>\n <tr><td>new Double(1.0).toString()</td><td>Double.toString(1.0)</td></tr>\n <tr><td>new Byte(1).toString()</td><td>Byte.toString(1)</td></tr>\n <tr><td>new Short(1).toString()</td><td>Short.toString(1)</td></tr>\n <tr><td>new Boolean(true).toString()</td><td>Boolean.toString(true)</td></tr>\n </table>",80 "DM_BOXED_PRIMITIVE_FOR_PARSING": "Boxing/unboxing to parse a primitive\n\n<p>A boxed primitive is created from a String, just to extract the unboxed primitive value.\n It is more efficient to just call the static parseXXX method.</p>",81 "DM_BOXED_PRIMITIVE_FOR_COMPARE": "Boxing a primitive to compare\n\n<p>A boxed primitive is created just to call compareTo method. It's more efficient to use static compare method\n (for double and float since Java 1.4, for other primitive types since Java 1.7) which works on primitives directly.\n </p>",82 "DM_NEW_FOR_GETCLASS": "Method allocates an object, only to get the class object\n\n<p>This method allocates an object just to call getClass() on it, in order to\n retrieve the Class object for it. It is simpler to just access the .class property of the class.</p>",83 "DM_MONITOR_WAIT_ON_CONDITION": "Monitor wait() called on Condition\n\n<p>\n This method calls <code>wait()</code> on a\n <code>java.util.concurrent.locks.Condition</code> object.&nbsp;\n Waiting for a <code>Condition</code> should be done using one of the <code>await()</code>\n methods defined by the <code>Condition</code> interface.\n </p>",84 "RV_01_TO_INT": "Random value from 0 to 1 is coerced to the integer 0\n\n<p>A random value from 0 to 1 is being coerced to the integer value 0. You probably\nwant to multiply the random value by something else before coercing it to an integer, or use the <code>Random.nextInt(n)</code> method.\n</p>",85 "DM_INVALID_MIN_MAX": "Incorrect combination of Math.max and Math.min\n\n<p>This code tries to limit the value bounds using the construct like Math.min(0, Math.max(100, value)). However the order of\n the constants is incorrect: it should be Math.min(100, Math.max(0, value)). As the result this code always produces the same result\n (or NaN if the value is NaN).</p>",86 "DM_NEXTINT_VIA_NEXTDOUBLE": "Use the nextInt method of Random rather than nextDouble to generate a random integer\n\n<p>If <code>r</code> is a <code>java.util.Random</code>, you can generate a random number from <code>0</code> to <code>n-1</code>\nusing <code>r.nextInt(n)</code>, rather than using <code>(int)(r.nextDouble() * n)</code>.\n</p>\n<p>The argument to nextInt must be positive. If, for example, you want to generate a random\nvalue from -99 to 0, use <code>-r.nextInt(100)</code>.\n</p>",87 "SQL_NONCONSTANT_STRING_PASSED_TO_EXECUTE": "Nonconstant string passed to execute or addBatch method on an SQL statement\n\n<p>The method invokes the execute or addBatch method on an SQL statement with a String that seems\nto be dynamically generated. Consider using\na prepared statement instead. It is more efficient and less vulnerable to\nSQL injection attacks.\n</p>",88 "SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING": "A prepared statement is generated from a nonconstant String\n\n<p>The code creates an SQL prepared statement from a nonconstant String.\nIf unchecked, tainted data from a user is used in building this String, SQL injection could\nbe used to make the prepared statement do something unexpected and undesirable.\n</p>",89 "DM_USELESS_THREAD": "A thread was created using the default empty run method\n\n<p>This method creates a thread without specifying a run method either by deriving from the Thread class, or\n by passing a Runnable object. This thread, then, does nothing but waste time.\n</p>",90 "DC_DOUBLECHECK": "Possible double check of field\n\n<p> This method may contain an instance of double-checked locking.&nbsp;\n This idiom is not correct according to the semantics of the Java memory\n model.&nbsp; For more information, see the web page\n <a href=\"http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html\"\n >http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html</a>.</p>",91 "DC_PARTIALLY_CONSTRUCTED": "Possible exposure of partially initialized object\n\n<p>Looks like this method uses lazy field initialization with double-checked locking.\n While the field is correctly declared as volatile, it's possible that the internal structure of\n the object is changed after the field assignment, thus another thread may see the partially initialized object.</p>\n <p>To fix this problem consider storing the object into the local variable first\n and save it to the volatile field only after it's fully constructed.\n </p>",92 "FI_FINALIZER_NULLS_FIELDS": "Finalizer nulls fields\n\n<p> This finalizer nulls out fields. This is usually an error, as it does not aid garbage collection,\n and the object is going to be garbage collected anyway.</p>",93 "FI_FINALIZER_ONLY_NULLS_FIELDS": "Finalizer only nulls fields\n\n<p> This finalizer does nothing except null out fields. This is completely pointless, and requires that\nthe object be garbage collected, finalized, and then garbage collected again. You should just remove the finalize\nmethod.</p>",94 "FI_PUBLIC_SHOULD_BE_PROTECTED": "Finalizer should be protected, not public\n\n<p> A class's <code>finalize()</code> method should have protected access,\n not public.</p>",95 "FI_EMPTY": "Empty finalizer should be deleted\n\n<p> Empty <code>finalize()</code> methods are useless, so they should\n be deleted.</p>",96 "FI_NULLIFY_SUPER": "Finalizer nullifies superclass finalizer\n\n<p> This empty <code>finalize()</code> method explicitly negates the\n effect of any finalizer defined by its superclass.&nbsp; Any finalizer\n actions defined for the superclass will not be performed.&nbsp;\n Unless this is intended, delete this method.</p>",97 "FI_USELESS": "Finalizer does nothing but call superclass finalizer\n\n<p> The only thing this <code>finalize()</code> method does is call\n the superclass's <code>finalize()</code> method, making it\n redundant.&nbsp; Delete it.</p>",98 "FI_MISSING_SUPER_CALL": "Finalizer does not call superclass finalizer\n\n<p> This <code>finalize()</code> method does not make a call to its\n superclass's <code>finalize()</code> method.&nbsp; So, any finalizer\n actions defined for the superclass will not be performed.&nbsp;\n Add a call to <code>super.finalize()</code>.</p>",99 "FI_EXPLICIT_INVOCATION": "Explicit invocation of finalizer\n\n<p> This method contains an explicit invocation of the <code>finalize()</code>\n method on an object.&nbsp; Because finalizer methods are supposed to be\n executed once, and only by the VM, this is a bad idea.</p>\n<p>If a connected set of objects beings finalizable, then the VM will invoke the\nfinalize method on all the finalizable object, possibly at the same time in different threads.\nThus, it is a particularly bad idea, in the finalize method for a class X, invoke finalize\non objects referenced by X, because they may already be getting finalized in a separate thread.</p>",100 "EQ_CHECK_FOR_OPERAND_NOT_COMPATIBLE_WITH_THIS": "Equals checks for incompatible operand\n\n<p> This equals method is checking to see if the argument is some incompatible type\n(i.e., a class that is neither a supertype nor subtype of the class that defines\nthe equals method). For example, the Foo class might have an equals method\nthat looks like:\n</p>\n<pre><code>public boolean equals(Object o) {\n if (o instanceof Foo)\n return name.equals(((Foo)o).name);\n else if (o instanceof String)\n return name.equals(o);\n else return false;\n}\n</code></pre>\n\n<p>This is considered bad practice, as it makes it very hard to implement an equals method that\nis symmetric and transitive. Without those properties, very unexpected behaviors are possible.\n</p>",101 "EQ_DONT_DEFINE_EQUALS_FOR_ENUM": "Covariant equals() method defined for enum\n\n<p> This class defines an enumeration, and equality on enumerations are defined\nusing object identity. Defining a covariant equals method for an enumeration\nvalue is exceptionally bad practice, since it would likely result\nin having two different enumeration values that compare as equals using\nthe covariant enum method, and as not equal when compared normally.\nDon't do it.\n</p>",102 "EQ_SELF_USE_OBJECT": "Covariant equals() method defined, Object.equals(Object) inherited\n\n<p> This class defines a covariant version of the <code>equals()</code>\n method, but inherits the normal <code>equals(Object)</code> method\n defined in the base <code>java.lang.Object</code> class.&nbsp;\n The class should probably define a <code>boolean equals(Object)</code> method.\n </p>",103 "EQ_OTHER_USE_OBJECT": "equals() method defined that doesn't override Object.equals(Object)\n\n<p> This class defines an <code>equals()</code>\n method, that doesn't override the normal <code>equals(Object)</code> method\n defined in the base <code>java.lang.Object</code> class.&nbsp;\n The class should probably define a <code>boolean equals(Object)</code> method.\n </p>",104 "EQ_OTHER_NO_OBJECT": "equals() method defined that doesn't override equals(Object)\n\n<p> This class defines an <code>equals()</code>\n method, that doesn't override the normal <code>equals(Object)</code> method\n defined in the base <code>java.lang.Object</code> class.&nbsp; Instead, it\n inherits an <code>equals(Object)</code> method from a superclass.\n The class should probably define a <code>boolean equals(Object)</code> method.\n </p>",105 "EQ_DOESNT_OVERRIDE_EQUALS": "Class doesn't override equals in superclass\n\n<p> This class extends a class that defines an equals method and adds fields, but doesn't\ndefine an equals method itself. Thus, equality on instances of this class will\nignore the identity of the subclass and the added fields. Be sure this is what is intended,\nand that you don't need to override the equals method. Even if you don't need to override\nthe equals method, consider overriding it anyway to document the fact\nthat the equals method for the subclass just return the result of\ninvoking super.equals(o).\n </p>",106 "EQ_SELF_NO_OBJECT": "Covariant equals() method defined\n\n<p> This class defines a covariant version of <code>equals()</code>.&nbsp;\n To correctly override the <code>equals()</code> method in\n <code>java.lang.Object</code>, the parameter of <code>equals()</code>\n must have type <code>java.lang.Object</code>.</p>",107 "EQ_OVERRIDING_EQUALS_NOT_SYMMETRIC": "equals method overrides equals in superclass and may not be symmetric\n\n<p> This class defines an equals method that overrides an equals method in a superclass. Both equals methods\nmethods use <code>instanceof</code> in the determination of whether two objects are equal. This is fraught with peril,\nsince it is important that the equals method is symmetrical (in other words, <code>a.equals(b) == b.equals(a)</code>).\nIf B is a subtype of A, and A's equals method checks that the argument is an instanceof A, and B's equals method\nchecks that the argument is an instanceof B, it is quite likely that the equivalence relation defined by these\nmethods is not symmetric.\n</p>",108 "EQ_GETCLASS_AND_CLASS_CONSTANT": "equals method fails for subtypes\n\n<p> This class has an equals method that will be broken if it is inherited by subclasses.\nIt compares a class literal with the class of the argument (e.g., in class <code>Foo</code>\nit might check if <code>Foo.class == o.getClass()</code>).\nIt is better to check if <code>this.getClass() == o.getClass()</code>.\n</p>",109 "EQ_UNUSUAL": "Unusual equals method \n\n<p> This class doesn't do any of the patterns we recognize for checking that the type of the argument\nis compatible with the type of the <code>this</code> object. There might not be anything wrong with\nthis code, but it is worth reviewing.\n</p>",110 "EQ_COMPARING_CLASS_NAMES": "equals method compares class names rather than class objects\n\n<p> This method checks to see if two objects are the same class by checking to see if the names\nof their classes are equal. You can have different classes with the same name if they are loaded by\ndifferent class loaders. Just check to see if the class objects are the same.\n</p>",111 "EQ_ALWAYS_TRUE": "equals method always returns true\n\n<p> This class defines an equals method that always returns true. This is imaginative, but not very smart.\nPlus, it means that the equals method is not symmetric.\n</p>",112 "EQ_ALWAYS_FALSE": "equals method always returns false\n\n<p> 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\nthat equals is not reflexive, one of the requirements of the equals method.</p>\n<p>The likely intended semantics are object identity: that an object is equal to itself. This is the behavior inherited from class <code>Object</code>. If you need to override an equals inherited from a different\nsuperclass, you can use:</p>\n<pre><code>public boolean equals(Object o) {\n return this == o;\n}\n</code></pre>",113 "HSC_HUGE_SHARED_STRING_CONSTANT": "Huge string constants is duplicated across multiple class files\n\n<p>\n A large String constant is duplicated across multiple class files.\n This is likely because a final field is initialized to a String constant, and the Java language\n mandates that all references to a final field from other classes be inlined into\nthat classfile. See <a href=\"http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6447475\">JDK bug 6447475</a>\n for a description of an occurrence of this bug in the JDK and how resolving it reduced\n the size of the JDK by 1 megabyte.\n</p>",114 "NP_ARGUMENT_MIGHT_BE_NULL": "Method does not check for null argument\n\n<p>\n A parameter to this method has been identified as a value that should\n always be checked to see whether or not it is null, but it is being dereferenced\n without a preceding null check.\n </p>",115 "NP_EQUALS_SHOULD_HANDLE_NULL_ARGUMENT": "equals() method does not check for null argument\n\n<p>\n This implementation of equals(Object) violates the contract defined\n by java.lang.Object.equals() because it does not check for null\n being passed as the argument. All equals() methods should return\n false if passed a null value.\n </p>",116 "RV_NEGATING_RESULT_OF_COMPARETO": "Negating the result of compareTo()/compare()\n\n<p> This code negatives the return value of a compareTo or compare method.\nThis is a questionable or bad programming practice, since if the return\nvalue is Integer.MIN_VALUE, negating the return value won't\nnegate the sign of the result. You can achieve the same intended result\nby reversing the order of the operands rather than by negating the results.\n</p>",117 "CO_COMPARETO_RESULTS_MIN_VALUE": "compareTo()/compare() returns Integer.MIN_VALUE\n\n<p> In some situation, this compareTo or compare method returns\nthe constant Integer.MIN_VALUE, which is an exceptionally bad practice.\n The only thing that matters about the return value of compareTo is the sign of the result.\n But people will sometimes negate the return value of compareTo, expecting that this will negate\n the sign of the result. And it will, except in the case where the value returned is Integer.MIN_VALUE.\n So just return -1 rather than Integer.MIN_VALUE.",118 "CO_COMPARETO_INCORRECT_FLOATING": "compareTo()/compare() incorrectly handles float or double value\n\n<p>This method compares double or float values using pattern like this: val1 &gt; val2 ? 1 : val1 &lt; val2 ? -1 : 0.\nThis pattern works incorrectly for -0.0 and NaN values which may result in incorrect sorting result or broken collection\n(if compared values are used as keys). Consider using Double.compare or Float.compare static methods which handle all\nthe special cases correctly.</p>",119 "CO_SELF_NO_OBJECT": "Covariant compareTo() method defined\n\n<p> This class defines a covariant version of <code>compareTo()</code>.&nbsp;\n To correctly override the <code>compareTo()</code> method in the\n <code>Comparable</code> interface, the parameter of <code>compareTo()</code>\n must have type <code>java.lang.Object</code>.</p>",120 "HE_SIGNATURE_DECLARES_HASHING_OF_UNHASHABLE_CLASS": "Signature declares use of unhashable class in hashed construct\n\n<p> A method, field or class declares a generic signature where a non-hashable class\nis used in context where a hashable class is required.\nA class that declares an equals method but inherits a hashCode() method\nfrom Object is unhashable, since it doesn't fulfill the requirement that\nequal objects have equal hashCodes.\n</p>",121 "HE_USE_OF_UNHASHABLE_CLASS": "Use of class without a hashCode() method in a hashed data structure\n\n<p> A class defines an equals(Object) method but not a hashCode() method,\nand thus doesn't fulfill the requirement that equal objects have equal hashCodes.\nAn instance of this class is used in a hash data structure, making the need to\nfix this problem of highest importance.",122 "HE_HASHCODE_USE_OBJECT_EQUALS": "Class defines hashCode() and uses Object.equals()\n\n<p> This class defines a <code>hashCode()</code> method but inherits its\n <code>equals()</code> method from <code>java.lang.Object</code>\n (which defines equality by comparing object references).&nbsp; Although\n this will probably satisfy the contract that equal objects must have\n equal hashcodes, it is probably not what was intended by overriding\n the <code>hashCode()</code> method.&nbsp; (Overriding <code>hashCode()</code>\n implies that the object's identity is based on criteria more complicated\n than simple reference equality.)</p>\n<p>If you don't think instances of this class will ever be inserted into a HashMap/HashTable,\nthe recommended <code>hashCode</code> implementation to use is:</p>\n<pre><code>public int hashCode() {\n assert false : \"hashCode not designed\";\n return 42; // any arbitrary constant will do\n}\n</code></pre>",123 "EQ_COMPARETO_USE_OBJECT_EQUALS": "Class defines compareTo(...) and uses Object.equals()\n\n<p> This class defines a <code>compareTo(...)</code> method but inherits its\n <code>equals()</code> method from <code>java.lang.Object</code>.\n Generally, the value of compareTo should return zero if and only if\n equals returns true. If this is violated, weird and unpredictable\n failures will occur in classes such as PriorityQueue.\n In Java 5 the PriorityQueue.remove method uses the compareTo method,\n while in Java 6 it uses the equals method.</p>\n\n<p>From the JavaDoc for the compareTo method in the Comparable interface:\n<blockquote>\nIt is strongly recommended, but not strictly required that <code>(x.compareTo(y)==0) == (x.equals(y))</code>.\nGenerally speaking, any class that implements the Comparable interface and violates this condition\nshould clearly indicate this fact. The recommended language\nis \"Note: this class has a natural ordering that is inconsistent with equals.\"\n</blockquote></p>",124 "HE_HASHCODE_NO_EQUALS": "Class defines hashCode() but not equals()\n\n<p> This class defines a <code>hashCode()</code> method but not an\n <code>equals()</code> method.&nbsp; Therefore, the class may\n violate the invariant that equal objects must have equal hashcodes.</p>",125 "HE_EQUALS_USE_HASHCODE": "Class defines equals() and uses Object.hashCode()\n\n<p> This class overrides <code>equals(Object)</code>, but does not\n override <code>hashCode()</code>, and inherits the implementation of\n <code>hashCode()</code> from <code>java.lang.Object</code> (which returns\n the identity hash code, an arbitrary value assigned to the object\n by the VM).&nbsp; Therefore, the class is very likely to violate the\n invariant that equal objects must have equal hashcodes.</p>\n\n<p>If you don't think instances of this class will ever be inserted into a HashMap/HashTable,\nthe recommended <code>hashCode</code> implementation to use is:</p>\n<pre><code>public int hashCode() {\n assert false : \"hashCode not designed\";\n return 42; // any arbitrary constant will do\n}\n</code></pre>",126 "HE_INHERITS_EQUALS_USE_HASHCODE": "Class inherits equals() and uses Object.hashCode()\n\n<p> This class inherits <code>equals(Object)</code> from an abstract\n superclass, and <code>hashCode()</code> from\n<code>java.lang.Object</code> (which returns\n the identity hash code, an arbitrary value assigned to the object\n by the VM).&nbsp; Therefore, the class is very likely to violate the\n invariant that equal objects must have equal hashcodes.</p>\n\n <p>If you don't want to define a hashCode method, and/or don't\n believe the object will ever be put into a HashMap/Hashtable,\n define the <code>hashCode()</code> method\n to throw <code>UnsupportedOperationException</code>.</p>",127 "HE_EQUALS_NO_HASHCODE": "Class defines equals() but not hashCode()\n\n<p> This class overrides <code>equals(Object)</code>, but does not\n override <code>hashCode()</code>.&nbsp; Therefore, the class may violate the\n invariant that equal objects must have equal hashcodes.</p>",128 "EQ_ABSTRACT_SELF": "Abstract class defines covariant equals() method\n\n<p> This class defines a covariant version of <code>equals()</code>.&nbsp;\n To correctly override the <code>equals()</code> method in\n <code>java.lang.Object</code>, the parameter of <code>equals()</code>\n must have type <code>java.lang.Object</code>.</p>",129 "ES_COMPARING_STRINGS_WITH_EQ": "Comparison of String objects using == or !=\n\n<p>This code compares <code>java.lang.String</code> objects for reference\nequality using the == or != operators.\nUnless both strings are either constants in a source file, or have been\ninterned using the <code>String.intern()</code> method, the same string\nvalue may be represented by two different String objects. Consider\nusing the <code>equals(Object)</code> method instead.</p>",130 "ES_COMPARING_PARAMETER_STRING_WITH_EQ": "Comparison of String parameter using == or !=\n\n<p>This code compares a <code>java.lang.String</code> parameter for reference\nequality using the == or != operators. Requiring callers to\npass only String constants or interned strings to a method is unnecessarily\nfragile, and rarely leads to measurable performance gains. Consider\nusing the <code>equals(Object)</code> method instead.</p>",131 "CO_ABSTRACT_SELF": "Abstract class defines covariant compareTo() method\n\n<p> This class defines a covariant version of <code>compareTo()</code>.&nbsp;\n To correctly override the <code>compareTo()</code> method in the\n <code>Comparable</code> interface, the parameter of <code>compareTo()</code>\n must have type <code>java.lang.Object</code>.</p>",132 "IS_FIELD_NOT_GUARDED": "Field not guarded against concurrent access\n\n<p> This field is annotated with net.jcip.annotations.GuardedBy or javax.annotation.concurrent.GuardedBy,\nbut can be accessed in a way that seems to violate those annotations.</p>",133 "MSF_MUTABLE_SERVLET_FIELD": "Mutable servlet field\n\n<p>A web server generally only creates one instance of servlet or JSP class (i.e., treats\nthe class as a Singleton),\nand will\nhave multiple threads invoke methods on that instance to service multiple\nsimultaneous requests.\nThus, having a mutable instance field generally creates race conditions.",134 "IS2_INCONSISTENT_SYNC": "Inconsistent synchronization\n\n<p> The fields of this class appear to be accessed inconsistently with respect\n to synchronization.&nbsp; This bug report indicates that the bug pattern detector\n judged that\n </p>\n <ul>\n <li> The class contains a mix of locked and unlocked accesses,</li>\n <li> The class is <b>not</b> annotated as javax.annotation.concurrent.NotThreadSafe,</li>\n <li> At least one locked access was performed by one of the class's own methods, and</li>\n <li> The number of unsynchronized field accesses (reads and writes) was no more than\n one third of all accesses, with writes being weighed twice as high as reads</li>\n </ul>\n\n <p> A typical bug matching this bug pattern is forgetting to synchronize\n one of the methods in a class that is intended to be thread-safe.</p>\n\n <p> You can select the nodes labeled \"Unsynchronized access\" to show the\n code locations where the detector believed that a field was accessed\n without synchronization.</p>\n\n <p> Note that there are various sources of inaccuracy in this detector;\n for example, the detector cannot statically detect all situations in which\n a lock is held.&nbsp; Also, even when the detector is accurate in\n distinguishing locked vs. unlocked accesses, the code in question may still\n be correct.</p>",135 "NN_NAKED_NOTIFY": "Naked notify\n\n<p> A call to <code>notify()</code> or <code>notifyAll()</code>\n was made without any (apparent) accompanying\n modification to mutable object state.&nbsp; In general, calling a notify\n method on a monitor is done because some condition another thread is\n waiting for has become true.&nbsp; However, for the condition to be meaningful,\n it must involve a heap object that is visible to both threads.</p>\n\n <p> This bug does not necessarily indicate an error, since the change to\n mutable object state may have taken place in a method which then called\n the method containing the notification.</p>",136 "MS_EXPOSE_REP": "Public static method may expose internal representation by returning array\n\n<p> A public static method returns a reference to\n an array that is part of the static state of the class.\n Any code that calls this method can freely modify\n the underlying array.\n One fix is to return a copy of the array.</p>",137 "EI_EXPOSE_REP": "May expose internal representation by returning reference to mutable object\n\n<p> Returning a reference to a mutable object value stored in one of the object's fields\n exposes the internal representation of the object.&nbsp;\n If instances\n are accessed by untrusted code, and unchecked changes to\n the mutable object would compromise security or other\n important properties, you will need to do something different.\n Returning a new copy of the object is better approach in many situations.</p>",138 "EI_EXPOSE_REP2": "May expose internal representation by incorporating reference to mutable object\n\n<p> This code stores a reference to an externally mutable object into the\n internal representation of the object.&nbsp;\n If instances\n are accessed by untrusted code, and unchecked changes to\n the mutable object would compromise security or other\n important properties, you will need to do something different.\n Storing a copy of the object is better approach in many situations.</p>",139 "EI_EXPOSE_STATIC_REP2": "May expose internal static state by storing a mutable object into a static field\n\n<p> This code stores a reference to an externally mutable object into a static\n field.\n If unchecked changes to\n the mutable object would compromise security or other\n important properties, you will need to do something different.\n Storing a copy of the object is better approach in many situations.</p>",140 "RU_INVOKE_RUN": "Invokes run on a thread (did you mean to start it instead?)\n\n<p> This method explicitly invokes <code>run()</code> on an object.&nbsp;\n In general, classes implement the <code>Runnable</code> interface because\n they are going to have their <code>run()</code> method invoked in a new thread,\n in which case <code>Thread.start()</code> is the right method to call.</p>",141 "SP_SPIN_ON_FIELD": "Method spins on field\n\n<p> This method spins in a loop which reads a field.&nbsp; The compiler\n may legally hoist the read out of the loop, turning the code into an\n infinite loop.&nbsp; The class should be changed so it uses proper\n synchronization (including wait and notify calls).</p>",142 "NS_DANGEROUS_NON_SHORT_CIRCUIT": "Potentially dangerous use of non-short-circuit logic\n\n<p> This code seems to be using non-short-circuit logic (e.g., &amp;\nor |)\nrather than short-circuit logic (&amp;&amp; or ||). In addition,\nit seem possible that, depending on the value of the left hand side, you might not\nwant to evaluate the right hand side (because it would have side effects, could cause an exception\nor could be expensive.</p>\n<p>\nNon-short-circuit logic causes both sides of the expression\nto be evaluated even when the result can be inferred from\nknowing the left-hand side. This can be less efficient and\ncan result in errors if the left-hand side guards cases\nwhen evaluating the right-hand side can generate an error.\n</p>\n\n<p>See <a href=\"https://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.22.2\">the Java\nLanguage Specification</a> for details.\n\n</p>",143 "NS_NON_SHORT_CIRCUIT": "Questionable use of non-short-circuit logic\n\n<p> This code seems to be using non-short-circuit logic (e.g., &amp;\nor |)\nrather than short-circuit logic (&amp;&amp; or ||).\nNon-short-circuit logic causes both sides of the expression\nto be evaluated even when the result can be inferred from\nknowing the left-hand side. This can be less efficient and\ncan result in errors if the left-hand side guards cases\nwhen evaluating the right-hand side can generate an error.\n\n<p>See <a href=\"https://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.22.2\">the Java\nLanguage Specification</a> for details.\n\n</p>",144 "TLW_TWO_LOCK_WAIT": "Wait with two locks held\n\n<p> Waiting on a monitor while two locks are held may cause\n deadlock.\n &nbsp;\n Performing a wait only releases the lock on the object\n being waited on, not any other locks.\n &nbsp;\nThis not necessarily a bug, but is worth examining\n closely.</p>",145 "TLW_TWO_LOCK_NOTIFY": "Notify with two locks held\n\n<p> The code calls notify() or notifyAll() while two locks\n are held. If this notification is intended to wake up a wait()\n that is holding the same locks, it may deadlock, since the wait\n will only give up one lock and the notify will be unable to get both locks,\n and thus the notify will not succeed.\n &nbsp; If there is also a warning about a two lock wait, the\n probably of a bug is quite high.\n</p>",146 "UW_UNCOND_WAIT": "Unconditional wait\n\n<p> This method contains a call to <code>java.lang.Object.wait()</code> which\n is not guarded by conditional control flow.&nbsp; The code should\n verify that condition it intends to wait for is not already satisfied\n before calling wait; any previous notifications will be ignored.\n </p>",147 "UR_UNINIT_READ": "Uninitialized read of field in constructor\n\n<p> This constructor reads a field which has not yet been assigned a value.&nbsp;\n This is often caused when the programmer mistakenly uses the field instead\n of one of the constructor's parameters.</p>",148 "UR_UNINIT_READ_CALLED_FROM_SUPER_CONSTRUCTOR": "Uninitialized read of field method called from constructor of superclass\n\n<p> This method is invoked in the constructor of the superclass. At this point,\n the fields of the class have not yet initialized.</p>\n<p>To make this more concrete, consider the following classes:</p>\n<pre><code>abstract class A {\n int hashCode;\n abstract Object getValue();\n\n A() {\n hashCode = getValue().hashCode();\n }\n}\n\nclass B extends A {\n Object value;\n\n B(Object v) {\n this.value = v;\n }\n\n Object getValue() {\n return value;\n }\n}\n</code></pre>\n<p>When a <code>B</code> is constructed,\nthe constructor for the <code>A</code> class is invoked\n<em>before</em> the constructor for <code>B</code> sets <code>value</code>.\nThus, when the constructor for <code>A</code> invokes <code>getValue</code>,\nan uninitialized value is read for <code>value</code>.\n</p>",149 "UG_SYNC_SET_UNSYNC_GET": "Unsynchronized get method, synchronized set method\n\n<p> This class contains similarly-named get and set\n methods where the set method is synchronized and the get method is not.&nbsp;\n This may result in incorrect behavior at runtime, as callers of the get\n method will not necessarily see a consistent state for the object.&nbsp;\n The get method should be made synchronized.</p>",150 "IC_INIT_CIRCULARITY": "Initialization circularity\n\n<p> A circularity was detected in the static initializers of the two\n classes referenced by the bug instance.&nbsp; Many kinds of unexpected\n behavior may arise from such circularity.</p>",151 "IC_SUPERCLASS_USES_SUBCLASS_DURING_INITIALIZATION": "Superclass uses subclass during initialization\n\n<p> During the initialization of a class, the class makes an active use of a subclass.\nThat subclass will not yet be initialized at the time of this use.\nFor example, in the following code, <code>foo</code> will be null.</p>\n<pre><code>public class CircularClassInitialization {\n static class InnerClassSingleton extends CircularClassInitialization {\n static InnerClassSingleton singleton = new InnerClassSingleton();\n }\n\n static CircularClassInitialization foo = InnerClassSingleton.singleton;\n}\n</code></pre>",152 "IT_NO_SUCH_ELEMENT": "Iterator next() method can't throw NoSuchElementException\n\n<p> This class implements the <code>java.util.Iterator</code> interface.&nbsp;\n However, its <code>next()</code> method is not capable of throwing\n <code>java.util.NoSuchElementException</code>.&nbsp; The <code>next()</code>\n method should be changed so it throws <code>NoSuchElementException</code>\n if is called when there are no more elements to return.</p>",153 "DL_SYNCHRONIZATION_ON_SHARED_CONSTANT": "Synchronization on interned String \n\n<p> The code synchronizes on interned String.</p>\n<pre><code>private static String LOCK = \"LOCK\";\n...\nsynchronized(LOCK) {\n ...\n}\n...\n</code></pre>\n<p>Constant Strings are interned and shared across all other classes loaded by the JVM. Thus, this code\nis locking on something that other code might also be locking. This could result in very strange and hard to diagnose\nblocking and deadlock behavior. See <a href=\"http://www.javalobby.org/java/forums/t96352.html\">http://www.javalobby.org/java/forums/t96352.html</a> and <a href=\"http://jira.codehaus.org/browse/JETTY-352\">http://jira.codehaus.org/browse/JETTY-352</a>.\n</p>\n<p>See CERT <a href=\"https://www.securecoding.cert.org/confluence/display/java/CON08-J.+Do+not+synchronize+on+objects+that+may+be+reused\">CON08-J. Do not synchronize on objects that may be reused</a> for more information.</p>",154 "DL_SYNCHRONIZATION_ON_BOOLEAN": "Synchronization on Boolean\n\n<p> The code synchronizes on a boxed primitive constant, such as a Boolean.</p>\n<pre><code>private static Boolean inited = Boolean.FALSE;\n...\nsynchronized(inited) {\n if (!inited) {\n init();\n inited = Boolean.TRUE;\n }\n}\n...\n</code></pre>\n<p>Since there normally exist only two Boolean objects, this code could be synchronizing on the same object as other, unrelated code, leading to unresponsiveness\nand possible deadlock.</p>\n<p>See CERT <a href=\"https://www.securecoding.cert.org/confluence/display/java/CON08-J.+Do+not+synchronize+on+objects+that+may+be+reused\">CON08-J. Do not synchronize on objects that may be reused</a> for more information.</p>",155 "DL_SYNCHRONIZATION_ON_UNSHARED_BOXED_PRIMITIVE": "Synchronization on boxed primitive values\n\n<p> The code synchronizes on an apparently unshared boxed primitive,\nsuch as an Integer.</p>\n<pre><code>private static final Integer fileLock = new Integer(1);\n...\nsynchronized(fileLock) {\n .. do something ..\n}\n...\n</code></pre>\n<p>It would be much better, in this code, to redeclare fileLock as</p>\n<pre><code>private static final Object fileLock = new Object();\n</code></pre>\n<p>\nThe existing code might be OK, but it is confusing and a\nfuture refactoring, such as the \"Remove Boxing\" refactoring in IntelliJ,\nmight replace this with the use of an interned Integer object shared\nthroughout the JVM, leading to very confusing behavior and potential deadlock.\n</p>",156 "DL_SYNCHRONIZATION_ON_BOXED_PRIMITIVE": "Synchronization on boxed primitive\n\n<p> The code synchronizes on a boxed primitive constant, such as an Integer.</p>\n<pre><code>private static Integer count = 0;\n...\nsynchronized(count) {\n count++;\n}\n...\n</code></pre>\n<p>Since Integer objects can be cached and shared,\nthis code could be synchronizing on the same object as other, unrelated code, leading to unresponsiveness\nand possible deadlock.</p>\n<p>See CERT <a href=\"https://www.securecoding.cert.org/confluence/display/java/CON08-J.+Do+not+synchronize+on+objects+that+may+be+reused\">CON08-J. Do not synchronize on objects that may be reused</a> for more information.</p>",157 "ESync_EMPTY_SYNC": "Empty synchronized block\n\n<p> The code contains an empty synchronized block:</p>\n<pre><code>synchronized() {\n}\n</code></pre>\n<p>Empty synchronized blocks are far more subtle and hard to use correctly\nthan most people recognize, and empty synchronized blocks\nare almost never a better solution\nthan less contrived solutions.\n</p>",158 "IS_INCONSISTENT_SYNC": "Inconsistent synchronization\n\n<p> The fields of this class appear to be accessed inconsistently with respect\n to synchronization.&nbsp; This bug report indicates that the bug pattern detector\n judged that\n </p>\n <ul>\n <li> The class contains a mix of locked and unlocked accesses,</li>\n <li> At least one locked access was performed by one of the class's own methods, and</li>\n <li> The number of unsynchronized field accesses (reads and writes) was no more than\n one third of all accesses, with writes being weighed twice as high as reads</li>\n </ul>\n\n <p> A typical bug matching this bug pattern is forgetting to synchronize\n one of the methods in a class that is intended to be thread-safe.</p>\n\n <p> Note that there are various sources of inaccuracy in this detector;\n for example, the detector cannot statically detect all situations in which\n a lock is held.&nbsp; Also, even when the detector is accurate in\n distinguishing locked vs. unlocked accesses, the code in question may still\n be correct.</p>",159 "ML_SYNC_ON_FIELD_TO_GUARD_CHANGING_THAT_FIELD": "Synchronization on field in futile attempt to guard that field\n\n<p> This method synchronizes on a field in what appears to be an attempt\nto guard against simultaneous updates to that field. But guarding a field\ngets a lock on the referenced object, not on the field. This may not\nprovide the mutual exclusion you need, and other threads might\nbe obtaining locks on the referenced objects (for other purposes). An example\nof this pattern would be:</p>\n<pre><code>private Long myNtfSeqNbrCounter = new Long(0);\nprivate Long getNotificationSequenceNumber() {\n Long result = null;\n synchronized(myNtfSeqNbrCounter) {\n result = new Long(myNtfSeqNbrCounter.longValue() + 1);\n myNtfSeqNbrCounter = new Long(result.longValue());\n }\n return result;\n}\n</code></pre>",160 "ML_SYNC_ON_UPDATED_FIELD": "Method synchronizes on an updated field\n\n<p> This method synchronizes on an object\n referenced from a mutable field.\n This is unlikely to have useful semantics, since different\nthreads may be synchronizing on different objects.</p>",161 "MS_OOI_PKGPROTECT": "Field should be moved out of an interface and made package protected\n\n<p>\n A final static field that is\ndefined in an interface references a mutable\n object such as an array or hashtable.\n This mutable object could\n be changed by malicious code or\n by accident from another package.\n To solve this, the field needs to be moved to a class\n and made package protected\n to avoid\n this vulnerability.</p>",162 "MS_FINAL_PKGPROTECT": "Field should be both final and package protected\n\n<p>\n A mutable static field could be changed by malicious code or\n by accident from another package.\n The field could be made package protected and/or made final\n to avoid\n this vulnerability.</p>",163 "MS_SHOULD_BE_REFACTORED_TO_BE_FINAL": "Field isn't final but should be refactored to be so\n\n<p>\nThis static field public but not final, and\ncould be changed by malicious code or\nby accident from another package.\nThe field could be made final to avoid\nthis vulnerability. However, the static initializer contains more than one write\nto the field, so doing so will require some refactoring.\n</p>",164 "MS_SHOULD_BE_FINAL": "Field isn't final but should be\n\n<p>\nThis static field public but not final, and\ncould be changed by malicious code or\n by accident from another package.\n The field could be made final to avoid\n this vulnerability.</p>",165 "MS_PKGPROTECT": "Field should be package protected\n\n<p> A mutable static field could be changed by malicious code or\n by accident.\n The field could be made package protected to avoid\n this vulnerability.</p>",166 "MS_MUTABLE_HASHTABLE": "Field is a mutable Hashtable\n\n<p>A final static field references a Hashtable\n and can be accessed by malicious code or\n by accident from another package.\n This code can freely modify the contents of the Hashtable.</p>",167 "MS_MUTABLE_COLLECTION": "Field is a mutable collection\n\n<p>A mutable collection instance is assigned to a final static field,\n thus can be changed by malicious code or by accident from another package.\n Consider wrapping this field into Collections.unmodifiableSet/List/Map/etc.\n to avoid this vulnerability.</p>",168 "MS_MUTABLE_COLLECTION_PKGPROTECT": "Field is a mutable collection which should be package protected\n\n<p>A mutable collection instance is assigned to a final static field,\n thus can be changed by malicious code or by accident from another package.\n The field could be made package protected to avoid this vulnerability.\n Alternatively you may wrap this field into Collections.unmodifiableSet/List/Map/etc.\n to avoid this vulnerability.</p>",169 "MS_MUTABLE_ARRAY": "Field is a mutable array\n\n<p> A final static field references an array\n and can be accessed by malicious code or\n by accident from another package.\n This code can freely modify the contents of the array.</p>",170 "MS_CANNOT_BE_FINAL": "Field isn't final and can't be protected from malicious code\n\n<p>\n A mutable static field could be changed by malicious code or\n by accident from another package.\n Unfortunately, the way the field is used doesn't allow\n any easy fix to this problem.</p>",171 "ME_MUTABLE_ENUM_FIELD": "Enum field is public and mutable\n\n<p>A mutable public field is defined inside a public enum, thus can be changed by malicious code or by accident from another package.\n Though mutable enum fields may be used for lazy initialization, it's a bad practice to expose them to the outer world.\n Consider declaring this field final and/or package-private.</p>",172 "ME_ENUM_FIELD_SETTER": "Public enum method unconditionally sets its field\n\n<p>This public method declared in public enum unconditionally sets enum field, thus this field can be changed by malicious code\n or by accident from another package. Though mutable enum fields may be used for lazy initialization, it's a bad practice to expose them to the outer world.\n Consider removing this method or declaring it package-private.</p>",173 "IA_AMBIGUOUS_INVOCATION_OF_INHERITED_OR_OUTER_METHOD": "Potentially ambiguous invocation of either an inherited or outer method\n\n<p>\nAn inner class is invoking a method that could be resolved to either a inherited method or a method defined in an outer class.\nFor example, you invoke <code>foo(17)</code>, which is defined in both a superclass and in an outer method.\nBy the Java semantics,\nit will be resolved to invoke the inherited method, but this may not be what\nyou intend.\n</p>\n<p>If you really intend to invoke the inherited method,\ninvoke it by invoking the method on super (e.g., invoke super.foo(17)), and\nthus it will be clear to other readers of your code and to SpotBugs\nthat you want to invoke the inherited method, not the method in the outer class.\n</p>\n<p>If you call <code>this.foo(17)</code>, then the inherited method will be invoked. However, since SpotBugs only looks at\nclassfiles, it\ncan't tell the difference between an invocation of <code>this.foo(17)</code> and <code>foo(17)</code>, it will still\ncomplain about a potential ambiguous invocation.\n</p>",174 "NM_SAME_SIMPLE_NAME_AS_SUPERCLASS": "Class names shouldn't shadow simple name of superclass\n\n<p> This class has a simple name that is identical to that of its superclass, except\nthat its superclass is in a different package (e.g., <code>alpha.Foo</code> extends <code>beta.Foo</code>).\nThis can be exceptionally confusing, create lots of situations in which you have to look at import statements\nto resolve references and creates many\nopportunities to accidentally define methods that do not override methods in their superclasses.\n</p>",175 "NM_SAME_SIMPLE_NAME_AS_INTERFACE": "Class names shouldn't shadow simple name of implemented interface\n\n<p> This class/interface has a simple name that is identical to that of an implemented/extended interface, except\nthat the interface is in a different package (e.g., <code>alpha.Foo</code> extends <code>beta.Foo</code>).\nThis can be exceptionally confusing, create lots of situations in which you have to look at import statements\nto resolve references and creates many\nopportunities to accidentally define methods that do not override methods in their superclasses.\n</p>",176 "NM_CLASS_NAMING_CONVENTION": "Class names should start with an upper case letter\n\n<p> 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).\n</p>",177 "NM_METHOD_NAMING_CONVENTION": "Method names should start with a lower case letter\n\n<p>\nMethods should be verbs, in mixed case with the first letter lowercase, with the first letter of each internal word capitalized.\n</p>",178 "NM_FIELD_NAMING_CONVENTION": "Field names should start with a lower case letter\n\n<p>\nNames of fields that are not final should be in mixed case with a lowercase first letter and the first letters of subsequent words capitalized.\n</p>",179 "NM_VERY_CONFUSING": "Very confusing method names\n\n<p> The referenced methods have names that differ only by capitalization.\nThis is very confusing because if the capitalization were\nidentical then one of the methods would override the other.\n</p>",180 "NM_VERY_CONFUSING_INTENTIONAL": "Very confusing method names (but perhaps intentional)\n\n<p> The referenced methods have names that differ only by capitalization.\nThis is very confusing because if the capitalization were\nidentical then one of the methods would override the other. From the existence of other methods, it\nseems that the existence of both of these methods is intentional, but is sure is confusing.\nYou should try hard to eliminate one of them, unless you are forced to have both due to frozen APIs.\n</p>",181 "NM_WRONG_PACKAGE": "Method doesn't override method in superclass due to wrong package for parameter\n\n<p> The method in the subclass doesn't override a similar method in a superclass because the type of a parameter doesn't exactly match\nthe type of the corresponding parameter in the superclass. For example, if you have:</p>\n<pre><code>import alpha.Foo;\n\npublic class A {\n public int f(Foo x) { return 17; }\n}\n----\nimport beta.Foo;\n\npublic class B extends A {\n public int f(Foo x) { return 42; }\n}\n</code></pre>\n<p>The <code>f(Foo)</code> method defined in class <code>B</code> doesn't\noverride the\n<code>f(Foo)</code> method defined in class <code>A</code>, because the argument\ntypes are <code>Foo</code>'s from different packages.\n</p>",182 "NM_WRONG_PACKAGE_INTENTIONAL": "Method doesn't override method in superclass due to wrong package for parameter\n\n<p> The method in the subclass doesn't override a similar method in a superclass because the type of a parameter doesn't exactly match\nthe type of the corresponding parameter in the superclass. For example, if you have:</p>\n<pre><code>import alpha.Foo;\n\npublic class A {\n public int f(Foo x) { return 17; }\n}\n----\nimport beta.Foo;\n\npublic class B extends A {\n public int f(Foo x) { return 42; }\n public int f(alpha.Foo x) { return 27; }\n}\n</code></pre>\n<p>The <code>f(Foo)</code> method defined in class <code>B</code> doesn't\noverride the\n<code>f(Foo)</code> method defined in class <code>A</code>, because the argument\ntypes are <code>Foo</code>'s from different packages.\n</p>\n\n<p>In this case, the subclass does define a method with a signature identical to the method in the superclass,\nso this is presumably understood. However, such methods are exceptionally confusing. You should strongly consider\nremoving or deprecating the method with the similar but not identical signature.\n</p>",183 "NM_CONFUSING": "Confusing method names\n\n<p> The referenced methods have names that differ only by capitalization.</p>",184 "NM_METHOD_CONSTRUCTOR_CONFUSION": "Apparent method/constructor confusion\n\n<p> 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.\n If it was intended to be a constructor, remove the declaration of a void return value.\n If you had accidentally defined this method, realized the mistake, defined a proper constructor\n but can't get rid of this method due to backwards compatibility, deprecate the method.\n</p>",185 "NM_LCASE_HASHCODE": "Class defines hashcode(); should it be hashCode()?\n\n<p> This class defines a method called <code>hashcode()</code>.&nbsp; This method\n does not override the <code>hashCode()</code> method in <code>java.lang.Object</code>,\n which is probably what was intended.</p>",186 "NM_LCASE_TOSTRING": "Class defines tostring(); should it be toString()?\n\n<p> This class defines a method called <code>tostring()</code>.&nbsp; This method\n does not override the <code>toString()</code> method in <code>java.lang.Object</code>,\n which is probably what was intended.</p>",187 "NM_BAD_EQUAL": "Class defines equal(Object); should it be equals(Object)?\n\n<p> This class defines a method <code>equal(Object)</code>.&nbsp; This method does\nnot override the <code>equals(Object)</code> method in <code>java.lang.Object</code>,\nwhich is probably what was intended.</p>",188 "NM_CLASS_NOT_EXCEPTION": "Class is not derived from an Exception, even though it is named as such\n\n<p> This class is not derived from another exception, but ends with 'Exception'. This will\nbe confusing to users of this class.</p>",189 "RR_NOT_CHECKED": "Method ignores results of InputStream.read()\n\n<p> This method ignores the return value of one of the variants of\n <code>java.io.InputStream.read()</code> which can return multiple bytes.&nbsp;\n If the return value is not checked, the caller will not be able to correctly\n handle the case where fewer bytes were read than the caller requested.&nbsp;\n This is a particularly insidious kind of bug, because in many programs,\n reads from input streams usually do read the full amount of data requested,\n causing the program to fail only sporadically.</p>",190 "SR_NOT_CHECKED": "Method ignores results of InputStream.skip()\n\n<p> This method ignores the return value of\n <code>java.io.InputStream.skip()</code> which can skip multiple bytes.&nbsp;\n If the return value is not checked, the caller will not be able to correctly\n handle the case where fewer bytes were skipped than the caller requested.&nbsp;\n This is a particularly insidious kind of bug, because in many programs,\n skips from input streams usually do skip the full amount of data requested,\n causing the program to fail only sporadically. With Buffered streams, however,\n skip() will only skip data in the buffer, and will routinely fail to skip the\n requested number of bytes.</p>",191 "SE_READ_RESOLVE_IS_STATIC": "The readResolve method must not be declared as a static method. \n\n<p> In order for the readResolve method to be recognized by the serialization\nmechanism, it must not be declared as a static method.\n</p>",192 "SE_PRIVATE_READ_RESOLVE_NOT_INHERITED": "Private readResolve method not inherited by subclasses\n\n<p> This class defines a private readResolve method. Since it is private, it won't be inherited by subclasses.\nThis might be intentional and OK, but should be reviewed to ensure it is what is intended.\n</p>",193 "SE_READ_RESOLVE_MUST_RETURN_OBJECT": "The readResolve method must be declared with a return type of Object. \n\n<p> In order for the readResolve method to be recognized by the serialization\nmechanism, it must be declared to have a return type of Object.\n</p>",194 "SE_TRANSIENT_FIELD_OF_NONSERIALIZABLE_CLASS": "Transient field of class that isn't Serializable. \n\n<p> The field is marked as transient, but the class isn't Serializable, so marking it as transient\nhas absolutely no effect.\nThis may be leftover marking from a previous version of the code in which the class was transient, or\nit may indicate a misunderstanding of how serialization works.\n</p>",195 "SE_TRANSIENT_FIELD_NOT_RESTORED": "Transient field that isn't set by deserialization. \n\n<p> 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\ndeserialized instance of the class.\n</p>",196 "SE_METHOD_MUST_BE_PRIVATE": "Method must be private in order for serialization to work\n\n<p> This class implements the <code>Serializable</code> interface, and defines a method\n for custom serialization/deserialization. But since that method isn't declared private,\n it will be silently ignored by the serialization/deserialization API.</p>",197 "SE_NO_SUITABLE_CONSTRUCTOR_FOR_EXTERNALIZATION": "Class is Externalizable but doesn't define a void constructor\n\n<p> This class implements the <code>Externalizable</code> interface, but does\n not define a void constructor. When Externalizable objects are deserialized,\n they first need to be constructed by invoking the void\n constructor. Since this class does not have one,\n serialization and deserialization will fail at runtime.</p>",198 "SE_NO_SUITABLE_CONSTRUCTOR": "Class is Serializable but its superclass doesn't define a void constructor\n\n<p> This class implements the <code>Serializable</code> interface\n and its superclass does not. When such an object is deserialized,\n the fields of the superclass need to be initialized by\n invoking the void constructor of the superclass.\n Since the superclass does not have one,\n serialization and deserialization will fail at runtime.</p>",199 "SE_NO_SERIALVERSIONID": "Class is Serializable, but doesn't define serialVersionUID\n\n<p> This class implements the <code>Serializable</code> interface, but does\n not define a <code>serialVersionUID</code> field.&nbsp;\n A change as simple as adding a reference to a .class object\n will add synthetic fields to the class,\n which will unfortunately change the implicit\n serialVersionUID (e.g., adding a reference to <code>String.class</code>\n will generate a static field <code>class$java$lang$String</code>).\n Also, different source code to bytecode compilers may use different\n naming conventions for synthetic variables generated for\n references to class objects or inner classes.\n To ensure interoperability of Serializable across versions,\n consider adding an explicit serialVersionUID.</p>",200 "SE_COMPARATOR_SHOULD_BE_SERIALIZABLE": "Comparator doesn't implement Serializable\n\n<p> This class implements the <code>Comparator</code> interface. You\nshould consider whether or not it should also implement the <code>Serializable</code>\ninterface. If a comparator is used to construct an ordered collection\nsuch as a <code>TreeMap</code>, then the <code>TreeMap</code>\nwill be serializable only if the comparator is also serializable.\nAs most comparators have little or no state, making them serializable\nis generally easy and good defensive programming.\n</p>",201 "SF_SWITCH_FALLTHROUGH": "Switch statement found where one case falls through to the next case\n\n<p> This method contains a switch statement where one case branch will fall through to the next case.\n Usually you need to end this case with a break or return.</p>",202 "SF_SWITCH_NO_DEFAULT": "Switch statement found where default case is missing\n\n<p> This method contains a switch statement where default case is missing.\n Usually you need to provide a default case.</p>\n <p>Because the analysis only looks at the generated bytecode, this warning can be incorrect triggered if\nthe default case is at the end of the switch statement and the switch statement doesn't contain break statements for other\ncases.",203 "SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHROUGH": "Dead store due to switch statement fall through\n\n<p> A value stored in the previous switch case is overwritten here due to a switch fall through. It is likely that\n you forgot to put a break or return at the end of the previous case.\n</p>",204 "SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHROUGH_TO_THROW": "Dead store due to switch statement fall through to throw\n\n<p> A value stored in the previous switch case is ignored here due to a switch fall through to a place where\n an exception is thrown. It is likely that\n you forgot to put a break or return at the end of the previous case.\n</p>",205 "WS_WRITEOBJECT_SYNC": "Class's writeObject() method is synchronized but nothing else is\n\n<p> This class has a <code>writeObject()</code> method which is synchronized;\n however, no other method of the class is synchronized.</p>",206 "RS_READOBJECT_SYNC": "Class's readObject() method is synchronized\n\n<p> This serializable class defines a <code>readObject()</code> which is\n synchronized.&nbsp; By definition, an object created by deserialization\n is only reachable by one thread, and thus there is no need for\n <code>readObject()</code> to be synchronized.&nbsp; If the <code>readObject()</code>\n method itself is causing the object to become visible to another thread,\n that is an example of very dubious coding style.</p>",207 "SE_NONSTATIC_SERIALVERSIONID": "serialVersionUID isn't static\n\n<p> This class defines a <code>serialVersionUID</code> field that is not static.&nbsp;\n The field should be made static\n if it is intended to specify\n the version UID for purposes of serialization.</p>",208 "SE_NONFINAL_SERIALVERSIONID": "serialVersionUID isn't final\n\n<p> This class defines a <code>serialVersionUID</code> field that is not final.&nbsp;\n The field should be made final\n if it is intended to specify\n the version UID for purposes of serialization.</p>",209 "SE_NONLONG_SERIALVERSIONID": "serialVersionUID isn't long\n\n<p> This class defines a <code>serialVersionUID</code> field that is not long.&nbsp;\n The field should be made long\n if it is intended to specify\n the version UID for purposes of serialization.</p>",210 "SE_BAD_FIELD": "Non-transient non-serializable instance field in serializable class\n\n<p> This Serializable class defines a non-primitive instance field which is neither transient,\nSerializable, or <code>java.lang.Object</code>, and does not appear to implement\nthe <code>Externalizable</code> interface or the\n<code>readObject()</code> and <code>writeObject()</code> methods.&nbsp;\nObjects of this class will not be deserialized correctly if a non-Serializable\nobject is stored in this field.</p>",211 "SE_BAD_FIELD_INNER_CLASS": "Non-serializable class has a serializable inner class\n\n<p> This Serializable class is an inner class of a non-serializable class.\nThus, attempts to serialize it will also attempt to associate instance of the outer\nclass with which it is associated, leading to a runtime error.\n</p>\n<p>If possible, making the inner class a static inner class should solve the\nproblem. Making the outer class serializable might also work, but that would\nmean serializing an instance of the inner class would always also serialize the instance\nof the outer class, which it often not what you really want.",212 "SE_INNER_CLASS": "Serializable inner class\n\n<p> This Serializable class is an inner class. Any attempt to serialize\nit will also serialize the associated outer instance. The outer instance is serializable,\nso this won't fail, but it might serialize a lot more data than intended.\nIf possible, making the inner class a static inner class (also known as a nested class) should solve the\nproblem.",213 "SE_BAD_FIELD_STORE": "Non-serializable value stored into instance field of a serializable class\n\n<p> A non-serializable value is stored into a non-transient field\nof a serializable class.</p>",214 "SC_START_IN_CTOR": "Constructor invokes Thread.start()\n\n<p> The constructor starts a thread. This is likely to be wrong if\n the class is ever extended/subclassed, since the thread will be started\n before the subclass constructor is started.</p>",215 "SS_SHOULD_BE_STATIC": "Unread field: should this field be static?\n\n<p> This class contains an instance final field that\n is initialized to a compile-time static value.\n Consider making the field static.</p>",216 "UUF_UNUSED_FIELD": "Unused field\n\n<p> This field is never used.&nbsp; Consider removing it from the class.</p>",217 "URF_UNREAD_FIELD": "Unread field\n\n<p> This field is never read.&nbsp; Consider removing it from the class.</p>",218 "UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD": "Unused public or protected field\n\n<p> This field is never used.&nbsp;\nThe field is public or protected, so perhaps\n it is intended to be used with classes not seen as part of the analysis. If not,\nconsider removing it from the class.</p>",219 "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD": "Unread public/protected field\n\n<p> This field is never read.&nbsp;\nThe field is public or protected, so perhaps\n it is intended to be used with classes not seen as part of the analysis. If not,\nconsider removing it from the class.</p>",220 "QF_QUESTIONABLE_FOR_LOOP": "Complicated, subtle or wrong increment in for-loop \n\n<p>Are you sure this for loop is incrementing the correct variable?\n It appears that another variable is being initialized and checked\n by the for loop.\n</p>",221 "UWF_NULL_FIELD": "Field only ever set to null\n\n<p> All writes to this field are of the constant value null, and thus\nall reads of the field will return null.\nCheck for errors, or remove it if it is useless.</p>",222 "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD": "Unwritten public or protected field\n\n<p> No writes were seen to this public/protected field.&nbsp; All reads of it will return the default\nvalue. Check for errors (should it have been initialized?), or remove it if it is useless.</p>",223 "UWF_UNWRITTEN_FIELD": "Unwritten field\n\n<p> This field is never written.&nbsp; All reads of it will return the default\nvalue. Check for errors (should it have been initialized?), or remove it if it is useless.</p>",224 "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD": "Write to static field from instance method\n\n<p> This instance method writes to a static field. This is tricky to get\ncorrect if multiple instances are being manipulated,\nand generally bad practice.\n</p>",225 "NP_LOAD_OF_KNOWN_NULL_VALUE": "Load of known null value\n\n<p> The variable referenced at this point is known to be null due to an earlier\n check against null. Although this is valid, it might be a mistake (perhaps you\nintended to refer to a different variable, or perhaps the earlier check to see if the\nvariable is null should have been a check to see if it was non-null).\n</p>",226 "NP_DEREFERENCE_OF_READLINE_VALUE": "Dereference of the result of readLine() without nullcheck\n\n<p> The result of invoking readLine() is dereferenced without checking to see if the result is null. If there are no more lines of text\nto read, readLine() will return null and dereferencing that will generate a null pointer exception.\n</p>",227 "NP_IMMEDIATE_DEREFERENCE_OF_READLINE": "Immediate dereference of the result of readLine()\n\n<p> The result of invoking readLine() is immediately dereferenced. If there are no more lines of text\nto read, readLine() will return null and dereferencing that will generate a null pointer exception.\n</p>",228 "NP_UNWRITTEN_FIELD": "Read of unwritten field\n\n<p> The program is dereferencing a field that does not seem to ever have a non-null value written to it.\nUnless the field is initialized via some mechanism not seen by the analysis,\ndereferencing this value will generate a null pointer exception.\n</p>",229 "NP_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD": "Read of unwritten public or protected field\n\n<p> The program is dereferencing a public or protected\nfield that does not seem to ever have a non-null value written to it.\nUnless the field is initialized via some mechanism not seen by the analysis,\ndereferencing this value will generate a null pointer exception.\n</p>",230 "SIC_THREADLOCAL_DEADLY_EMBRACE": "Deadly embrace of non-static inner class and thread local\n\n<p> This class is an inner class, but should probably be a static inner class.\n As it is, there is a serious danger of a deadly embrace between the inner class\n and the thread local in the outer class. Because the inner class isn't static,\n it retains a reference to the outer class.\n If the thread local contains a reference to an instance of the inner\n class, the inner and outer instance will both be reachable\n and not eligible for garbage collection.\n</p>",231 "SIC_INNER_SHOULD_BE_STATIC": "Should be a static inner class\n\n<p> This class is an inner class, but does not use its embedded reference\n to the object which created it.&nbsp; This reference makes the instances\n of the class larger, and may keep the reference to the creator object\n alive longer than necessary.&nbsp; If possible, the class should be\n made static.\n</p>",232 "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR": "Field not initialized in constructor but dereferenced without null check\n\n<p> This field is never initialized within any constructor, and is therefore could be null after\nthe object is constructed. Elsewhere, it is loaded and dereferenced without a null check.\nThis could be a either an error or a questionable design, since\nit means a null pointer exception will be generated if that field is dereferenced\nbefore being initialized.\n</p>",233 "SIC_INNER_SHOULD_BE_STATIC_ANON": "Could be refactored into a named static inner class\n\n<p> This class is an inner class, but does not use its embedded reference\n to the object which created it.&nbsp; This reference makes the instances\n of the class larger, and may keep the reference to the creator object\n alive longer than necessary.&nbsp; If possible, the class should be\n made into a <em>static</em> inner class. Since anonymous inner\nclasses cannot be marked as static, doing this will require refactoring\nthe inner class so that it is a named inner class.</p>",234 "SIC_INNER_SHOULD_BE_STATIC_NEEDS_THIS": "Could be refactored into a static inner class\n\n<p> This class is an inner class, but does not use its embedded reference\n to the object which created it except during construction of the\ninner object.&nbsp; This reference makes the instances\n of the class larger, and may keep the reference to the creator object\n alive longer than necessary.&nbsp; If possible, the class should be\n made into a <em>static</em> inner class. Since the reference to the\n outer object is required during construction of the inner instance,\n the inner class will need to be refactored so as to\n pass a reference to the outer instance to the constructor\n for the inner class.</p>",235 "WA_NOT_IN_LOOP": "Wait not in loop \n\n<p> This method contains a call to <code>java.lang.Object.wait()</code>\n which is not in a loop.&nbsp; If the monitor is used for multiple conditions,\n the condition the caller intended to wait for might not be the one\n that actually occurred.</p>",236 "WA_AWAIT_NOT_IN_LOOP": "Condition.await() not in loop \n\n<p> This method contains a call to <code>java.util.concurrent.await()</code>\n (or variants)\n which is not in a loop.&nbsp; If the object is used for multiple conditions,\n the condition the caller intended to wait for might not be the one\n that actually occurred.</p>",237 "NO_NOTIFY_NOT_NOTIFYALL": "Using notify() rather than notifyAll()\n\n<p> This method calls <code>notify()</code> rather than <code>notifyAll()</code>.&nbsp;\n Java monitors are often used for multiple conditions.&nbsp; Calling <code>notify()</code>\n only wakes up one thread, meaning that the thread woken up might not be the\n one waiting for the condition that the caller just satisfied.</p>",238 "UC_USELESS_VOID_METHOD": "Useless non-empty void method\n\n<p>Our analysis shows that this non-empty void method does not actually perform any useful work.\nPlease check it: probably there's a mistake in its code or its body can be fully removed.\n</p>\n<p>We are trying to reduce the false positives as much as possible, but in some cases this warning might be wrong.\nCommon false-positive cases include:</p>\n<ul>\n<li>The method is intended to trigger loading of some class which may have a side effect.</li>\n<li>The method is intended to implicitly throw some obscure exception.</li>\n</ul>",239 "UC_USELESS_CONDITION": "Condition has no effect\n\n<p>This condition always produces the same result as the value of the involved variable that was narrowed before.\nProbably something else was meant or the condition can be removed.</p>",240 "UC_USELESS_CONDITION_TYPE": "Condition has no effect due to the variable type\n\n<p>This condition always produces the same result due to the type range of the involved variable.\nProbably something else was meant or the condition can be removed.</p>",241 "UC_USELESS_OBJECT": "Useless object created\n\n<p>Our analysis shows that this object is useless.\nIt's created and modified, but its value never go outside of the method or produce any side-effect.\nEither there is a mistake and object was intended to be used or it can be removed.</p>\n<p>This analysis rarely produces false-positives. Common false-positive cases include:</p>\n<p>- This object used to implicitly throw some obscure exception.</p>\n<p>- This object used as a stub to generalize the code.</p>\n<p>- This object used to hold strong references to weak/soft-referenced objects.</p>",242 "UC_USELESS_OBJECT_STACK": "Useless object created on stack\n\n<p>This object is created just to perform some modifications which don't have any side-effect.\nProbably something else was meant or the object can be removed.</p>",243 "RANGE_ARRAY_INDEX": "Array index is out of bounds\n\n<p> Array operation is performed, but array index is out of bounds, which will result in ArrayIndexOutOfBoundsException at runtime.</p>",244 "RANGE_ARRAY_OFFSET": "Array offset is out of bounds\n\n<p> Method is called with array parameter and offset parameter, but the offset is out of bounds. This will result in IndexOutOfBoundsException at runtime. </p>",245 "RANGE_ARRAY_LENGTH": "Array length is out of bounds\n\n<p> Method is called with array parameter and length parameter, but the length is out of bounds. This will result in IndexOutOfBoundsException at runtime. </p>",246 "RANGE_STRING_INDEX": "String index is out of bounds\n\n<p> String method is called and specified string index is out of bounds. This will result in StringIndexOutOfBoundsException at runtime. </p>",247 "RV_CHECK_FOR_POSITIVE_INDEXOF": "Method checks to see if result of String.indexOf is positive\n\n<p> The method invokes String.indexOf and checks to see if the result is positive or non-positive.\n It is much more typical to check to see if the result is negative or non-negative. It is\n positive only if the substring checked for occurs at some place other than at the beginning of\n the String.</p>",248 "RV_DONT_JUST_NULL_CHECK_READLINE": "Method discards result of readLine after checking if it is non-null\n\n<p> The value returned by readLine is discarded after checking to see if the return\nvalue is non-null. In almost all situations, if the result is non-null, you will want\nto use that non-null value. Calling readLine again will give you a different line.</p>",249 "RV_RETURN_VALUE_IGNORED_INFERRED": "Method ignores return value, is this OK?\n\n<p>This code calls a method and ignores the return value. The return value\nis the same type as the type the method is invoked on, and from our analysis it looks\nlike the return value might be important (e.g., like ignoring the\nreturn value of <code>String.toLowerCase()</code>).\n</p>\n<p>We are guessing that ignoring the return value might be a bad idea just from\na simple analysis of the body of the method. You can use a @CheckReturnValue annotation\nto instruct SpotBugs as to whether ignoring the return value of this method\nis important or acceptable.\n</p>\n<p>Please investigate this closely to decide whether it is OK to ignore the return value.\n</p>",250 "RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT": "Return value of method without side effect is ignored\n\n<p>This code calls a method and ignores the return value. However our analysis shows that\nthe method (including its implementations in subclasses if any) does not produce any effect\nother than return value. Thus this call can be removed.\n</p>\n<p>We are trying to reduce the false positives as much as possible, but in some cases this warning might be wrong.\nCommon false-positive cases include:</p>\n<p>- The method is designed to be overridden and produce a side effect in other projects which are out of the scope of the analysis.</p>\n<p>- The method is called to trigger the class loading which may have a side effect.</p>\n<p>- The method is called just to get some exception.</p>\n<p>If you feel that our assumption is incorrect, you can use a @CheckReturnValue annotation\nto instruct SpotBugs that ignoring the return value of this method is acceptable.\n</p>",251 "RV_RETURN_VALUE_IGNORED": "Method ignores return value\n\n<p> The return value of this method should be checked. One common\ncause of this warning is to invoke a method on an immutable object,\nthinking that it updates the object. For example, in the following code\nfragment,</p>\n<pre><code>String dateString = getHeaderField(name);\ndateString.trim();\n</code></pre>\n<p>the programmer seems to be thinking that the trim() method will update\nthe String referenced by dateString. But since Strings are immutable, the trim()\nfunction returns a new String value, which is being ignored here. The code\nshould be corrected to: </p>\n<pre><code>String dateString = getHeaderField(name);\ndateString = dateString.trim();\n</code></pre>",252 "RV_RETURN_VALUE_IGNORED_BAD_PRACTICE": "Method ignores exceptional return value\n\n<p> This method returns a value that is not checked. The return value should be checked\nsince it can indicate an unusual or unexpected function execution. For\nexample, the <code>File.delete()</code> method returns false\nif the file could not be successfully deleted (rather than\nthrowing an Exception).\nIf you don't check the result, you won't notice if the method invocation\nsignals unexpected behavior by returning an atypical return value.\n</p>",253 "RV_CHECK_COMPARETO_FOR_SPECIFIC_RETURN_VALUE": "Code checks for specific values returned by compareTo\n\n<p> This code invoked a compareTo or compare method, and checks to see if the return value is a specific value,\nsuch as 1 or -1. When invoking these methods, you should only check the sign of the result, not for any specific\nnon-zero value. While many or most compareTo and compare methods only return -1, 0 or 1, some of them\nwill return other values.",254 "RV_EXCEPTION_NOT_THROWN": "Exception created and dropped rather than thrown\n\n<p> This code creates an exception (or error) object, but doesn't do anything with it. For example,\nsomething like </p>\n<pre><code>if (x &lt; 0) {\n new IllegalArgumentException(\"x must be nonnegative\");\n}\n</code></pre>\n<p>It was probably the intent of the programmer to throw the created exception:</p>\n<pre><code>if (x &lt; 0) {\n throw new IllegalArgumentException(\"x must be nonnegative\");\n}\n</code></pre>",255 "NP_ALWAYS_NULL": "Null pointer dereference\n\n<p> A null pointer is dereferenced here.&nbsp; This will lead to a\n<code>NullPointerException</code> when the code is executed.</p>",256 "NP_CLOSING_NULL": "close() invoked on a value that is always null\n\n<p> close() is being invoked on a value that is always null. If this statement is executed,\na null pointer exception will occur. But the big risk here you never close\nsomething that should be closed.",257 "NP_STORE_INTO_NONNULL_FIELD": "Store of null value into field annotated @Nonnull\n\n<p> A value that could be null is stored into a field that has been annotated as @Nonnull. </p>",258 "NP_ALWAYS_NULL_EXCEPTION": "Null pointer dereference in method on exception path\n\n<p> A pointer which is null on an exception path is dereferenced here.&nbsp;\nThis will lead to a <code>NullPointerException</code> when the code is executed.&nbsp;\nNote that because SpotBugs currently does not prune infeasible exception paths,\nthis may be a false warning.</p>\n\n<p> Also note that SpotBugs considers the default case of a switch statement to\nbe an exception path, since the default case is often infeasible.</p>",259 "NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE": "Parameter must be non-null but is marked as nullable\n\n<p> This parameter is always used in a way that requires it to be non-null,\nbut the parameter is explicitly annotated as being Nullable. Either the use\nof the parameter or the annotation is wrong.\n</p>",260 "NP_NULL_ON_SOME_PATH": "Possible null pointer dereference\n\n<p> There is a branch of statement that, <em>if executed,</em> guarantees that\na null value will be dereferenced, which\nwould generate a <code>NullPointerException</code> when the code is executed.\nOf course, the problem might be that the branch or statement is infeasible and that\nthe null pointer exception can't ever be executed; deciding that is beyond the ability of SpotBugs.\n</p>",261 "NP_NULL_ON_SOME_PATH_MIGHT_BE_INFEASIBLE": "Possible null pointer dereference on branch that might be infeasible\n\n<p> There is a branch of statement that, <em>if executed,</em> guarantees that\na null value will be dereferenced, which\nwould generate a <code>NullPointerException</code> when the code is executed.\nOf course, the problem might be that the branch or statement is infeasible and that\nthe null pointer exception can't ever be executed; deciding that is beyond the ability of SpotBugs.\nDue to the fact that this value had been previously tested for nullness,\nthis is a definite possibility.\n</p>",262 "NP_NULL_ON_SOME_PATH_EXCEPTION": "Possible null pointer dereference in method on exception path\n\n<p> A reference value which is null on some exception control path is\ndereferenced here.&nbsp; This may lead to a <code>NullPointerException</code>\nwhen the code is executed.&nbsp;\nNote that because SpotBugs currently does not prune infeasible exception paths,\nthis may be a false warning.</p>\n\n<p> Also note that SpotBugs considers the default case of a switch statement to\nbe an exception path, since the default case is often infeasible.</p>",263 "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE": "Possible null pointer dereference due to return value of called method\n\n<p> The return value from a method is dereferenced without a null check,\nand the return value of that method is one that should generally be checked\nfor null. This may lead to a <code>NullPointerException</code> when the code is executed.\n</p>",264 "NP_NULL_PARAM_DEREF_NONVIRTUAL": "Non-virtual method call passes null for non-null parameter\n\n<p>\n A possibly-null value is passed to a non-null method parameter.\n Either the parameter is annotated as a parameter that should\n always be non-null, or analysis has shown that it will always be\n dereferenced.\n </p>",265 "NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS": "Method call passes null for non-null parameter\n\n<p>\n A possibly-null value is passed at a call site where all known\n target methods require the parameter to be non-null.\n Either the parameter is annotated as a parameter that should\n always be non-null, or analysis has shown that it will always be\n dereferenced.\n </p>",266 "NP_NULL_PARAM_DEREF": "Method call passes null for non-null parameter\n\n<p>\n This method call passes a null value for a non-null method parameter.\n Either the parameter is annotated as a parameter that should\n always be non-null, or analysis has shown that it will always be\n dereferenced.\n </p>",267 "NP_NONNULL_PARAM_VIOLATION": "Method call passes null to a non-null parameter \n\n<p>\n This method passes a null value as the parameter of a method which\n must be non-null. Either this parameter has been explicitly marked\n as @Nonnull, or analysis has determined that this parameter is\n always dereferenced.\n </p>",268 "NP_NONNULL_RETURN_VIOLATION": "Method may return null, but is declared @Nonnull\n\n<p>\n This method may return a null value, but the method (or a superclass method\n which it overrides) is declared to return @Nonnull.\n </p>",269 "NP_CLONE_COULD_RETURN_NULL": "Clone method may return null\n\n<p>\n This clone method seems to return null in some circumstances, but clone is never\n allowed to return a null value. If you are convinced this path is unreachable, throw an AssertionError\n instead.\n </p>",270 "NP_TOSTRING_COULD_RETURN_NULL": "toString method may return null\n\n<p>\n This toString method seems to return null in some circumstances. A liberal reading of the\n spec could be interpreted as allowing this, but it is probably a bad idea and could cause\n other code to break. Return the empty string or some other appropriate string rather than null.\n </p>",271 "NP_GUARANTEED_DEREF": "Null value is guaranteed to be dereferenced\n\n<p>\n There is a statement or branch that if executed guarantees that\n a value is null at this point, and that\n value that is guaranteed to be dereferenced\n (except on forward paths involving runtime exceptions).\n </p>\n <p>Note that a check such as\n <code>if (x == null) throw new NullPointerException();</code>\n is treated as a dereference of <code>x</code>.</p>",272 "NP_GUARANTEED_DEREF_ON_EXCEPTION_PATH": "Value is null and guaranteed to be dereferenced on exception path\n\n<p>\n There is a statement or branch on an exception path\n that if executed guarantees that\n a value is null at this point, and that\n value that is guaranteed to be dereferenced\n (except on forward paths involving runtime exceptions).\n </p>",273 "SI_INSTANCE_BEFORE_FINALS_ASSIGNED": "Static initializer creates instance before all static final fields assigned\n\n<p> The class's static initializer creates an instance of the class\nbefore all of the static final fields are assigned.</p>",274 "OS_OPEN_STREAM": "Method may fail to close stream\n\n<p> The method creates an IO stream object, does not assign it to any\nfields, pass it to other methods that might close it,\nor return it, and does not appear to close\nthe stream on all paths out of the method.&nbsp; This may result in\na file descriptor leak.&nbsp; It is generally a good\nidea to use a <code>finally</code> block to ensure that streams are\nclosed.</p>",275 "OS_OPEN_STREAM_EXCEPTION_PATH": "Method may fail to close stream on exception\n\n<p> The method creates an IO stream object, does not assign it to any\nfields, pass it to other methods, or return it, and does not appear to close\nit on all possible exception paths out of the method.&nbsp;\nThis may result in a file descriptor leak.&nbsp; It is generally a good\nidea to use a <code>finally</code> block to ensure that streams are\nclosed.</p>",276 "PZLA_PREFER_ZERO_LENGTH_ARRAYS": "Consider returning a zero length array rather than null\n\n<p> It is often a better design to\nreturn a length zero array rather than a null reference to indicate that there\nare no results (i.e., an empty list of results).\nThis way, no explicit check for null is needed by clients of the method.</p>\n\n<p>On the other hand, using null to indicate\n\"there is no answer to this question\" is probably appropriate.\nFor example, <code>File.listFiles()</code> returns an empty list\nif given a directory containing no files, and returns null if the file\nis not a directory.</p>",277 "UCF_USELESS_CONTROL_FLOW": "Useless control flow\n\n<p> This method contains a useless control flow statement, where\ncontrol flow continues onto the same place regardless of whether or not\nthe branch is taken. For example,\nthis is caused by having an empty statement\nblock for an <code>if</code> statement:</p>\n<pre><code>if (argv.length == 0) {\n // TODO: handle this case\n}\n</code></pre>",278 "UCF_USELESS_CONTROL_FLOW_NEXT_LINE": "Useless control flow to next line\n\n<p> This method contains a useless control flow statement in which control\nflow follows to the same or following line regardless of whether or not\nthe branch is taken.\nOften, this is caused by inadvertently using an empty statement as the\nbody of an <code>if</code> statement, e.g.:</p>\n<pre><code>if (argv.length == 1);\n System.out.println(\"Hello, \" + argv[0]);\n</code></pre>",279 "RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE": "Nullcheck of value previously dereferenced\n\n<p> A value is checked here to see whether it is null, but this value can't\nbe null because it was previously dereferenced and if it were null a null pointer\nexception would have occurred at the earlier dereference.\nEssentially, this code and the previous dereference\ndisagree as to whether this value is allowed to be null. Either the check is redundant\nor the previous dereference is erroneous.</p>",280 "RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE": "Redundant nullcheck of value known to be null\n\n<p> This method contains a redundant check of a known null value against\nthe constant null.</p>",281 "RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE": "Redundant nullcheck of value known to be non-null\n\n<p> This method contains a redundant check of a known non-null value against\nthe constant null.</p>",282 "RCN_REDUNDANT_COMPARISON_TWO_NULL_VALUES": "Redundant comparison of two null values\n\n<p> This method contains a redundant comparison of two references known to\nboth be definitely null.</p>",283 "RCN_REDUNDANT_COMPARISON_OF_NULL_AND_NONNULL_VALUE": "Redundant comparison of non-null value to null\n\n<p> This method contains a reference known to be non-null with another reference\nknown to be null.</p>",284 "RCN_REDUNDANT_CHECKED_NULL_COMPARISON": "Redundant comparison to null of previously checked value\n\n<p> This method contains a redundant comparison of a reference value\nto null. Two types of redundant comparison are reported:\n</p>\n<ul>\n<li> Both values compared are definitely null</li>\n<li> One value is definitely null and the other is definitely not null</li>\n</ul>\n\n<p> This particular warning generally indicates that a\nvalue known not to be null was checked against null.\nWhile the check is not necessary, it may simply be a case\nof defensive programming.</p>",285 "UL_UNRELEASED_LOCK": "Method does not release lock on all paths\n\n<p> This method acquires a JSR-166 (<code>java.util.concurrent</code>) lock,\nbut does not release it on all paths out of the method. In general, the correct idiom\nfor using a JSR-166 lock is:\n</p>\n<pre><code>Lock l = ...;\nl.lock();\ntry {\n // do something\n} finally {\n l.unlock();\n}\n</code></pre>",286 "UL_UNRELEASED_LOCK_EXCEPTION_PATH": "Method does not release lock on all exception paths\n\n<p> This method acquires a JSR-166 (<code>java.util.concurrent</code>) lock,\nbut does not release it on all exception paths out of the method. In general, the correct idiom\nfor using a JSR-166 lock is:\n</p>\n<pre><code>Lock l = ...;\nl.lock();\ntry {\n // do something\n} finally {\n l.unlock();\n}\n</code></pre>",287 "RC_REF_COMPARISON": "Suspicious reference comparison\n\n<p> This method compares two reference values using the == or != operator,\nwhere the correct way to compare instances of this type is generally\nwith the equals() method.\nIt is possible to create distinct instances that are equal but do not compare as == since\nthey are different objects.\nExamples of classes which should generally\nnot be compared by reference are java.lang.Integer, java.lang.Float, etc.</p>",288 "RC_REF_COMPARISON_BAD_PRACTICE": "Suspicious reference comparison to constant\n\n<p> This method compares a reference value to a constant using the == or != operator,\nwhere the correct way to compare instances of this type is generally\nwith the equals() method.\nIt is possible to create distinct instances that are equal but do not compare as == since\nthey are different objects.\nExamples of classes which should generally\nnot be compared by reference are java.lang.Integer, java.lang.Float, etc.</p>",289 "RC_REF_COMPARISON_BAD_PRACTICE_BOOLEAN": "Suspicious reference comparison of Boolean values\n\n<p> This method compares two Boolean values using the == or != operator.\nNormally, there are only two Boolean values (Boolean.TRUE and Boolean.FALSE),\nbut it is possible to create other Boolean objects using the <code>new Boolean(b)</code>\nconstructor. It is best to avoid such objects, but if they do exist,\nthen checking Boolean objects for equality using == or != will give results\nthan are different than you would get using <code>.equals(...)</code>.\n</p>",290 "EC_UNRELATED_TYPES_USING_POINTER_EQUALITY": "Using pointer equality to compare different types\n\n<p> This method uses using pointer equality to compare two references that seem to be of\ndifferent types. The result of this comparison will always be false at runtime.\n</p>",291 "EC_UNRELATED_TYPES": "Call to equals() comparing different types\n\n<p> This method calls equals(Object) on two references of different\nclass types and analysis suggests they will be to objects of different classes\nat runtime. Further, examination of the equals methods that would be invoked suggest that either\nthis call will always return false, or else the equals method is not be symmetric (which is\na property required by the contract\nfor equals in class Object).\n</p>",292 "EC_UNRELATED_INTERFACES": "Call to equals() comparing different interface types\n\n<p> This method calls equals(Object) on two references of unrelated\ninterface types, where neither is a subtype of the other,\nand there are no known non-abstract classes which implement both interfaces.\nTherefore, the objects being compared\nare unlikely to be members of the same class at runtime\n(unless some application classes were not analyzed, or dynamic class\nloading can occur at runtime).\nAccording to the contract of equals(),\nobjects of different\nclasses should always compare as unequal; therefore, according to the\ncontract defined by java.lang.Object.equals(Object),\nthe result of this comparison will always be false at runtime.\n</p>",293 "EC_UNRELATED_CLASS_AND_INTERFACE": "Call to equals() comparing unrelated class and interface\n\n<p>\nThis method calls equals(Object) on two references, one of which is a class\nand the other an interface, where neither the class nor any of its\nnon-abstract subclasses implement the interface.\nTherefore, the objects being compared\nare unlikely to be members of the same class at runtime\n(unless some application classes were not analyzed, or dynamic class\nloading can occur at runtime).\nAccording to the contract of equals(),\nobjects of different\nclasses should always compare as unequal; therefore, according to the\ncontract defined by java.lang.Object.equals(Object),\nthe result of this comparison will always be false at runtime.\n</p>",294 "EC_NULL_ARG": "Call to equals(null)\n\n<p> This method calls equals(Object), passing a null value as\nthe argument. According to the contract of the equals() method,\nthis call should always return <code>false</code>.</p>",295 "MWN_MISMATCHED_WAIT": "Mismatched wait()\n\n<p> This method calls Object.wait() without obviously holding a lock\non the object.&nbsp; Calling wait() without a lock held will result in\nan <code>IllegalMonitorStateException</code> being thrown.</p>",296 "MWN_MISMATCHED_NOTIFY": "Mismatched notify()\n\n<p> This method calls Object.notify() or Object.notifyAll() without obviously holding a lock\non the object.&nbsp; Calling notify() or notifyAll() without a lock held will result in\nan <code>IllegalMonitorStateException</code> being thrown.</p>",297 "SA_LOCAL_SELF_ASSIGNMENT_INSTEAD_OF_FIELD": "Self assignment of local rather than assignment to field\n\n<p> This method contains a self assignment of a local variable, and there\nis a field with an identical name.\nassignment appears to have been ; e.g.</p>\n<pre><code> int foo;\n public void setFoo(int foo) {\n foo = foo;\n }\n</code></pre>\n<p>The assignment is useless. Did you mean to assign to the field instead?</p>",298 "SA_LOCAL_SELF_ASSIGNMENT": "Self assignment of local variable\n\n<p> This method contains a self assignment of a local variable; e.g.</p>\n<pre><code>public void foo() {\n int x = 3;\n x = x;\n}\n</code></pre>\n<p>\nSuch assignments are useless, and may indicate a logic error or typo.\n</p>",299 "SA_FIELD_SELF_ASSIGNMENT": "Self assignment of field\n\n<p> This method contains a self assignment of a field; e.g.\n</p>\n<pre><code>int x;\npublic void foo() {\n x = x;\n}\n</code></pre>\n<p>Such assignments are useless, and may indicate a logic error or typo.</p>",300 "SA_FIELD_DOUBLE_ASSIGNMENT": "Double assignment of field\n\n<p> This method contains a double assignment of a field; e.g.\n</p>\n<pre><code>int x,y;\npublic void foo() {\n x = x = 17;\n}\n</code></pre>\n<p>Assigning to a field twice is useless, and may indicate a logic error or typo.</p>",301 "SA_LOCAL_DOUBLE_ASSIGNMENT": "Double assignment of local variable \n\n<p> This method contains a double assignment of a local variable; e.g.\n</p>\n<pre><code>public void foo() {\n int x,y;\n x = x = 17;\n}\n</code></pre>\n<p>Assigning the same value to a variable twice is useless, and may indicate a logic error or typo.</p>",302 "SA_FIELD_SELF_COMPUTATION": "Nonsensical self computation involving a field (e.g., x & x)\n\n<p> This method performs a nonsensical computation of a field with another\nreference to the same field (e.g., x&x or x-x). Because of the nature\nof the computation, this operation doesn't seem to make sense,\nand may indicate a typo or\na logic error. Double check the computation.\n</p>",303 "SA_LOCAL_SELF_COMPUTATION": "Nonsensical self computation involving a variable (e.g., x & x)\n\n<p> This method performs a nonsensical computation of a local variable with another\nreference to the same variable (e.g., x&x or x-x). Because of the nature\nof the computation, this operation doesn't seem to make sense,\nand may indicate a typo or\na logic error. Double check the computation.\n</p>",304 "SA_FIELD_SELF_COMPARISON": "Self comparison of field with itself\n\n<p> This method compares a field with itself, and may indicate a typo or\na logic error. Make sure that you are comparing the right things.\n</p>",305 "SA_LOCAL_SELF_COMPARISON": "Self comparison of value with itself\n\n<p> This method compares a local variable with itself, and may indicate a typo or\na logic error. Make sure that you are comparing the right things.\n</p>",306 "DMI_LONG_BITS_TO_DOUBLE_INVOKED_ON_INT": "Double.longBitsToDouble invoked on an int\n\n<p> The Double.longBitsToDouble method is invoked, but a 32 bit int value is passed\n as an argument. This almost certainly is not intended and is unlikely\n to give the intended result.\n</p>",307 "DMI_ARGUMENTS_WRONG_ORDER": "Reversed method arguments\n\n<p> The arguments to this method call seem to be in the wrong order.\nFor example, a call <code>Preconditions.checkNotNull(\"message\", message)</code>\nhas reserved arguments: the value to be checked is the first argument.\n</p>",308 "DMI_RANDOM_USED_ONLY_ONCE": "Random object created and used only once\n\n<p> This code creates a java.util.Random object, uses it to generate one random number, and then discards\nthe Random object. This produces mediocre quality random numbers and is inefficient.\nIf possible, rewrite the code so that the Random object is created once and saved, and each time a new random number\nis required invoke a method on the existing Random object to obtain it.\n</p>\n\n<p>If it is important that the generated Random numbers not be guessable, you <em>must</em> not create a new Random for each random\nnumber; the values are too easily guessable. You should strongly consider using a java.security.SecureRandom instead\n(and avoid allocating a new SecureRandom for each random number needed).\n</p>",309 "RV_ABSOLUTE_VALUE_OF_RANDOM_INT": "Bad attempt to compute absolute value of signed random integer\n\n<p> This code generates a random signed integer and then computes\nthe absolute value of that random integer. If the number returned by the random number\ngenerator is <code>Integer.MIN_VALUE</code>, then the result will be negative as well (since\n<code>Math.abs(Integer.MIN_VALUE) == Integer.MIN_VALUE</code>). (Same problem arises for long values as well).\n</p>",310 "RV_ABSOLUTE_VALUE_OF_HASHCODE": "Bad attempt to compute absolute value of signed 32-bit hashcode \n\n<p> This code generates a hashcode and then computes\nthe absolute value of that hashcode. If the hashcode\nis <code>Integer.MIN_VALUE</code>, then the result will be negative as well (since\n<code>Math.abs(Integer.MIN_VALUE) == Integer.MIN_VALUE</code>).\n</p>\n<p>One out of 2^32 strings have a hashCode of Integer.MIN_VALUE,\nincluding \"polygenelubricants\" \"GydZG_\" and \"\"DESIGNING WORKHOUSES\".\n</p>",311 "RV_REM_OF_RANDOM_INT": "Remainder of 32-bit signed random integer\n\n<p> This code generates a random signed integer and then computes\nthe remainder of that value modulo another value. Since the random\nnumber can be negative, the result of the remainder operation\ncan also be negative. Be sure this is intended, and strongly\nconsider using the Random.nextInt(int) method instead.\n</p>",312 "RV_REM_OF_HASHCODE": "Remainder of hashCode could be negative\n\n<p> This code computes a hashCode, and then computes\nthe remainder of that value modulo another value. Since the hashCode\ncan be negative, the result of the remainder operation\ncan also be negative. </p>\n<p> Assuming you want to ensure that the result of your computation is nonnegative,\nyou may need to change your code.\nIf you know the divisor is a power of 2,\nyou can use a bitwise and operator instead (i.e., instead of\nusing <code>x.hashCode()%n</code>, use <code>x.hashCode()&amp;(n-1)</code>).\nThis is probably faster than computing the remainder as well.\nIf you don't know that the divisor is a power of 2, take the absolute\nvalue of the result of the remainder operation (i.e., use\n<code>Math.abs(x.hashCode()%n)</code>).\n</p>",313 "INT_BAD_COMPARISON_WITH_NONNEGATIVE_VALUE": "Bad comparison of nonnegative value with negative constant or zero\n\n<p> This code compares a value that is guaranteed to be non-negative with a negative constant or zero.\n</p>",314 "INT_BAD_COMPARISON_WITH_SIGNED_BYTE": "Bad comparison of signed byte\n\n<p> Signed bytes can only have a value in the range -128 to 127. Comparing\na signed byte with a value outside that range is vacuous and likely to be incorrect.\nTo convert a signed byte <code>b</code> to an unsigned value in the range 0..255,\nuse <code>0xff &amp; b</code>.\n</p>",315 "INT_BAD_COMPARISON_WITH_INT_VALUE": "Bad comparison of int value with long constant\n\n<p> This code compares an int value with a long constant that is outside\nthe range of values that can be represented as an int value.\nThis comparison is vacuous and possibly to be incorrect.\n</p>",316 "INT_VACUOUS_BIT_OPERATION": "Vacuous bit mask operation on integer value\n\n<p> This is an integer bit operation (and, or, or exclusive or) that doesn't do any useful work\n(e.g., <code>v & 0xffffffff</code>).\n\n</p>",317 "INT_VACUOUS_COMPARISON": "Vacuous comparison of integer value\n\n<p> There is an integer comparison that always returns\nthe same value (e.g., x &lt;= Integer.MAX_VALUE).\n</p>",318 "INT_BAD_REM_BY_1": "Integer remainder modulo 1\n\n<p> Any expression (exp % 1) is guaranteed to always return zero.\nDid you mean (exp &amp; 1) or (exp % 2) instead?\n</p>",319 "BIT_IOR_OF_SIGNED_BYTE": "Bitwise OR of signed byte value\n\n<p> Loads a byte value (e.g., a value loaded from a byte array or returned by a method\nwith return type byte) and performs a bitwise OR with\nthat value. Byte values are sign extended to 32 bits\nbefore any bitwise operations are performed on the value.\nThus, if <code>b[0]</code> contains the value <code>0xff</code>, and\n<code>x</code> is initially 0, then the code\n<code>((x &lt;&lt; 8) | b[0])</code> will sign extend <code>0xff</code>\nto get <code>0xffffffff</code>, and thus give the value\n<code>0xffffffff</code> as the result.\n</p>\n\n<p>In particular, the following code for packing a byte array into an int is badly wrong: </p>\n<pre><code>int result = 0;\nfor(int i = 0; i &lt; 4; i++) {\n result = ((result &lt;&lt; 8) | b[i]);\n}\n</code></pre>\n<p>The following idiom will work instead: </p>\n<pre><code>int result = 0;\nfor(int i = 0; i &lt; 4; i++) {\n result = ((result &lt;&lt; 8) | (b[i] &amp; 0xff));\n}\n</code></pre>",320 "BIT_ADD_OF_SIGNED_BYTE": "Bitwise add of signed byte value\n\n<p> Adds a byte value and a value which is known to have the 8 lower bits clear.\nValues loaded from a byte array are sign extended to 32 bits\nbefore any bitwise operations are performed on the value.\nThus, if <code>b[0]</code> contains the value <code>0xff</code>, and\n<code>x</code> is initially 0, then the code\n<code>((x &lt;&lt; 8) + b[0])</code> will sign extend <code>0xff</code>\nto get <code>0xffffffff</code>, and thus give the value\n<code>0xffffffff</code> as the result.\n</p>\n\n<p>In particular, the following code for packing a byte array into an int is badly wrong: </p>\n<pre><code>int result = 0;\nfor(int i = 0; i &lt; 4; i++)\n result = ((result &lt;&lt; 8) + b[i]);\n</code></pre>\n<p>The following idiom will work instead: </p>\n<pre><code>int result = 0;\nfor(int i = 0; i &lt; 4; i++)\n result = ((result &lt;&lt; 8) + (b[i] &amp; 0xff));\n</code></pre>",321 "BIT_AND": "Incompatible bit masks\n\n<p> This method compares an expression of the form (e &amp; C) to D,\nwhich will always compare unequal\ndue to the specific values of constants C and D.\nThis may indicate a logic error or typo.</p>",322 "BIT_SIGNED_CHECK": "Check for sign of bitwise operation\n\n<p> This method compares an expression such as\n<code>((event.detail &amp; SWT.SELECTED) &gt; 0)</code>.\nUsing bit arithmetic and then comparing with the greater than operator can\nlead to unexpected results (of course depending on the value of\nSWT.SELECTED). If SWT.SELECTED is a negative number, this is a candidate\nfor a bug. Even when SWT.SELECTED is not negative, it seems good practice\nto use '!= 0' instead of '&gt; 0'.\n</p>",323 "BIT_SIGNED_CHECK_HIGH_BIT": "Check for sign of bitwise operation involving negative number\n\n<p> This method compares a bitwise expression such as\n<code>((val &amp; CONSTANT) &gt; 0)</code> where CONSTANT is the negative number.\nUsing bit arithmetic and then comparing with the greater than operator can\nlead to unexpected results. This comparison is unlikely to work as expected. The good practice is\nto use '!= 0' instead of '&gt; 0'.\n</p>",324 "BIT_AND_ZZ": "Check to see if ((...) & 0) == 0\n\n<p> This method compares an expression of the form <code>(e &amp; 0)</code> to 0,\nwhich will always compare equal.\nThis may indicate a logic error or typo.</p>",325 "BIT_IOR": "Incompatible bit masks\n\n<p> This method compares an expression of the form <code>(e | C)</code> to D.\nwhich will always compare unequal\ndue to the specific values of constants C and D.\nThis may indicate a logic error or typo.</p>\n\n<p> Typically, this bug occurs because the code wants to perform\na membership test in a bit set, but uses the bitwise OR\noperator (\"|\") instead of bitwise AND (\"&amp;\").</p>\n\n<p>Also such bug may appear in expressions like <code>(e &amp; A | B) == C</code>\nwhich is parsed like <code>((e &amp; A) | B) == C</code> while <code>(e &amp; (A | B)) == C</code> was intended.</p>",326 "LI_LAZY_INIT_INSTANCE": "Incorrect lazy initialization of instance field\n\n<p> This method contains an unsynchronized lazy initialization of a non-volatile field.\nBecause the compiler or processor may reorder instructions,\nthreads are not guaranteed to see a completely initialized object,\n<em>if the method can be called by multiple threads</em>.\nYou can make the field volatile to correct the problem.\nFor more information, see the\n<a href=\"http://www.cs.umd.edu/~pugh/java/memoryModel/\">Java Memory Model web site</a>.\n</p>",327 "LI_LAZY_INIT_STATIC": "Incorrect lazy initialization of static field\n\n<p> This method contains an unsynchronized lazy initialization of a non-volatile static field.\nBecause the compiler or processor may reorder instructions,\nthreads are not guaranteed to see a completely initialized object,\n<em>if the method can be called by multiple threads</em>.\nYou can make the field volatile to correct the problem.\nFor more information, see the\n<a href=\"http://www.cs.umd.edu/~pugh/java/memoryModel/\">Java Memory Model web site</a>.\n</p>",328 "LI_LAZY_INIT_UPDATE_STATIC": "Incorrect lazy initialization and update of static field\n\n<p> This method contains an unsynchronized lazy initialization of a static field.\nAfter the field is set, the object stored into that location is further updated or accessed.\nThe setting of the field is visible to other threads as soon as it is set. If the\nfurther accesses in the method that set the field serve to initialize the object, then\nyou have a <em>very serious</em> multithreading bug, unless something else prevents\nany other thread from accessing the stored object until it is fully initialized.\n</p>\n<p>Even if you feel confident that the method is never called by multiple\nthreads, it might be better to not set the static field until the value\nyou are setting it to is fully populated/initialized.",329 "JLM_JSR166_LOCK_MONITORENTER": "Synchronization performed on Lock\n\n<p> This method performs synchronization an object that implements\njava.util.concurrent.locks.Lock. Such an object is locked/unlocked\nusing\n<code>acquire()</code>/<code>release()</code> rather\nthan using the <code>synchronized (...)</code> construct.\n</p>",330 "JML_JSR166_CALLING_WAIT_RATHER_THAN_AWAIT": "Using monitor style wait methods on util.concurrent abstraction\n\n<p> This method calls\n<code>wait()</code>,\n<code>notify()</code> or\n<code>notifyAll()()</code>\non an object that also provides an\n<code>await()</code>,\n<code>signal()</code>,\n<code>signalAll()</code> method (such as util.concurrent Condition objects).\nThis probably isn't what you want, and even if you do want it, you should consider changing\nyour design, as other developers will find it exceptionally confusing.\n</p>",331 "JLM_JSR166_UTILCONCURRENT_MONITORENTER": "Synchronization performed on util.concurrent instance\n\n<p> This method performs synchronization an object that is an instance of\na class from the java.util.concurrent package (or its subclasses). Instances\nof these classes have their own concurrency control mechanisms that are orthogonal to\nthe synchronization provided by the Java keyword <code>synchronized</code>. For example,\nsynchronizing on an <code>AtomicBoolean</code> will not prevent other threads\nfrom modifying the <code>AtomicBoolean</code>.</p>\n<p>Such code may be correct, but should be carefully reviewed and documented,\nand may confuse people who have to maintain the code at a later date.\n</p>",332 "UPM_UNCALLED_PRIVATE_METHOD": "Private method is never called\n\n<p> This private method is never called. Although it is\npossible that the method will be invoked through reflection,\nit is more likely that the method is never used, and should be\nremoved.\n</p>",333 "UMAC_UNCALLABLE_METHOD_OF_ANONYMOUS_CLASS": "Uncallable method defined in anonymous class\n\n<p> This anonymous class defined a method that is not directly invoked and does not override\na method in a superclass. Since methods in other classes cannot directly invoke methods\ndeclared in an anonymous class, it seems that this method is uncallable. The method\nmight simply be dead code, but it is also possible that the method is intended to\noverride a method declared in a superclass, and due to an typo or other error the method does not,\nin fact, override the method it is intended to.\n</p>",334 "ODR_OPEN_DATABASE_RESOURCE": "Method may fail to close database resource\n\n<p> The method creates a database resource (such as a database connection\nor row set), does not assign it to any\nfields, pass it to other methods, or return it, and does not appear to close\nthe object on all paths out of the method.&nbsp; Failure to\nclose database resources on all paths out of a method may\nresult in poor performance, and could cause the application to\nhave problems communicating with the database.\n</p>",335 "ODR_OPEN_DATABASE_RESOURCE_EXCEPTION_PATH": "Method may fail to close database resource on exception\n\n<p> The method creates a database resource (such as a database connection\nor row set), does not assign it to any\nfields, pass it to other methods, or return it, and does not appear to close\nthe object on all exception paths out of the method.&nbsp; Failure to\nclose database resources on all paths out of a method may\nresult in poor performance, and could cause the application to\nhave problems communicating with the database.</p>",336 "SBSC_USE_STRINGBUFFER_CONCATENATION": "Method concatenates strings using + in a loop\n\n<p> The method seems to be building a String using concatenation in a loop.\nIn each iteration, the String is converted to a StringBuffer/StringBuilder,\n appended to, and converted back to a String.\n This can lead to a cost quadratic in the number of iterations,\n as the growing string is recopied in each iteration. </p>\n\n<p>Better performance can be obtained by using\na StringBuffer (or StringBuilder in Java 1.5) explicitly.</p>\n\n<p> For example:</p>\n<pre><code>// This is bad\nString s = \"\";\nfor (int i = 0; i &lt; field.length; ++i) {\n s = s + field[i];\n}\n\n// This is better\nStringBuffer buf = new StringBuffer();\nfor (int i = 0; i &lt; field.length; ++i) {\n buf.append(field[i]);\n}\nString s = buf.toString();\n</code></pre>",337 "IIL_PREPARE_STATEMENT_IN_LOOP": "Method calls prepareStatement in a loop\n\n<p> The method calls Connection.prepareStatement inside the loop passing the constant arguments.\nIf the PreparedStatement should be executed several times there's no reason to recreate it for each loop iteration.\nMove this call outside of the loop.</p>",338 "IIL_ELEMENTS_GET_LENGTH_IN_LOOP": "NodeList.getLength() called in a loop\n\n<p> The method calls NodeList.getLength() inside the loop and NodeList was produced by getElementsByTagName call.\nThis NodeList doesn't store its length, but computes it every time in not very optimal way.\nConsider storing the length to the variable before the loop.\n</p>",339 "IIL_PATTERN_COMPILE_IN_LOOP": "Method calls Pattern.compile in a loop\n\n<p> The method calls Pattern.compile inside the loop passing the constant arguments.\nIf the Pattern should be used several times there's no reason to compile it for each loop iteration.\nMove this call outside of the loop or even into static final field.</p>",340 "IIL_PATTERN_COMPILE_IN_LOOP_INDIRECT": "Method compiles the regular expression in a loop\n\n<p> The method creates the same regular expression inside the loop, so it will be compiled every iteration.\nIt would be more optimal to precompile this regular expression using Pattern.compile outside of the loop.</p>",341 "IIO_INEFFICIENT_INDEX_OF": "Inefficient use of String.indexOf(String)\n\n<p> This code passes a constant string of length 1 to String.indexOf().\nIt is more efficient to use the integer implementations of String.indexOf().\nf. e. call <code>myString.indexOf('.')</code> instead of <code>myString.indexOf(\".\")</code></p>",342 "IIO_INEFFICIENT_LAST_INDEX_OF": "Inefficient use of String.lastIndexOf(String)\n\n<p> This code passes a constant string of length 1 to String.lastIndexOf().\nIt is more efficient to use the integer implementations of String.lastIndexOf().\nf. e. call <code>myString.lastIndexOf('.')</code> instead of <code>myString.lastIndexOf(\".\")</code></p>",343 "ITA_INEFFICIENT_TO_ARRAY": "Method uses toArray() with zero-length array argument\n\n<p> This method uses the toArray() method of a collection derived class, and passes\nin a zero-length prototype array argument. It is more efficient to use\n<code>myCollection.toArray(new Foo[myCollection.size()])</code>\nIf the array passed in is big enough to store all of the\nelements of the collection, then it is populated and returned\ndirectly. This avoids the need to create a second array\n(by reflection) to return as the result.</p>",344 "IJU_ASSERT_METHOD_INVOKED_FROM_RUN_METHOD": "JUnit assertion in run method will not be noticed by JUnit\n\n<p> A JUnit assertion is performed in a run method. Failed JUnit assertions\njust result in exceptions being thrown.\nThus, if this exception occurs in a thread other than the thread that invokes\nthe test method, the exception will terminate the thread but not result\nin the test failing.\n</p>",345 "IJU_SETUP_NO_SUPER": "TestCase defines setUp that doesn't call super.setUp()\n\n<p> Class is a JUnit TestCase and implements the setUp method. The setUp method should call\nsuper.setUp(), but doesn't.</p>",346 "IJU_TEARDOWN_NO_SUPER": "TestCase defines tearDown that doesn't call super.tearDown()\n\n<p> Class is a JUnit TestCase and implements the tearDown method. The tearDown method should call\nsuper.tearDown(), but doesn't.</p>",347 "IJU_SUITE_NOT_STATIC": "TestCase implements a non-static suite method \n\n<p> Class is a JUnit TestCase and implements the suite() method.\n The suite method should be declared as being static, but isn't.</p>",348 "IJU_BAD_SUITE_METHOD": "TestCase declares a bad suite method \n\n<p> Class is a JUnit TestCase and defines a suite() method.\nHowever, the suite method needs to be declared as either</p>\n<pre><code>public static junit.framework.Test suite()\n</code></pre>\n<p>\nor\n</p>\n<pre><code>public static junit.framework.TestSuite suite()\n</code></pre>",349 "IJU_NO_TESTS": "TestCase has no tests\n\n<p> Class is a JUnit TestCase but has not implemented any test methods.</p>",350 "BOA_BADLY_OVERRIDDEN_ADAPTER": "Class overrides a method implemented in super class Adapter wrongly\n\n<p> This method overrides a method found in a parent class, where that class is an Adapter that implements\na listener defined in the java.awt.event or javax.swing.event package. As a result, this method will not\nget called when the event occurs.</p>",351 "BRSA_BAD_RESULTSET_ACCESS": "Method attempts to access a result set field with index 0\n\n<p> A call to getXXX or updateXXX methods of a result set was made where the\nfield index is 0. As ResultSet fields start at index 1, this is always a mistake.</p>",352 "SQL_BAD_RESULTSET_ACCESS": "Method attempts to access a result set field with index 0\n\n<p> A call to getXXX or updateXXX methods of a result set was made where the\nfield index is 0. As ResultSet fields start at index 1, this is always a mistake.</p>",353 "SQL_BAD_PREPARED_STATEMENT_ACCESS": "Method attempts to access a prepared statement parameter with index 0\n\n<p> A call to a setXXX method of a prepared statement was made where the\nparameter index is 0. As parameter indexes start at index 1, this is always a mistake.</p>",354 "SIO_SUPERFLUOUS_INSTANCEOF": "Unnecessary type check done using instanceof operator\n\n<p> Type check performed using the instanceof operator where it can be statically determined whether the object\nis of the type requested. </p>",355 "BAC_BAD_APPLET_CONSTRUCTOR": "Bad Applet Constructor relies on uninitialized AppletStub\n\n<p>\nThis constructor calls methods in the parent Applet that rely on the AppletStub. Since the AppletStub\nisn't initialized until the init() method of this applet is called, these methods will not perform\ncorrectly.\n</p>",356 "EC_ARRAY_AND_NONARRAY": "equals() used to compare array and nonarray\n\n<p>\nThis method invokes the .equals(Object o) to compare an array and a reference that doesn't seem\nto be an array. If things being compared are of different types, they are guaranteed to be unequal\nand the comparison is almost certainly an error. Even if they are both arrays, the equals method\non arrays only determines of the two arrays are the same object.\nTo compare the\ncontents of the arrays, use java.util.Arrays.equals(Object[], Object[]).\n</p>",357 "EC_BAD_ARRAY_COMPARE": "Invocation of equals() on an array, which is equivalent to ==\n\n<p>\nThis method invokes the .equals(Object o) method on an array. Since arrays do not override the equals\nmethod of Object, calling equals on an array is the same as comparing their addresses. To compare the\ncontents of the arrays, use <code>java.util.Arrays.equals(Object[], Object[])</code>.\nTo compare the addresses of the arrays, it would be\nless confusing to explicitly check pointer equality using <code>==</code>.\n</p>",358 "EC_INCOMPATIBLE_ARRAY_COMPARE": "equals(...) used to compare incompatible arrays\n\n<p>\nThis method invokes the .equals(Object o) to compare two arrays, but the arrays of\nof incompatible types (e.g., String[] and StringBuffer[], or String[] and int[]).\nThey will never be equal. In addition, when equals(...) is used to compare arrays it\nonly checks to see if they are the same array, and ignores the contents of the arrays.\n</p>",359 "STI_INTERRUPTED_ON_CURRENTTHREAD": "Unneeded use of currentThread() call, to call interrupted() \n\n<p>\nThis method invokes the Thread.currentThread() call, just to call the interrupted() method. As interrupted() is a\nstatic method, is more simple and clear to use Thread.interrupted().\n</p>",360 "STI_INTERRUPTED_ON_UNKNOWNTHREAD": "Static Thread.interrupted() method invoked on thread instance\n\n<p>\nThis method invokes the Thread.interrupted() method on a Thread object that appears to be a Thread object that is\nnot the current thread. As the interrupted() method is static, the interrupted method will be called on a different\nobject than the one the author intended.\n</p>",361 "IP_PARAMETER_IS_DEAD_BUT_OVERWRITTEN": "A parameter is dead upon entry to a method but overwritten\n\n<p>\nThe initial value of this parameter is ignored, and the parameter\nis overwritten here. This often indicates a mistaken belief that\nthe write to the parameter will be conveyed back to\nthe caller.\n</p>",362 "DLS_DEAD_LOCAL_STORE_SHADOWS_FIELD": "Dead store to local variable that shadows field\n\n<p>\nThis instruction assigns a value to a local variable,\nbut the value is not read or used in any subsequent instruction.\nOften, this indicates an error, because the value computed is never\nused. There is a field with the same name as the local variable. Did you\nmean to assign to that variable instead?\n</p>",363 "DLS_DEAD_LOCAL_STORE": "Dead store to local variable\n\n<p>\nThis instruction assigns a value to a local variable,\nbut the value is not read or used in any subsequent instruction.\nOften, this indicates an error, because the value computed is never\nused.\n</p>\n<p>\nNote that Sun's javac compiler often generates dead stores for\nfinal local variables. Because SpotBugs is a bytecode-based tool,\nthere is no easy way to eliminate these false positives.\n</p>",364 "DLS_DEAD_LOCAL_STORE_IN_RETURN": "Useless assignment in return statement\n\n<p>\nThis statement assigns to a local variable in a return statement. This assignment\nhas effect. Please verify that this statement does the right thing.\n</p>",365 "DLS_DEAD_LOCAL_INCREMENT_IN_RETURN": "Useless increment in return statement\n\n<p>This statement has a return such as <code>return x++;</code>.\nA postfix increment/decrement does not impact the value of the expression,\nso this increment/decrement has no effect.\nPlease verify that this statement does the right thing.\n</p>",366 "DLS_DEAD_STORE_OF_CLASS_LITERAL": "Dead store of class literal\n\n<p>\nThis instruction assigns a class literal to a variable and then never uses it.\n<a href=\"http://www.oracle.com/technetwork/java/javase/compatibility-137462.html#literal\">The behavior of this differs in Java 1.4 and in Java 5.</a>\nIn Java 1.4 and earlier, a reference to <code>Foo.class</code> would force the static initializer\nfor <code>Foo</code> to be executed, if it has not been executed already.\nIn Java 5 and later, it does not.\n</p>\n<p>See Sun's <a href=\"http://www.oracle.com/technetwork/java/javase/compatibility-137462.html#literal\">article on Java SE compatibility</a>\nfor more details and examples, and suggestions on how to force class initialization in Java 5.\n</p>",367 "DLS_DEAD_LOCAL_STORE_OF_NULL": "Dead store of null to local variable\n\n<p>The code stores null into a local variable, and the stored value is not\nread. This store may have been introduced to assist the garbage collector, but\nas of Java SE 6.0, this is no longer needed or useful.\n</p>",368 "MF_METHOD_MASKS_FIELD": "Method defines a variable that obscures a field\n\n<p> This method defines a local variable with the same name as a field\nin this class or a superclass. This may cause the method to\nread an uninitialized value from the field, leave the field uninitialized,\nor both.</p>",369 "MF_CLASS_MASKS_FIELD": "Class defines field that masks a superclass field\n\n<p> This class defines a field with the same name as a visible\ninstance field in a superclass. This is confusing, and\nmay indicate an error if methods update or access one of\nthe fields when they wanted the other.</p>",370 "WMI_WRONG_MAP_ITERATOR": "Inefficient use of keySet iterator instead of entrySet iterator\n\n<p> This method accesses the value of a Map entry, using a key that was retrieved from\na keySet iterator. It is more efficient to use an iterator on the entrySet of the map, to avoid the\nMap.get(key) lookup.</p>",371 "ISC_INSTANTIATE_STATIC_CLASS": "Needless instantiation of class that only supplies static methods\n\n<p> This class allocates an object that is based on a class that only supplies static methods. This object\ndoes not need to be created, just access the static methods directly using the class name as a qualifier.</p>",372 "REC_CATCH_EXCEPTION": "Exception is caught when Exception is not thrown\n\n<p>\n This method uses a try-catch block that catches Exception objects, but Exception is not\n thrown within the try block, and RuntimeException is not explicitly caught. It is a common bug pattern to\n say try { ... } catch (Exception e) { something } as a shorthand for catching a number of types of exception\n each of whose catch blocks is identical, but this construct also accidentally catches RuntimeException as well,\n masking potential bugs.\n </p>\n <p>A better approach is to either explicitly catch the specific exceptions that are thrown,\n or to explicitly catch RuntimeException exception, rethrow it, and then catch all non-Runtime Exceptions, as shown below:</p>\n<pre><code>try {\n ...\n} catch (RuntimeException e) {\n throw e;\n} catch (Exception e) {\n ... deal with all non-runtime exceptions ...\n}\n</code></pre>",373 "FE_TEST_IF_EQUAL_TO_NOT_A_NUMBER": "Doomed test for equality to NaN\n\n<p>\n This code checks to see if a floating point value is equal to the special\n Not A Number value (e.g., <code>if (x == Double.NaN)</code>). However,\n because of the special semantics of <code>NaN</code>, no value\n is equal to <code>Nan</code>, including <code>NaN</code>. Thus,\n <code>x == Double.NaN</code> always evaluates to false.\n\n To check to see if a value contained in <code>x</code>\n is the special Not A Number value, use\n <code>Double.isNaN(x)</code> (or <code>Float.isNaN(x)</code> if\n <code>x</code> is floating point precision).\n </p>",374 "FE_FLOATING_POINT_EQUALITY": "Test for floating point equality\n\n<p>\n This operation compares two floating point values for equality.\n Because floating point calculations may involve rounding,\n calculated float and double values may not be accurate.\n For values that must be precise, such as monetary values,\n consider using a fixed-precision type such as BigDecimal.\n For values that need not be precise, consider comparing for equality\n within some range, for example:\n <code>if ( Math.abs(x - y) &lt; .0000001 )</code>.\n See the Java Language Specification, section 4.2.4.\n </p>",375 "UM_UNNECESSARY_MATH": "Method calls static Math class method on a constant value\n\n<p> This method uses a static method from java.lang.Math on a constant value. This method's\nresult in this case, can be determined statically, and is faster and sometimes more accurate to\njust use the constant. Methods detected are:\n</p>\n<table>\n<tr>\n <th>Method</th> <th>Parameter</th>\n</tr>\n<tr>\n <td>abs</td> <td>-any-</td>\n</tr>\n<tr>\n <td>acos</td> <td>0.0 or 1.0</td>\n</tr>\n<tr>\n <td>asin</td> <td>0.0 or 1.0</td>\n</tr>\n<tr>\n <td>atan</td> <td>0.0 or 1.0</td>\n</tr>\n<tr>\n <td>atan2</td> <td>0.0</td>\n</tr>\n<tr>\n <td>cbrt</td> <td>0.0 or 1.0</td>\n</tr>\n<tr>\n <td>ceil</td> <td>-any-</td>\n</tr>\n<tr>\n <td>cos</td> <td>0.0</td>\n</tr>\n<tr>\n <td>cosh</td> <td>0.0</td>\n</tr>\n<tr>\n <td>exp</td> <td>0.0 or 1.0</td>\n</tr>\n<tr>\n <td>expm1</td> <td>0.0</td>\n</tr>\n<tr>\n <td>floor</td> <td>-any-</td>\n</tr>\n<tr>\n <td>log</td> <td>0.0 or 1.0</td>\n</tr>\n<tr>\n <td>log10</td> <td>0.0 or 1.0</td>\n</tr>\n<tr>\n <td>rint</td> <td>-any-</td>\n</tr>\n<tr>\n <td>round</td> <td>-any-</td>\n</tr>\n<tr>\n <td>sin</td> <td>0.0</td>\n</tr>\n<tr>\n <td>sinh</td> <td>0.0</td>\n</tr>\n<tr>\n <td>sqrt</td> <td>0.0 or 1.0</td>\n</tr>\n<tr>\n <td>tan</td> <td>0.0</td>\n</tr>\n<tr>\n <td>tanh</td> <td>0.0</td>\n</tr>\n<tr>\n <td>toDegrees</td> <td>0.0 or 1.0</td>\n</tr>\n<tr>\n <td>toRadians</td> <td>0.0</td>\n</tr>\n</table>",376 "CD_CIRCULAR_DEPENDENCY": "Test for circular dependencies among classes\n\n<p>\n This class has a circular dependency with other classes. This makes building these classes\n difficult, as each is dependent on the other to build correctly. Consider using interfaces\n to break the hard dependency.\n </p>",377 "RI_REDUNDANT_INTERFACES": "Class implements same interface as superclass\n\n<p>\n This class declares that it implements an interface that is also implemented by a superclass.\n This is redundant because once a superclass implements an interface, all subclasses by default also\n implement this interface. It may point out that the inheritance hierarchy has changed since\n this class was created, and consideration should be given to the ownership of\n the interface's implementation.\n </p>",378 "MTIA_SUSPECT_STRUTS_INSTANCE_FIELD": "Class extends Struts Action class and uses instance variables\n\n<p>\n This class extends from a Struts Action class, and uses an instance member variable. Since only\n one instance of a struts Action class is created by the Struts framework, and used in a\n multithreaded way, this paradigm is highly discouraged and most likely problematic. Consider\n only using method local variables. Only instance fields that are written outside of a monitor\n are reported.\n </p>",379 "MTIA_SUSPECT_SERVLET_INSTANCE_FIELD": "Class extends Servlet class and uses instance variables\n\n<p>\n This class extends from a Servlet class, and uses an instance member variable. Since only\n one instance of a Servlet class is created by the J2EE framework, and used in a\n multithreaded way, this paradigm is highly discouraged and most likely problematic. Consider\n only using method local variables.\n </p>",380 "PS_PUBLIC_SEMAPHORES": "Class exposes synchronization and semaphores in its public interface\n\n<p>\n This class uses synchronization along with wait(), notify() or notifyAll() on itself (the this\n reference). Client classes that use this class, may, in addition, use an instance of this class\n as a synchronizing object. Because two classes are using the same object for synchronization,\n Multithread correctness is suspect. You should not synchronize nor call semaphore methods on\n a public reference. Consider using a internal private member variable to control synchronization.\n </p>",381 "ICAST_INTEGER_MULTIPLY_CAST_TO_LONG": "Result of integer multiplication cast to long\n\n<p>\nThis code performs integer multiply and then converts the result to a long,\nas in:</p>\n<pre><code>long convertDaysToMilliseconds(int days) { return 1000*3600*24*days; }\n</code></pre>\n<p>\nIf the multiplication is done using long arithmetic, you can avoid\nthe possibility that the result will overflow. For example, you\ncould fix the above code to:</p>\n<pre><code>long convertDaysToMilliseconds(int days) { return 1000L*3600*24*days; }\n</code></pre>\n<p>\nor\n</p>\n<pre><code>static final long MILLISECONDS_PER_DAY = 24L*3600*1000;\nlong convertDaysToMilliseconds(int days) { return days * MILLISECONDS_PER_DAY; }\n</code></pre>",382 "ICAST_INT_2_LONG_AS_INSTANT": "int value converted to long and used as absolute time\n\n<p>\nThis code converts a 32-bit int value to a 64-bit long value, and then\npasses that value for a method parameter that requires an absolute time value.\nAn absolute time value is the number\nof milliseconds since the standard base time known as \"the epoch\", namely January 1, 1970, 00:00:00 GMT.\nFor example, the following method, intended to convert seconds since the epoch into a Date, is badly\nbroken:</p>\n<pre><code>Date getDate(int seconds) { return new Date(seconds * 1000); }\n</code></pre>\n<p>The multiplication is done using 32-bit arithmetic, and then converted to a 64-bit value.\nWhen a 32-bit value is converted to 64-bits and used to express an absolute time\nvalue, only dates in December 1969 and January 1970 can be represented.</p>\n\n<p>Correct implementations for the above method are:</p>\n<pre><code>// Fails for dates after 2037\nDate getDate(int seconds) { return new Date(seconds * 1000L); }\n\n// better, works for all dates\nDate getDate(long seconds) { return new Date(seconds * 1000); }\n</code></pre>",383 "ICAST_INT_CAST_TO_FLOAT_PASSED_TO_ROUND": "int value cast to float and then passed to Math.round\n\n<p>\nThis code converts an int value to a float precision\nfloating point number and then\npassing the result to the Math.round() function, which returns the int/long closest\nto the argument. This operation should always be a no-op,\nsince the converting an integer to a float should give a number with no fractional part.\nIt is likely that the operation that generated the value to be passed\nto Math.round was intended to be performed using\nfloating point arithmetic.\n</p>",384 "ICAST_INT_CAST_TO_DOUBLE_PASSED_TO_CEIL": "Integral value cast to double and then passed to Math.ceil\n\n<p>\nThis code converts an integral value (e.g., int or long)\nto a double precision\nfloating point number and then\npassing the result to the Math.ceil() function, which rounds a double to\nthe next higher integer value. This operation should always be a no-op,\nsince the converting an integer to a double should give a number with no fractional part.\nIt is likely that the operation that generated the value to be passed\nto Math.ceil was intended to be performed using double precision\nfloating point arithmetic.\n</p>",385 "ICAST_IDIV_CAST_TO_DOUBLE": "Integral division result cast to double or float\n\n<p>\nThis code casts the result of an integral division (e.g., int or long division)\noperation to double or\nfloat.\nDoing division on integers truncates the result\nto the integer value closest to zero. The fact that the result\nwas cast to double suggests that this precision should have been retained.\nWhat was probably meant was to cast one or both of the operands to\ndouble <em>before</em> performing the division. Here is an example:\n</p>\n<pre><code>int x = 2;\nint y = 5;\n// Wrong: yields result 0.0\ndouble value1 = x / y;\n\n// Right: yields result 0.4\ndouble value2 = x / (double) y;\n</code></pre>",386 "J2EE_STORE_OF_NON_SERIALIZABLE_OBJECT_INTO_SESSION": "Store of non serializable object into HttpSession\n\n<p>\nThis code seems to be storing a non-serializable object into an HttpSession.\nIf this session is passivated or migrated, an error will result.\n</p>",387 "DMI_NONSERIALIZABLE_OBJECT_WRITTEN": "Non serializable object written to ObjectOutput\n\n<p>\nThis code seems to be passing a non-serializable object to the ObjectOutput.writeObject method.\nIf the object is, indeed, non-serializable, an error will result.\n</p>",388 "VA_FORMAT_STRING_NO_PREVIOUS_ARGUMENT": "No previous argument for format string\n\n<p>\nThe format string specifies a relative index to request that the argument for the previous format specifier\nbe reused. However, there is no previous argument.\nFor example,\n</p>\n<p><code>formatter.format(\"%&lt;s %s\", \"a\", \"b\")</code>\n</p>\n<p>would throw a MissingFormatArgumentException when executed.\n</p>",389 "VA_FORMAT_STRING_USES_NEWLINE": "Format string should use %n rather than \n\n\n<p>\nThis format string includes a newline character (\n). In format strings, it is generally\n preferable to use %n, which will produce the platform-specific line separator.\n</p>",390 "VA_FORMAT_STRING_BAD_CONVERSION": "The type of a supplied argument doesn't match format specifier\n\n<p>\nOne of the arguments is incompatible with the corresponding format string specifier.\nAs a result, this will generate a runtime exception when executed.\nFor example, <code>String.format(\"%d\", \"1\")</code> will generate an exception, since\nthe String \"1\" is incompatible with the format specifier %d.\n</p>",391 "VA_FORMAT_STRING_BAD_CONVERSION_TO_BOOLEAN": "Non-Boolean argument formatted using %b format specifier\n\n<p>\nAn argument not of type Boolean is being formatted with a %b format specifier. This won't throw an\nexception; instead, it will print true for any non-null value, and false for null.\nThis feature of format strings is strange, and may not be what you intended.\n</p>",392 "VA_FORMAT_STRING_BAD_CONVERSION_FROM_ARRAY": "Array formatted in useless way using format string\n\n<p>\nOne of the arguments being formatted with a format string is an array. This will be formatted\nusing a fairly useless format, such as [I@304282, which doesn't actually show the contents\nof the array.\nConsider wrapping the array using <code>Arrays.asList(...)</code> before handling it off to a formatted.\n</p>",393 "VA_FORMAT_STRING_ARG_MISMATCH": "Number of format-string arguments does not correspond to number of placeholders\n\n<p>\nA format-string method with a variable number of arguments is called,\nbut the number of arguments passed does not match with the number of\n% placeholders in the format string. This is probably not what the\nauthor intended.\n</p>",394 "VA_FORMAT_STRING_EXPECTED_MESSAGE_FORMAT_SUPPLIED": "MessageFormat supplied where printf style format expected\n\n<p>\nA method is called that expects a Java printf format string and a list of arguments.\nHowever, the format string doesn't contain any format specifiers (e.g., %s) but\ndoes contain message format elements (e.g., {0}). It is likely\nthat the code is supplying a MessageFormat string when a printf-style format string\nis required. At runtime, all of the arguments will be ignored\nand the format string will be returned exactly as provided without any formatting.\n</p>",395 "VA_FORMAT_STRING_EXTRA_ARGUMENTS_PASSED": "More arguments are passed than are actually used in the format string\n\n<p>\nA format-string method with a variable number of arguments is called,\nbut more arguments are passed than are actually used by the format string.\nThis won't cause a runtime exception, but the code may be silently omitting\ninformation that was intended to be included in the formatted string.\n</p>",396 "VA_FORMAT_STRING_ILLEGAL": "Illegal format string\n\n<p>\nThe format string is syntactically invalid,\nand a runtime exception will occur when\nthis statement is executed.\n</p>",397 "VA_FORMAT_STRING_MISSING_ARGUMENT": "Format string references missing argument\n\n<p>\nNot enough arguments are passed to satisfy a placeholder in the format string.\nA runtime exception will occur when\nthis statement is executed.\n</p>",398 "VA_FORMAT_STRING_BAD_ARGUMENT": "Format string placeholder incompatible with passed argument\n\n<p>\nThe format string placeholder is incompatible with the corresponding\nargument. For example,\n<code>\n System.out.println(\"%d\n\", \"hello\");\n</code>\n<p>The %d placeholder requires a numeric argument, but a string value is\npassed instead.\nA runtime exception will occur when\nthis statement is executed.\n</p>",399 "VA_PRIMITIVE_ARRAY_PASSED_TO_OBJECT_VARARG": "Primitive array passed to function expecting a variable number of object arguments\n\n<p>\nThis code passes a primitive array to a function that takes a variable number of object arguments.\nThis creates an array of length one to hold the primitive array and passes it to the function.\n</p>",400 "BC_EQUALS_METHOD_SHOULD_WORK_FOR_ALL_OBJECTS": "Equals method should not assume anything about the type of its argument\n\n<p>\nThe <code>equals(Object o)</code> method shouldn't make any assumptions\nabout the type of <code>o</code>. It should simply return\nfalse if <code>o</code> is not the same type as <code>this</code>.\n</p>",401 "BC_BAD_CAST_TO_ABSTRACT_COLLECTION": "Questionable cast to abstract collection \n\n<p>\nThis code casts a Collection to an abstract collection\n(such as <code>List</code>, <code>Set</code>, or <code>Map</code>).\nEnsure that you are guaranteed that the object is of the type\nyou are casting to. If all you need is to be able\nto iterate through a collection, you don't need to cast it to a Set or List.\n</p>",402 "BC_IMPOSSIBLE_CAST_PRIMITIVE_ARRAY": "Impossible cast involving primitive array\n\n<p>\nThis cast will always throw a ClassCastException.\n</p>",403 "BC_IMPOSSIBLE_CAST": "Impossible cast\n\n<p>\nThis cast will always throw a ClassCastException.\nSpotBugs tracks type information from instanceof checks,\nand also uses more precise information about the types\nof values returned from methods and loaded from fields.\nThus, it may have more precise information that just\nthe declared type of a variable, and can use this to determine\nthat a cast will always throw an exception at runtime.\n\n</p>",404 "BC_IMPOSSIBLE_DOWNCAST": "Impossible downcast\n\n<p>\nThis cast will always throw a ClassCastException.\nThe analysis believes it knows\nthe precise type of the value being cast, and the attempt to\ndowncast it to a subtype will always fail by throwing a ClassCastException.\n</p>",405 "BC_IMPOSSIBLE_DOWNCAST_OF_TOARRAY": "Impossible downcast of toArray() result\n\n<p>\nThis code is casting the result of calling <code>toArray()</code> on a collection\nto a type more specific than <code>Object[]</code>, as in:</p>\n<pre><code>String[] getAsArray(Collection&lt;String&gt; c) {\n return (String[]) c.toArray();\n}\n</code></pre>\n<p>This will usually fail by throwing a ClassCastException. The <code>toArray()</code>\nof almost all collections return an <code>Object[]</code>. They can't really do anything else,\nsince the Collection object has no reference to the declared generic type of the collection.\n<p>The correct way to do get an array of a specific type from a collection is to use\n <code>c.toArray(new String[]);</code>\n or <code>c.toArray(new String[c.size()]);</code> (the latter is slightly more efficient).\n<p>There is one common/known exception to this. The <code>toArray()</code>\nmethod of lists returned by <code>Arrays.asList(...)</code> will return a covariantly\ntyped array. For example, <code>Arrays.asArray(new String[] { \"a\" }).toArray()</code>\nwill return a <code>String []</code>. SpotBugs attempts to detect and suppress\nsuch cases, but may miss some.\n</p>",406 "NP_NULL_INSTANCEOF": "A known null value is checked to see if it is an instance of a type\n\n<p>\nThis instanceof test will always return false, since the value being checked is guaranteed to be null.\nAlthough this is safe, make sure it isn't\nan indication of some misunderstanding or some other logic error.\n</p>",407 "BC_NULL_INSTANCEOF": "A known null value is checked to see if it is an instance of a type\n\n<p>\nThis instanceof test will always return false, since the value being checked is guaranteed to be null.\nAlthough this is safe, make sure it isn't\nan indication of some misunderstanding or some other logic error.\n</p>",408 "BC_IMPOSSIBLE_INSTANCEOF": "instanceof will always return false\n\n<p>\nThis instanceof test will always return false. Although this is safe, make sure it isn't\nan indication of some misunderstanding or some other logic error.\n</p>",409 "BC_VACUOUS_INSTANCEOF": "instanceof will always return true\n\n<p>\nThis instanceof test will always return true (unless the value being tested is null).\nAlthough this is safe, make sure it isn't\nan indication of some misunderstanding or some other logic error.\nIf you really want to test the value for being null, perhaps it would be clearer to do\nbetter to do a null test rather than an instanceof test.\n</p>",410 "BC_UNCONFIRMED_CAST": "Unchecked/unconfirmed cast\n\n<p>\nThis cast is unchecked, and not all instances of the type casted from can be cast to\nthe type it is being cast to. Check that your program logic ensures that this\ncast will not fail.\n</p>",411 "BC_UNCONFIRMED_CAST_OF_RETURN_VALUE": "Unchecked/unconfirmed cast of return value from method\n\n<p>\nThis code performs an unchecked cast of the return value of a method.\nThe code might be calling the method in such a way that the cast is guaranteed to be\nsafe, but SpotBugs is unable to verify that the cast is safe. Check that your program logic ensures that this\ncast will not fail.\n</p>",412 "BC_BAD_CAST_TO_CONCRETE_COLLECTION": "Questionable cast to concrete collection\n\n<p>\nThis code casts an abstract collection (such as a Collection, List, or Set)\nto a specific concrete implementation (such as an ArrayList or HashSet).\nThis might not be correct, and it may make your code fragile, since\nit makes it harder to switch to other concrete implementations at a future\npoint. Unless you have a particular reason to do so, just use the abstract\ncollection class.\n</p>",413 "RE_POSSIBLE_UNINTENDED_PATTERN": "\".\" or \"|\" used for regular expression\n\n<p>\nA String function is being invoked and \".\" or \"|\" is being passed\nto a parameter that takes a regular expression as an argument. Is this what you intended?\nFor example\n</p>\n<ul>\n<li>s.replaceAll(\".\", \"/\") will return a String in which <em>every</em> character has been replaced by a '/' character</li>\n<li>s.split(\".\") <em>always</em> returns a zero length array of String</li>\n<li>\"ab|cd\".replaceAll(\"|\", \"/\") will return \"/a/b/|/c/d/\"</li>\n<li>\"ab|cd\".split(\"|\") will return array with six (!) elements: [, a, b, |, c, d]</li>\n</ul>",414 "RE_BAD_SYNTAX_FOR_REGULAR_EXPRESSION": "Invalid syntax for regular expression\n\n<p>\nThe code here uses a regular expression that is invalid according to the syntax\nfor regular expressions. This statement will throw a PatternSyntaxException when\nexecuted.\n</p>",415 "RE_CANT_USE_FILE_SEPARATOR_AS_REGULAR_EXPRESSION": "File.separator used for regular expression\n\n<p>\nThe code here uses <code>File.separator</code>\nwhere a regular expression is required. This will fail on Windows\nplatforms, where the <code>File.separator</code> is a backslash, which is interpreted in a\nregular expression as an escape character. Among other options, you can just use\n<code>File.separatorChar=='\\' ? \"\\\\\" : File.separator</code> instead of\n<code>File.separator</code>\n\n</p>",416 "DLS_OVERWRITTEN_INCREMENT": "Overwritten increment\n\n<p>\nThe code performs an increment operation (e.g., <code>i++</code>) and then\nimmediately overwrites it. For example, <code>i = i++</code> immediately\noverwrites the incremented value with the original value.\n</p>",417 "ICAST_QUESTIONABLE_UNSIGNED_RIGHT_SHIFT": "Unsigned right shift cast to short/byte\n\n<p>\nThe code performs an unsigned right shift, whose result is then\ncast to a short or byte, which discards the upper bits of the result.\nSince the upper bits are discarded, there may be no difference between\na signed and unsigned right shift (depending upon the size of the shift).\n</p>",418 "BSHIFT_WRONG_ADD_PRIORITY": "Possible bad parsing of shift operation\n\n<p>\nThe code performs an operation like (x &lt;&lt; 8 + y). Although this might be correct, probably it was meant\nto perform (x &lt;&lt; 8) + y, but shift operation has\na lower precedence, so it's actually parsed as x &lt;&lt; (8 + y).\n</p>",419 "ICAST_BAD_SHIFT_AMOUNT": "32 bit int shifted by an amount not in the range -31..31\n\n<p>\nThe code performs shift of a 32 bit int by a constant amount outside\nthe range -31..31.\nThe effect of this is to use the lower 5 bits of the integer\nvalue to decide how much to shift by (e.g., shifting by 40 bits is the same as shifting by 8 bits,\nand shifting by 32 bits is the same as shifting by zero bits). This probably isn't what was expected,\nand it is at least confusing.\n</p>",420 "IM_MULTIPLYING_RESULT_OF_IREM": "Integer multiply of result of integer remainder\n\n<p>\nThe code multiplies the result of an integer remaining by an integer constant.\nBe sure you don't have your operator precedence confused. For example\ni % 60 * 1000 is (i % 60) * 1000, not i % (60 * 1000).\n</p>",421 "DMI_INVOKING_HASHCODE_ON_ARRAY": "Invocation of hashCode on an array\n\n<p>\nThe code invokes hashCode on an array. Calling hashCode on\nan array returns the same value as System.identityHashCode, and ignores\nthe contents and length of the array. If you need a hashCode that\ndepends on the contents of an array <code>a</code>,\nuse <code>java.util.Arrays.hashCode(a)</code>.\n\n</p>",422 "DMI_INVOKING_TOSTRING_ON_ARRAY": "Invocation of toString on an array\n\n<p>\nThe code invokes toString on an array, which will generate a fairly useless result\nsuch as [C@16f0472. Consider using Arrays.toString to convert the array into a readable\nString that gives the contents of the array. See Programming Puzzlers, chapter 3, puzzle 12.\n</p>",423 "DMI_INVOKING_TOSTRING_ON_ANONYMOUS_ARRAY": "Invocation of toString on an unnamed array\n\n<p>\nThe code invokes toString on an (anonymous) array. Calling toString on an array generates a fairly useless result\nsuch as [C@16f0472. Consider using Arrays.toString to convert the array into a readable\nString that gives the contents of the array. See Programming Puzzlers, chapter 3, puzzle 12.\n</p>",424 "IM_AVERAGE_COMPUTATION_COULD_OVERFLOW": "Computation of average could overflow\n\n<p>The code computes the average of two integers using either division or signed right shift,\nand then uses the result as the index of an array.\nIf the values being averaged are very large, this can overflow (resulting in the computation\nof a negative average). Assuming that the result is intended to be nonnegative, you\ncan use an unsigned right shift instead. In other words, rather that using <code>(low+high)/2</code>,\nuse <code>(low+high) &gt;&gt;&gt; 1</code>\n</p>\n<p>This bug exists in many earlier implementations of binary search and merge sort.\nMartin Buchholz <a href=\"http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6412541\">found and fixed it</a>\nin the JDK libraries, and Joshua Bloch\n<a href=\"http://googleresearch.blogspot.com/2006/06/extra-extra-read-all-about-it-nearly.html\">widely\npublicized the bug pattern</a>.\n</p>",425 "IM_BAD_CHECK_FOR_ODD": "Check for oddness that won't work for negative numbers \n\n<p>\nThe code uses x % 2 == 1 to check to see if a value is odd, but this won't work\nfor negative numbers (e.g., (-5) % 2 == -1). If this code is intending to check\nfor oddness, consider using x &amp; 1 == 1, or x % 2 != 0.\n</p>",426 "DMI_HARDCODED_ABSOLUTE_FILENAME": "Code contains a hard coded reference to an absolute pathname\n\n<p>This code constructs a File object using a hard coded to an absolute pathname\n(e.g., <code>new File(\"/home/dannyc/workspace/j2ee/src/share/com/sun/enterprise/deployment\");</code>\n</p>",427 "DMI_BAD_MONTH": "Bad constant value for month\n\n<p>\nThis code passes a constant month\nvalue outside the expected range of 0..11 to a method.\n</p>",428 "DMI_USELESS_SUBSTRING": "Invocation of substring(0), which returns the original value\n\n<p>\nThis code invokes substring(0) on a String, which returns the original value.\n</p>",429 "DMI_CALLING_NEXT_FROM_HASNEXT": "hasNext method invokes next\n\n<p>\nThe hasNext() method invokes the next() method. This is almost certainly wrong,\nsince the hasNext() method is not supposed to change the state of the iterator,\nand the next method is supposed to change the state of the iterator.\n</p>",430 "SWL_SLEEP_WITH_LOCK_HELD": "Method calls Thread.sleep() with a lock held\n\n<p>\n This method calls Thread.sleep() with a lock held. This may result\n in very poor performance and scalability, or a deadlock, since other threads may\n be waiting to acquire the lock. It is a much better idea to call\n wait() on the lock, which releases the lock and allows other threads\n to run.\n </p>",431 "DB_DUPLICATE_BRANCHES": "Method uses the same code for two branches\n\n<p>\n This method uses the same code to implement two branches of a conditional branch.\n Check to ensure that this isn't a coding mistake.\n </p>",432 "DB_DUPLICATE_SWITCH_CLAUSES": "Method uses the same code for two switch clauses\n\n<p>\n This method uses the same code to implement two clauses of a switch statement.\n This could be a case of duplicate code, but it might also indicate\n a coding mistake.\n </p>",433 "IMA_INEFFICIENT_MEMBER_ACCESS": "Method accesses a private member variable of owning class\n\n<p>\n This method of an inner class reads from or writes to a private member variable of the owning class,\n or calls a private method of the owning class. The compiler must generate a special method to access this\n private member, causing this to be less efficient. Relaxing the protection of the member variable or method\n will allow the compiler to treat this as a normal access.\n </p>",434 "XFB_XML_FACTORY_BYPASS": "Method directly allocates a specific implementation of xml interfaces\n\n<p>\n This method allocates a specific implementation of an xml interface. It is preferable to use\n the supplied factory classes to create these objects so that the implementation can be\n changed at runtime. See\n </p>\n <ul>\n <li>javax.xml.parsers.DocumentBuilderFactory</li>\n <li>javax.xml.parsers.SAXParserFactory</li>\n <li>javax.xml.transform.TransformerFactory</li>\n <li>org.w3c.dom.Document.create<i>XXXX</i></li>\n </ul>\n <p>for details.</p>",435 "USM_USELESS_SUBCLASS_METHOD": "Method superfluously delegates to parent class method\n\n<p>\n This derived method merely calls the same superclass method passing in the exact parameters\n received. This method can be removed, as it provides no additional value.\n </p>",436 "USM_USELESS_ABSTRACT_METHOD": "Abstract Method is already defined in implemented interface\n\n<p>\n This abstract method is already defined in an interface that is implemented by this abstract\n class. This method can be removed, as it provides no additional value.\n </p>",437 "CI_CONFUSED_INHERITANCE": "Class is final but declares protected field\n\n<p>\n This class is declared to be final, but declares fields to be protected. Since the class\n is final, it can not be derived from, and the use of protected is confusing. The access\n modifier for the field should be changed to private or public to represent the true\n use for the field.\n </p>",438 "QBA_QUESTIONABLE_BOOLEAN_ASSIGNMENT": "Method assigns boolean literal in boolean expression\n\n<p>\n This method assigns a literal boolean value (true or false) to a boolean variable inside\n an if or while expression. Most probably this was supposed to be a boolean comparison using\n ==, not an assignment using =.\n </p>",439 "VR_UNRESOLVABLE_REFERENCE": "Class makes reference to unresolvable class or method\n\n<p>\n This class makes a reference to a class or method that can not be\n resolved using against the libraries it is being analyzed with.\n </p>",440 "GC_UNCHECKED_TYPE_IN_GENERIC_CALL": "Unchecked type in generic call\n\n<p> This call to a generic collection method passes an argument\n while compile type Object where a specific type from\n the generic type parameters is expected.\n Thus, neither the standard Java type system nor static analysis\n can provide useful information on whether the\n object being passed as a parameter is of an appropriate type.\n </p>",441 "GC_UNRELATED_TYPES": "No relationship between generic parameter and method argument\n\n<p> This call to a generic collection method contains an argument\n with an incompatible class from that of the collection's parameter\n (i.e., the type of the argument is neither a supertype nor a subtype\n of the corresponding generic type argument).\n Therefore, it is unlikely that the collection contains any objects\n that are equal to the method argument used here.\n Most likely, the wrong value is being passed to the method.</p>\n <p>In general, instances of two unrelated classes are not equal.\n For example, if the <code>Foo</code> and <code>Bar</code> classes\n are not related by subtyping, then an instance of <code>Foo</code>\n should not be equal to an instance of <code>Bar</code>.\n Among other issues, doing so will likely result in an equals method\n that is not symmetrical. For example, if you define the <code>Foo</code> class\n so that a <code>Foo</code> can be equal to a <code>String</code>,\n your equals method isn't symmetrical since a <code>String</code> can only be equal\n to a <code>String</code>.\n </p>\n <p>In rare cases, people do define nonsymmetrical equals methods and still manage to make\n their code work. Although none of the APIs document or guarantee it, it is typically\n the case that if you check if a <code>Collection&lt;String&gt;</code> contains\n a <code>Foo</code>, the equals method of argument (e.g., the equals method of the\n <code>Foo</code> class) used to perform the equality checks.\n </p>",442 "DMI_COLLECTIONS_SHOULD_NOT_CONTAIN_THEMSELVES": "Collections should not contain themselves\n\n<p> This call to a generic collection's method would only make sense if a collection contained\nitself (e.g., if <code>s.contains(s)</code> were true). This is unlikely to be true and would cause\nproblems if it were true (such as the computation of the hash code resulting in infinite recursion).\nIt is likely that the wrong value is being passed as a parameter.\n </p>",443 "DMI_VACUOUS_SELF_COLLECTION_CALL": "Vacuous call to collections\n\n<p> This call doesn't make sense. For any collection <code>c</code>, calling <code>c.containsAll(c)</code> should\nalways be true, and <code>c.retainAll(c)</code> should have no effect.\n </p>",444 "PZ_DONT_REUSE_ENTRY_OBJECTS_IN_ITERATORS": "Don't reuse entry objects in iterators\n\n<p> The entrySet() method is allowed to return a view of the\n underlying Map in which an Iterator and Map.Entry. This clever\n idea was used in several Map implementations, but introduces the possibility\n of nasty coding mistakes. If a map <code>m</code> returns\n such an iterator for an entrySet, then\n <code>c.addAll(m.entrySet())</code> will go badly wrong. All of\n the Map implementations in OpenJDK 1.7 have been rewritten to avoid this,\n you should to.\n </p>",445 "DMI_ENTRY_SETS_MAY_REUSE_ENTRY_OBJECTS": "Adding elements of an entry set may fail due to reuse of Entry objects\n\n<p> The entrySet() method is allowed to return a view of the\n underlying Map in which a single Entry object is reused and returned\n during the iteration. As of Java 1.6, both IdentityHashMap\n and EnumMap did so. When iterating through such a Map,\n the Entry value is only valid until you advance to the next iteration.\n If, for example, you try to pass such an entrySet to an addAll method,\n things will go badly wrong.\n </p>",446 "DMI_USING_REMOVEALL_TO_CLEAR_COLLECTION": "Don't use removeAll to clear a collection\n\n<p> If you want to remove all elements from a collection <code>c</code>, use <code>c.clear</code>,\nnot <code>c.removeAll(c)</code>. Calling <code>c.removeAll(c)</code> to clear a collection\nis less clear, susceptible to errors from typos, less efficient and\nfor some collections, might throw a <code>ConcurrentModificationException</code>.\n </p>",447 "STCAL_STATIC_CALENDAR_INSTANCE": "Static Calendar field\n\n<p>Even though the JavaDoc does not contain a hint about it, Calendars are inherently unsafe for multithreaded use.\nSharing a single instance across thread boundaries without proper synchronization will result in erratic behavior of the\napplication. Under 1.4 problems seem to surface less often than under Java 5 where you will probably see\nrandom ArrayIndexOutOfBoundsExceptions or IndexOutOfBoundsExceptions in sun.util.calendar.BaseCalendar.getCalendarDateFromFixedDate().</p>\n<p>You may also experience serialization problems.</p>\n<p>Using an instance field is recommended.</p>\n<p>For more information on this see <a href=\"http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6231579\">JDK Bug #6231579</a>\nand <a href=\"http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6178997\">JDK Bug #6178997</a>.</p>",448 "STCAL_INVOKE_ON_STATIC_CALENDAR_INSTANCE": "Call to static Calendar\n\n<p>Even though the JavaDoc does not contain a hint about it, Calendars are inherently unsafe for multithreaded use.\nThe detector has found a call to an instance of Calendar that has been obtained via a static\nfield. This looks suspicious.</p>\n<p>For more information on this see <a href=\"http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6231579\">JDK Bug #6231579</a>\nand <a href=\"http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6178997\">JDK Bug #6178997</a>.</p>",449 "STCAL_STATIC_SIMPLE_DATE_FORMAT_INSTANCE": "Static DateFormat\n\n<p>As the JavaDoc states, DateFormats are inherently unsafe for multithreaded use.\nSharing a single instance across thread boundaries without proper synchronization will result in erratic behavior of the\napplication.</p>\n<p>You may also experience serialization problems.</p>\n<p>Using an instance field is recommended.</p>\n<p>For more information on this see <a href=\"http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6231579\">JDK Bug #6231579</a>\nand <a href=\"http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6178997\">JDK Bug #6178997</a>.</p>",450 "STCAL_INVOKE_ON_STATIC_DATE_FORMAT_INSTANCE": "Call to static DateFormat\n\n<p>As the JavaDoc states, DateFormats are inherently unsafe for multithreaded use.\nThe detector has found a call to an instance of DateFormat that has been obtained via a static\nfield. This looks suspicious.</p>\n<p>For more information on this see <a href=\"http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6231579\">JDK Bug #6231579</a>\nand <a href=\"http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6178997\">JDK Bug #6178997</a>.</p>",451 "TQ_COMPARING_VALUES_WITH_INCOMPATIBLE_TYPE_QUALIFIERS": "Comparing values with incompatible type qualifiers\n\n<p>\n A value specified as carrying a type qualifier annotation is\n compared with a value that doesn't ever carry that qualifier.\n </p>\n\n <p>\n More precisely, a value annotated with a type qualifier specifying when=ALWAYS\n is compared with a value that where the same type qualifier specifies when=NEVER.\n </p>\n\n <p>\n For example, say that @NonNegative is a nickname for\n the type qualifier annotation @Negative(when=When.NEVER).\n The following code will generate this warning because\n the return statement requires a @NonNegative value,\n but receives one that is marked as @Negative.\n </p>\n<pre><code>public boolean example(@Negative Integer value1, @NonNegative Integer value2) {\n return value1.equals(value2);\n}\n</code></pre>",452 "TQ_ALWAYS_VALUE_USED_WHERE_NEVER_REQUIRED": "Value annotated as carrying a type qualifier used where a value that must not carry that qualifier is required\n\n<p>\n A value specified as carrying a type qualifier annotation is\n consumed in a location or locations requiring that the value not\n carry that annotation.\n </p>\n\n <p>\n More precisely, a value annotated with a type qualifier specifying when=ALWAYS\n is guaranteed to reach a use or uses where the same type qualifier specifies when=NEVER.\n </p>\n\n <p>\n For example, say that @NonNegative is a nickname for\n the type qualifier annotation @Negative(when=When.NEVER).\n The following code will generate this warning because\n the return statement requires a @NonNegative value,\n but receives one that is marked as @Negative.\n </p>\n<pre><code>public @NonNegative Integer example(@Negative Integer value) {\n return value;\n}\n</code></pre>",453 "TQ_UNKNOWN_VALUE_USED_WHERE_ALWAYS_STRICTLY_REQUIRED": "Value without a type qualifier used where a value is required to have that qualifier\n\n<p>\n A value is being used in a way that requires the value be annotation with a type qualifier.\n The type qualifier is strict, so the tool rejects any values that do not have\n the appropriate annotation.\n </p>\n\n <p>\n To coerce a value to have a strict annotation, define an identity function where the return value is annotated\n with the strict annotation.\n This is the only way to turn a non-annotated value into a value with a strict type qualifier annotation.\n </p>",454 "TQ_NEVER_VALUE_USED_WHERE_ALWAYS_REQUIRED": "Value annotated as never carrying a type qualifier used where value carrying that qualifier is required\n\n<p>\n A value specified as not carrying a type qualifier annotation is guaranteed\n to be consumed in a location or locations requiring that the value does\n carry that annotation.\n </p>\n\n <p>\n More precisely, a value annotated with a type qualifier specifying when=NEVER\n is guaranteed to reach a use or uses where the same type qualifier specifies when=ALWAYS.\n </p>\n\n <p>\n TODO: example\n </p>",455 "TQ_MAYBE_SOURCE_VALUE_REACHES_ALWAYS_SINK": "Value that might not carry a type qualifier is always used in a way requires that type qualifier\n\n<p>\n A value that is annotated as possibility not being an instance of\n the values denoted by the type qualifier, and the value is guaranteed to be used\n in a way that requires values denoted by that type qualifier.\n </p>",456 "TQ_MAYBE_SOURCE_VALUE_REACHES_NEVER_SINK": "Value that might carry a type qualifier is always used in a way prohibits it from having that type qualifier\n\n<p>\n A value that is annotated as possibility being an instance of\n the values denoted by the type qualifier, and the value is guaranteed to be used\n in a way that prohibits values denoted by that type qualifier.\n </p>",457 "TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_NEVER_SINK": "Value required to not have type qualifier, but marked as unknown\n\n<p>\n A value is used in a way that requires it to be never be a value denoted by a type qualifier, but\n there is an explicit annotation stating that it is not known where the value is prohibited from having that type qualifier.\n Either the usage or the annotation is incorrect.\n </p>",458 "TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_ALWAYS_SINK": "Value required to have type qualifier, but marked as unknown\n\n<p>\n A value is used in a way that requires it to be always be a value denoted by a type qualifier, but\n there is an explicit annotation stating that it is not known where the value is required to have that type qualifier.\n Either the usage or the annotation is incorrect.\n </p>",459 "IO_APPENDING_TO_OBJECT_OUTPUT_STREAM": "Doomed attempt to append to an object output stream\n\n<p>\n This code opens a file in append mode and then wraps the result in an object output stream.\n This won't allow you to append to an existing object output stream stored in a file. If you want to be\n able to append to an object output stream, you need to keep the object output stream open.\n </p>\n <p>The only situation in which opening a file in append mode and the writing an object output stream\n could work is if on reading the file you plan to open it in random access mode and seek to the byte offset\n where the append started.\n </p>\n\n <p>\n TODO: example.\n </p>",460 "WL_USING_GETCLASS_RATHER_THAN_CLASS_LITERAL": "Synchronization on getClass rather than class literal\n\n<p>\n This instance method synchronizes on <code>this.getClass()</code>. If this class is subclassed,\n subclasses will synchronize on the class object for the subclass, which isn't likely what was intended.\n For example, consider this code from java.awt.Label:</p>\n<pre><code>private static final String base = \"label\";\nprivate static int nameCounter = 0;\n\nString constructComponentName() {\n synchronized (getClass()) {\n return base + nameCounter++;\n }\n}\n</code></pre>\n <p>Subclasses of <code>Label</code> won't synchronize on the same subclass, giving rise to a datarace.\n Instead, this code should be synchronizing on <code>Label.class</code></p>\n<pre><code>private static final String base = \"label\";\nprivate static int nameCounter = 0;\n\nString constructComponentName() {\n synchronized (Label.class) {\n return base + nameCounter++;\n }\n}\n</code></pre>\n <p>Bug pattern contributed by Jason Mehrens</p>",461 "OBL_UNSATISFIED_OBLIGATION": "Method may fail to clean up stream or resource\n\n<p>\n This method may fail to clean up (close, dispose of) a stream,\n database object, or other\n resource requiring an explicit cleanup operation.\n </p>\n\n <p>\n In general, if a method opens a stream or other resource,\n the method should use a try/finally block to ensure that\n the stream or resource is cleaned up before the method\n returns.\n </p>\n\n <p>\n This bug pattern is essentially the same as the\n OS_OPEN_STREAM and ODR_OPEN_DATABASE_RESOURCE\n bug patterns, but is based on a different\n (and hopefully better) static analysis technique.\n We are interested is getting feedback about the\n usefulness of this bug pattern.\n For sending feedback, check:\n </p>\n <ul>\n <li><a href=\"https://github.com/spotbugs/spotbugs/blob/master/CONTRIBUTING.md\">contributing guideline</a></li>\n <li><a href=\"https://github.com/spotbugs/discuss/issues?q=\">malinglist</a></li>\n </ul>\n\n <p>\n In particular,\n the false-positive suppression heuristics for this\n bug pattern have not been extensively tuned, so\n reports about false positives are helpful to us.\n </p>\n\n <p>\n See Weimer and Necula, <i>Finding and Preventing Run-Time Error Handling Mistakes</i>, for\n a description of the analysis technique.\n </p>",462 "OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE": "Method may fail to clean up stream or resource on checked exception\n\n<p>\n This method may fail to clean up (close, dispose of) a stream,\n database object, or other\n resource requiring an explicit cleanup operation.\n </p>\n\n <p>\n In general, if a method opens a stream or other resource,\n the method should use a try/finally block to ensure that\n the stream or resource is cleaned up before the method\n returns.\n </p>\n\n <p>\n This bug pattern is essentially the same as the\n OS_OPEN_STREAM and ODR_OPEN_DATABASE_RESOURCE\n bug patterns, but is based on a different\n (and hopefully better) static analysis technique.\n We are interested is getting feedback about the\n usefulness of this bug pattern.\n For sending feedback, check:\n </p>\n <ul>\n <li><a href=\"https://github.com/spotbugs/spotbugs/blob/master/CONTRIBUTING.md\">contributing guideline</a></li>\n <li><a href=\"https://github.com/spotbugs/discuss/issues?q=\">malinglist</a></li>\n </ul>\n\n <p>\n In particular,\n the false-positive suppression heuristics for this\n bug pattern have not been extensively tuned, so\n reports about false positives are helpful to us.\n </p>\n\n <p>\n See Weimer and Necula, <i>Finding and Preventing Run-Time Error Handling Mistakes</i>, for\n a description of the analysis technique.\n </p>",463 "FB_UNEXPECTED_WARNING": "Unexpected/undesired warning from SpotBugs\n\n<p>SpotBugs generated a warning that, according to a @NoWarning annotated,\n is unexpected or undesired.</p>",464 "FB_MISSING_EXPECTED_WARNING": "Missing expected or desired warning from SpotBugs\n\n<p>SpotBugs didn't generate generated a warning that, according to a @ExpectedWarning annotated,\n is expected or desired.</p>",465 "RV_RETURN_VALUE_OF_PUTIFABSENT_IGNORED": "Return value of putIfAbsent ignored, value passed to putIfAbsent reused\n\nThe <code>putIfAbsent</code> method is typically used to ensure that a\n single value is associated with a given key (the first value for which put\n if absent succeeds).\n If you ignore the return value and retain a reference to the value passed in,\n you run the risk of retaining a value that is not the one that is associated with the key in the map.\n If it matters which one you use and you use the one that isn't stored in the map,\n your program will behave incorrectly.",466 "LG_LOST_LOGGER_DUE_TO_WEAK_REFERENCE": "Potential lost logger changes due to weak reference in OpenJDK\n\n<p>OpenJDK introduces a potential incompatibility.\n In particular, the java.util.logging.Logger behavior has\n changed. Instead of using strong references, it now uses weak references\n internally. That's a reasonable change, but unfortunately some code relies on\n the old behavior - when changing logger configuration, it simply drops the\n logger reference. That means that the garbage collector is free to reclaim\n that memory, which means that the logger configuration is lost. For example,\nconsider:\n</p>\n<pre><code>public static void initLogging() throws Exception {\n Logger logger = Logger.getLogger(\"edu.umd.cs\");\n logger.addHandler(new FileHandler()); // call to change logger configuration\n logger.setUseParentHandlers(false); // another call to change logger configuration\n}\n</code></pre>\n<p>The logger reference is lost at the end of the method (it doesn't\nescape the method), so if you have a garbage collection cycle just\nafter the call to initLogging, the logger configuration is lost\n(because Logger only keeps weak references).</p>\n<pre><code>public static void main(String[] args) throws Exception {\n initLogging(); // adds a file handler to the logger\n System.gc(); // logger configuration lost\n Logger.getLogger(\"edu.umd.cs\").info(\"Some message\"); // this isn't logged to the file as expected\n}\n</code></pre>\n<p><em>Ulf Ochsenfahrt and Eric Fellheimer</em></p>",467 "AT_OPERATION_SEQUENCE_ON_CONCURRENT_ABSTRACTION": "Sequence of calls to concurrent abstraction may not be atomic\n\n<p>This code contains a sequence of calls to a concurrent abstraction\n (such as a concurrent hash map).\n These calls will not be executed atomically.",468 "DM_DEFAULT_ENCODING": "Reliance on default encoding\n\n<p> 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. </p>",469 "NP_METHOD_PARAMETER_RELAXING_ANNOTATION": "Method tightens nullness annotation on parameter\n\n<p>\n A method should always implement the contract of a method it overrides. Thus, if a method takes a parameter\n that is marked as @Nullable, you shouldn't override that method in a subclass with a method where that parameter is @Nonnull.\n Doing so violates the contract that the method should handle a null parameter.\n </p>",470 "NP_METHOD_PARAMETER_TIGHTENS_ANNOTATION": "Method tightens nullness annotation on parameter\n\n<p>\n A method should always implement the contract of a method it overrides. Thus, if a method takes a parameter\n that is marked as @Nullable, you shouldn't override that method in a subclass with a method where that parameter is @Nonnull.\n Doing so violates the contract that the method should handle a null parameter.\n </p>",471 "NP_METHOD_RETURN_RELAXING_ANNOTATION": "Method relaxes nullness annotation on return value\n\n<p>\n A method should always implement the contract of a method it overrides. Thus, if a method takes is annotated\n as returning a @Nonnull value,\n you shouldn't override that method in a subclass with a method annotated as returning a @Nullable or @CheckForNull value.\n Doing so violates the contract that the method shouldn't return null.\n </p>",472}...

Full Screen

Full Screen

xhtml.go

Source:xhtml.go Github

copy

Full Screen

1package processor2import (3 "errors"4 "fmt"5 "html"6 "net/url"7 "path"8 "path/filepath"9 "strconv"10 "strings"11 "time"12 "unicode"13 "unicode/utf8"14 "github.com/asaskevich/govalidator"15 "go.uber.org/zap"16 tc "golang.org/x/text/cases"17 "fb2converter/config"18 "fb2converter/etree"19)20// processBody parses fb2 document body and produces formatted output.21func (p *Processor) processBody(index int, from *etree.Element) (err error) {22 // setup processing context23 if index != 0 {24 // always ignore first body name - it is main body25 p.ctx().bodyName = getAttrValue(from, "name")26 }27 p.ctx().header = 028 p.ctx().firstBodyTitle = true29 p.env.Log.Debug("Parsing body - start", zap.String("name", p.ctx().bodyName))30 defer func(start time.Time) {31 p.env.Log.Debug("Parsing body - done",32 zap.Duration("elapsed", time.Since(start)),33 zap.String("name", p.ctx().bodyName),34 )35 }(time.Now())36 if p.notesMode == NDefault || !IsOneOf(p.ctx().bodyName, p.env.Cfg.Doc.Notes.BodyNames) {37 // initialize first XHTML buffer38 ns := []*etree.Attr{attr("xmlns", `http://www.w3.org/1999/xhtml`)}39 if p.notesMode == NFloatNew {40 ns = append(ns, attr("xmlns:epub", `http://www.idpf.org/2007/ops`))41 }42 to, f := p.ctx().createXHTML("", ns...)43 p.Book.Files = append(p.Book.Files, f)44 p.Book.Pages[f.fname] = 045 return p.transfer(from, to)46 }47 if p.notesMode != NFloat && p.notesMode != NFloatOld && p.notesMode != NFloatNew {48 // NOTE: for block and inline notes we do not need to save XHTML, have nothing to put there49 return nil50 }51 // initialize XHTML buffer for notes52 ns := []*etree.Attr{attr("xmlns", `http://www.w3.org/1999/xhtml`)}53 if p.notesMode == NFloatNew {54 ns = append(ns, attr("xmlns:epub", `http://www.idpf.org/2007/ops`))55 }56 to, f := p.ctx().createXHTML("", ns...)57 p.Book.Files = append(p.Book.Files, f)58 // To satisfy Amazon's requirements for floating notes we have to create notes body on the fly here, removing most if not59 // all of existing formatting. At this point we already scanned available notes in ProcessNotes()...60 for i, nl := range p.Book.NotesOrder {61 // title section62 if i == 0 {63 tocRefID := fmt.Sprintf("tocref%d", p.ctx().tocIndex)64 inner := to.AddNext("div", attr("class", "titleblock"), attr("id", tocRefID))65 vignette := p.getVignetteFile("h0", config.VigBeforeTitle)66 if len(vignette) > 0 {67 inner.AddNext("div", attr("class", "vignette_title_before")).68 AddNext("img", attr("src", path.Join("vignettes", filepath.Base(vignette))))69 }70 var tocTitle string71 if t, ok := p.Book.NoteBodyTitles[p.ctx().bodyName]; ok {72 tocTitle = t.title73 inner.AddChild(t.parsed.Copy())74 } else {75 tocTitle = tc.Title(p.Book.Lang).String(p.ctx().bodyName)76 inner.AddNext("div", attr("class", "h0")).AddNext("p", attr("class", "title")).SetText(tocTitle)77 }78 vignette = p.getVignetteFile("h0", config.VigAfterTitle)79 if len(vignette) > 0 {80 inner.AddNext("div", attr("class", "vignette_title_after")).81 AddNext("img", attr("src", path.Join("vignettes", filepath.Base(vignette))))82 }83 p.Book.TOC = append(p.Book.TOC, &tocEntry{84 ref: p.ctx().fname + "#" + tocRefID,85 title: tocTitle,86 level: p.ctx().header,87 bodyName: p.ctx().bodyName,88 })89 p.ctx().tocIndex++90 }91 // note body92 if nl.bodyName == p.ctx().bodyName {93 note := p.Book.Notes[nl.id]94 backID := "back_" + nl.id95 p.Book.LinksLocations[nl.id] = p.ctx().fname96 backRef, exists := p.Book.LinksLocations[backID]97 if !exists {98 backRef = "nowhere"99 }100 var t string101 if p.env.Cfg.Doc.Notes.Renumber {102 t = strconv.Itoa(note.number) + "."103 } else {104 t = "***."105 if len(note.title) > 0 {106 t = note.title107 // Sometimes authors put "." inside the note108 if !strings.HasSuffix(t, ".") {109 t += "."110 }111 }112 }113 // NOTE: we are adding .SetTail("\n") to make result readable when debugging, it does not have any other use114 if p.notesMode == NFloatNew {115 // new "preffered" HTML5 method with "aside"116 to.AddNext("aside", attr("id", nl.id), attr("epub:type", "footnote")).SetTail("\n").117 AddNext("p", attr("class", "floatnote")).118 AddNext("a", attr("href", backRef+"#"+backID)).SetText(t).SetTail(strNBSP + note.body)119 } else {120 // old bi-directional mode121 to.AddNext("p", attr("class", "floatnote"), attr("id", nl.id)).SetTail("\n").122 AddNext("a", attr("href", backRef+"#"+backID)).SetText(t).SetTail(strNBSP + note.body)123 }124 }125 }126 return nil127}128func (p *Processor) doTextTransformations(text string, breakable, tail bool) string {129 if p.ctx().inParagraph && breakable {130 // normalize direct speech if requested131 if !tail && p.speechTransform != nil {132 from, to := p.speechTransform.From, p.speechTransform.To133 cutIndex := 0134 for i, sym := range text {135 if i == 0 {136 if !strings.ContainsRune(from, sym) {137 break138 }139 cutIndex += utf8.RuneLen(sym)140 } else {141 if unicode.IsSpace(sym) {142 cutIndex += utf8.RuneLen(sym)143 } else {144 text = to + text[cutIndex:]145 break146 }147 }148 }149 }150 // unify dashes if requested151 if p.dashTransform != nil {152 var (153 b strings.Builder154 runes = []rune(text)155 )156 for i := 0; i < len(runes); i++ {157 if i > 0 && unicode.IsSpace(runes[i-1]) &&158 i < len(runes)-1 && unicode.IsSpace(runes[i+1]) &&159 strings.ContainsRune(p.dashTransform.From, runes[i]) {160 b.WriteString(p.dashTransform.To)161 continue162 }163 b.WriteRune(runes[i])164 }165 text = b.String()166 }167 }168 return text169}170// formatText inserts page markers (for page map), kobo spans (if necessary) and hyphenates words if requested.171func (p *Processor) formatText(in string, breakable, tail bool, to *etree.Element) {172 in = p.doTextTransformations(in, breakable, tail)173 var (174 textOut string175 textOutLen int // before hyphenation176 dropcapFound bool // if true - do not look for dropcap177 buf strings.Builder178 page, insertMarkers = p.Book.Pages[p.ctx().fname]179 kobo = p.format == OKepub180 )181 bufWriteString := func(text string, kobo bool) {182 if kobo {183 p.ctx().sentence++184 buf.WriteString(`<span class="koboSpan" id=` + fmt.Sprintf("\"kobo.%d.%d\"", p.ctx().paragraph, p.ctx().sentence) + `>`)185 }186 buf.WriteString(html.EscapeString(text))187 if kobo {188 buf.WriteString(`</span>`)189 }190 }191 buf.WriteString(`<root>`)192 for k, sentence := range splitSentences(p.Book.tokenizer, in) {193 for i, word := range splitWords(p.Book.tokenizer, sentence, p.env.Cfg.Doc.NoNBSP) {194 wl := utf8.RuneCountInString(word)195 dropIndex := 0196 if k == 0 && i == 0 && wl > 0 && !dropcapFound && // worth looking and we still do not have it197 p.ctx().inParagraph && breakable && p.env.Cfg.Doc.DropCaps.Create && !tail &&198 p.ctx().firstChapterLine && !p.ctx().inHeader && !p.ctx().inSubHeader && len(p.ctx().bodyName) == 0 && !p.ctx().specialParagraph {199 for j, sym := range word {200 if !strings.ContainsRune(p.env.Cfg.Doc.DropCaps.IgnoreSymbols, sym) {201 // Do not dropcap spaces unless they are set as ignored202 if !unicode.IsSpace(sym) {203 dropIndex = j + utf8.RuneLen(sym)204 dropcapFound = true205 }206 break207 }208 }209 if dropIndex > 0 {210 buf.WriteString(`<span class="dropcaps">`)211 bufWriteString(word[0:dropIndex], false)212 buf.WriteString(`</span>`)213 word = word[dropIndex:]214 }215 }216 if p.Book.hyph != nil && !p.ctx().inHeader && !p.ctx().inSubHeader && wl > 2 && dropIndex == 0 {217 word = p.Book.hyph.hyphenate(word)218 }219 textOutLen += wl220 if i == 0 {221 textOut = word222 } else {223 textOut = strings.Join([]string{textOut, word}, " ")224 textOutLen++ // count extra space225 }226 if p.ctx().inParagraph && !p.ctx().inHeader && !p.ctx().inSubHeader && len(p.ctx().bodyName) == 0 {227 // to properly set chapter_end vignette we need to know if chapter has some text in it228 p.ctx().sectionTextLength.add(textOutLen)229 }230 if insertMarkers && !tail && p.ctx().inParagraph && breakable && p.ctx().pageLength+textOutLen >= p.env.Cfg.Doc.CharsPerPage {231 if len(textOut) > 0 {232 bufWriteString(textOut, kobo)233 }234 buf.WriteString(`<a class="pagemarker" id=` + fmt.Sprintf("\"page_%d\"/>", page))235 p.ctx().pageLength, textOutLen, textOut = 0, 0, ""236 page++237 }238 }239 if len(textOut) > 0 {240 bufWriteString(textOut, kobo)241 p.ctx().pageLength, textOutLen, textOut = p.ctx().pageLength+textOutLen, 0, ""242 }243 }244 buf.WriteString(`</root>`)245 if insertMarkers {246 p.Book.Pages[p.ctx().fname] = page247 }248 if !tail &&249 p.ctx().firstChapterLine && !p.ctx().inHeader && !p.ctx().inSubHeader && len(p.ctx().bodyName) == 0 && !p.ctx().specialParagraph {250 // we are looking for drop cups on a first line of chapter only251 p.ctx().firstChapterLine = false252 }253 doc := etree.NewDocument()254 if err := doc.ReadFromString(buf.String()); err != nil {255 p.env.Log.Error("Unable to format text", zap.String("text", buf.String()), zap.Error(err))256 }257 if tail {258 text := doc.Root().Text()259 if len(text) > 0 {260 to.SetTail(text)261 }262 pel := to.Parent()263 for _, e := range doc.Root().ChildElements() {264 pel.AddChild(e)265 }266 } else {267 if dropcapFound {268 if attr := to.SelectAttr("class"); attr != nil {269 attr.Value = "dropcaps"270 } else {271 to.CreateAttr("class", "dropcaps")272 }273 }274 text := doc.Root().Text()275 if len(text) > 0 {276 to.SetText(text)277 }278 for _, e := range doc.Root().ChildElements() {279 to.AddChild(e)280 }281 }282}283// transfer converts source xml element to resulting xhtml fragment, possibly with multiple nodes and formatting.284// NOTE: decorations (if any) are (order important): name of new html tag, its css class, href attribute.285func (p *Processor) transfer(from, to *etree.Element, decorations ...string) error {286 // See if decorations are requested287 var tag, css, href string288 for i, p := range decorations {289 switch {290 case i == 0:291 tag = p292 case i == 1:293 css = p294 case i == 2:295 href = p296 }297 }298 text := from.Text()299 tail := from.Tail()300 processChildren := true301 // links are notes - probably302 if tag == "a" && len(href) > 0 {303 var noteID string304 // Some people does not know how to format url properly305 href = strings.Replace(href, "\\", "/", -1)306 if u, err := url.Parse(href); err != nil {307 p.env.Log.Warn("unable to parse note href", zap.String("href", href), zap.Error(err))308 } else {309 noteID = u.Fragment310 switch p.notesMode {311 case NDefault:312 if _, ok := p.Book.Notes[noteID]; !ok {313 css = "linkanchor"314 }315 case NInline:316 fallthrough317 case NBlock:318 if n, ok := p.Book.Notes[noteID]; ok {319 p.ctx().currentNotes = append(p.ctx().currentNotes, n)320 tag = "span"321 css = fmt.Sprintf("%sanchor", p.notesMode.String())322 href = ""323 }324 case NFloat:325 fallthrough326 case NFloatOld:327 fallthrough328 case NFloatNew:329 if note, ok := p.Book.Notes[noteID]; !ok {330 css = "linkanchor"331 } else {332 if p.env.Cfg.Doc.Notes.Renumber {333 var name string334 if t, ok := p.Book.NoteBodyTitles[note.bodyName]; ok {335 name = t.title336 } else {337 name = tc.Title(p.Book.Lang).String(note.bodyName)338 }339 var bodyNumber int340 if p.Book.NotesBodies > 1 {341 bodyNumber = note.bodyNumber342 }343 text = ReplaceKeywords(p.env.Cfg.Doc.Notes.Format, CreateAnchorLinkKeywordsMap(name, bodyNumber, note.number))344 processChildren = false345 }346 // NOTE: modifying attribute on SOURCE node!347 from.CreateAttr("id", "back_"+noteID)348 }349 default:350 return errors.New("unknown notes mode - this should never happen")351 }352 }353 }354 // generate requested node at destination355 inner := to356 if len(tag) > 0 {357 var newid string358 if id := getAttrValue(from, "id"); len(id) > 0 {359 var changed bool360 newid, changed = SanitizeName(id)361 if changed {362 p.env.Log.Warn("Tag id was sanitized. This may create problems with links (TOC, notes) - it is better to fix original file", zap.String(tag, id))363 }364 p.Book.LinksLocations[newid] = p.ctx().fname365 }366 // NOTE: There could be sections inside sections to no end, so we do not want to repeat this as it will break TOC on "strangly" formatted texts,367 // we will just mark main section beginning with "section" css in case somebody wants to do some formatting there368 if css == "section" {369 attrs := make([]*etree.Attr, 2)370 attrs[0] = attr("class", css)371 attrs[1] = attr("href", href)372 if len(newid) != 0 {373 attrs = append(attrs, attr("id", newid))374 }375 to.AddNext(tag, attrs...)376 } else {377 attrs := make([]*etree.Attr, 3)378 attrs[0] = attr("id", newid)379 attrs[1] = attr("class", css)380 attrs[2] = attr("href", href)381 if p.notesMode == NFloatNew && tag == "a" {382 attrs = append(attrs, attr("epub:type", "noteref"))383 }384 inner = to.AddNext(tag, attrs...)385 }386 if tag == "p" {387 p.ctx().inParagraph = true388 defer func() { p.ctx().inParagraph = false }()389 p.ctx().paragraph++390 p.ctx().sentence = 0391 }392 }393 // add node text394 if len(text) > 0 {395 p.formatText(text, from.Tag == "p", false, inner)396 }397 if processChildren {398 // transfer children399 var err error400 for _, child := range from.ChildElements() {401 if proc, ok := supportedTransfers[child.Tag]; ok {402 err = proc(p, child, inner)403 if err == nil && from.Tag == "section" {404 // NOTE: during inner section transfer we may open new xhtml file starting new chapter, so we want to sync up current node...405 if body := p.ctx().out.FindElement("./html/body"); body != nil {406 to, inner = body, body407 }408 }409 } else {410 // unexpected tag to transfer411 if from.Tag == "body" || from.Tag == "section" {412 p.env.Log.Debug("Unexpected tag, ignoring completely", zap.String("tag", from.Tag), zap.String("xml", getXMLFragmentFromElement(child)))413 continue414 }415 p.env.Log.Debug("Unexpected tag, transferring", zap.String("tag", from.Tag), zap.String("xml", getXMLFragmentFromElement(child)))416 // NOTE: all "unknown" attributes will be lost during this transfer417 err = p.transfer(child, inner, child.Tag)418 }419 if err != nil {420 return err421 }422 }423 }424 // add bodies of inline and block notes425 // NOTE: presently ignore note bodies when calculating page length...426 currentNotes := p.ctx().currentNotes427 if len(p.ctx().currentNotes) > 0 {428 // insert inline and block notes429 if p.notesMode == NInline && tag == "span" {430 inner = to.AddNext("span", attr("class", "inlinenote")).SetText(currentNotes[0].body)431 p.ctx().currentNotes = []*note{}432 } else if p.notesMode == NBlock && tag == "p" {433 inner := to.AddNext("div", attr("class", "blocknote"))434 for _, n := range currentNotes {435 t := n.title436 if i, err := strconv.Atoi(t); err == nil {437 t = fmt.Sprintf("%d) ", i)438 }439 inner.AddNext("p").AddNext("span", attr("class", "notenum")).SetText(t).SetTail(n.body)440 }441 p.ctx().currentNotes = []*note{}442 }443 }444 // and do not forget node tail445 if len(tail) > 0 {446 p.formatText(tail, from.Tag == "p", true, inner)447 }448 return nil449}450var supportedTransfers map[string]func(p *Processor, from, to *etree.Element) error451func init() {452 // all tags mentioned in "http://www.gribuser.ru/xml/fictionbook/2.2/xsd/FictionBook2.2.xsd" and then some453 supportedTransfers = map[string]func(p *Processor, from, to *etree.Element) error{454 "title": transferTitle,455 "image": transferImage,456 "section": transferSection,457 "span": transferSpan,458 "subtitle": transferSubtitle,459 "epigraph": func(p *Processor, from, to *etree.Element) error {460 p.ctx().specialParagraph = true461 defer func() { p.ctx().specialParagraph = false }()462 return p.transfer(from, to, "div", "epigraph")463 },464 "annotation": func(p *Processor, from, to *etree.Element) error {465 p.ctx().specialParagraph = true466 defer func() { p.ctx().specialParagraph = false }()467 return p.transfer(from, to, "div", "annotation")468 },469 "b": func(p *Processor, from, to *etree.Element) error {470 return p.transfer(from, to, "span", "strong")471 },472 "strong": func(p *Processor, from, to *etree.Element) error {473 return p.transfer(from, to, "span", "strong")474 },475 "i": func(p *Processor, from, to *etree.Element) error {476 return p.transfer(from, to, "span", "emphasis")477 },478 "emphasis": func(p *Processor, from, to *etree.Element) error {479 return p.transfer(from, to, "span", "emphasis")480 },481 "strikethrough": func(p *Processor, from, to *etree.Element) error {482 return p.transfer(from, to, "span", "strike")483 },484 "style": func(p *Processor, from, to *etree.Element) error {485 return p.transfer(from, to, "span")486 },487 "a": transferAnchor,488 "p": transferParagraph,489 "poem": func(p *Processor, from, to *etree.Element) error {490 p.ctx().specialParagraph = true491 defer func() { p.ctx().specialParagraph = false }()492 return p.transfer(from, to, "div", "poem")493 },494 "stanza": func(p *Processor, from, to *etree.Element) error {495 return p.transfer(from, to, "div", "stanza")496 },497 "v": func(p *Processor, from, to *etree.Element) error {498 return p.transfer(from, to, "p")499 },500 "cite": func(p *Processor, from, to *etree.Element) error {501 return p.transfer(from, to, "div", "cite")502 },503 "empty-line": func(_ *Processor, _, to *etree.Element) error {504 to.AddNext("div", attr("class", "emptyline"))505 return nil506 },507 "text-author": func(p *Processor, from, to *etree.Element) error {508 p.ctx().specialParagraph = true509 defer func() { p.ctx().specialParagraph = false }()510 return p.transfer(from, to, "div", "text-author")511 },512 "code": func(p *Processor, from, to *etree.Element) error {513 return p.transfer(from, to, "code")514 },515 "date": func(p *Processor, from, to *etree.Element) error {516 return p.transfer(from, to, "time")517 },518 "sup": func(p *Processor, from, to *etree.Element) error {519 return p.transfer(from, to, "sup")520 },521 "sub": func(p *Processor, from, to *etree.Element) error {522 return p.transfer(from, to, "sub")523 },524 "table": transferTable,525 "tr": transferTableElement,526 "td": transferTableElement,527 "th": transferTableElement,528 }529}530func transferSubtitle(p *Processor, from, to *etree.Element) error {531 if p.env.Cfg.Doc.ChapterPerFile {532 t := from.Text()533 if len(t) != 0 {534 for _, dv := range p.env.Cfg.Doc.ChapterDividers {535 if t == dv && !p.ctx().inHeader && !p.ctx().inSubHeader && len(p.ctx().bodyName) == 0 && !p.ctx().specialParagraph {536 // open next XHTML537 ns := []*etree.Attr{attr("xmlns", `http://www.w3.org/1999/xhtml`)}538 if p.notesMode == NFloatNew {539 ns = append(ns, attr("xmlns:epub", `http://www.idpf.org/2007/ops`))540 }541 var f *dataFile542 to, f = p.ctx().createXHTML("", ns...)543 // store it for future flushing544 p.Book.Files = append(p.Book.Files, f)545 p.Book.Pages[f.fname] = 0546 }547 }548 }549 }550 p.ctx().inSubHeader = true551 defer func() { p.ctx().inSubHeader = false }()552 return p.transfer(from, to, "p", "subtitle")553}554func transferParagraph(p *Processor, from, to *etree.Element) error {555 if p.env.Cfg.Doc.ChapterPerFile {556 // Split content if requested557 if pages, ok := p.Book.Pages[p.ctx().fname]; ok && pages >= p.env.Cfg.Doc.PagesPerFile &&558 !p.ctx().inHeader && !p.ctx().inSubHeader && len(p.ctx().bodyName) == 0 && !p.ctx().specialParagraph {559 // open next XHTML560 ns := []*etree.Attr{attr("xmlns", `http://www.w3.org/1999/xhtml`)}561 if p.notesMode == NFloatNew {562 ns = append(ns, attr("xmlns:epub", `http://www.idpf.org/2007/ops`))563 }564 var f *dataFile565 to, f = p.ctx().createXHTML("", ns...)566 // store it for future flushing567 p.Book.Files = append(p.Book.Files, f)568 p.Book.Pages[f.fname] = 0569 }570 }571 var css string572 if p.ctx().inHeader {573 css = "title"574 }575 return p.transfer(from, to, "p", css)576}577func transferAnchor(p *Processor, from, to *etree.Element) error {578 href := getAttrValue(from, "href")579 if len(href) == 0 {580 txt := strings.TrimSpace(from.Text())581 if len(txt) > 0 && len(from.ChildElements()) == 0 {582 // some idiots think that anchors are for text formatting - see if we could save it583 href = strings.Trim(filepath.ToSlash(txt), ".,")584 if govalidator.IsURL(href) || govalidator.IsEmail(href) {585 return p.transfer(from, to, "a", "anchor", href)586 }587 }588 if len(txt) > 0 || len(from.ChildElements()) > 0 {589 p.env.Log.Warn("Unable to find href attribute in anchor", zap.String("xml", getXMLFragmentFromElement(from)))590 return p.transfer(from, to, "a", "empty-href")591 }592 p.env.Log.Warn("Unable to find href attribute in anchor, ignoring", zap.String("xml", getXMLFragmentFromElement(from)))593 return nil594 }595 // sometimes people are doing strange things with URLs596 return p.transfer(from, to, "a", "anchor", filepath.ToSlash(href))597}598func transferTitle(p *Processor, from, to *etree.Element) error {599 defer func() {600 p.ctx().inHeader = false601 p.ctx().firstBodyTitle = false602 p.ctx().tocIndex++603 }()604 tocRefID := fmt.Sprintf("tocref%d", p.ctx().tocIndex)605 tocTitle := SanitizeTitle(getTextFragment(from))606 // notes bodies have many titles, for main body only first title deserves special processing607 if len(p.ctx().bodyName) == 0 || p.ctx().firstBodyTitle {608 // to properly set chapter_end vignette we need to know if chapter has title609 p.ctx().sectionWithTitle.set()610 p.ctx().inHeader = true611 p.ctx().firstChapterLine = true612 cls := "titleblock"613 if p.ctx().header.Int() >= p.env.Cfg.Doc.ChapterLevel {614 cls = "titleblock_nobreak"615 }616 div := to.AddNext("div", attr("id", tocRefID), attr("class", cls))617 h := p.ctx().header.String("h")618 vignette := p.getVignetteFile(h, config.VigBeforeTitle)619 if len(vignette) > 0 {620 div.AddNext("div", attr("class", "vignette_title_before")).621 AddNext("img", attr("src", path.Join("vignettes", filepath.Base(vignette))), attr("alt", config.VigBeforeTitle))622 }623 if err := p.transfer(from, div, "div", h); err != nil {624 return err625 }626 vignette = p.getVignetteFile(h, config.VigAfterTitle)627 if len(vignette) > 0 {628 div.AddNext("div", attr("class", "vignette_title_after")).629 AddNext("img", attr("src", path.Join("vignettes", filepath.Base(vignette))), attr("alt", config.VigAfterTitle))630 }631 p.Book.TOC = append(p.Book.TOC, &tocEntry{632 ref: p.ctx().fname + "#" + tocRefID,633 title: tocTitle,634 level: p.ctx().header,635 bodyName: p.ctx().bodyName,636 main: p.ctx().firstBodyTitle,637 })638 } else if err := p.transfer(from, to, "div", "titlenotes"); err != nil {639 return err640 }641 return nil642}643func transferSection(p *Processor, from, to *etree.Element) error {644 if len(p.ctx().bodyName) == 0 && p.ctx().header.Int() == 0 && p.ctx().firstBodyTitle {645 // processing section in main body, but there was no (body) title - we have to fake it to646 // keep structure uniform647 tocRefID := fmt.Sprintf("tocref%d", p.ctx().tocIndex)648 tocTitle := p.Book.BookAuthors(p.env.Cfg.Doc.AuthorFormat, true) + " " + p.Book.Title649 cls := "titleblock"650 if p.ctx().header.Int() >= p.env.Cfg.Doc.ChapterLevel {651 cls = "titleblock_nobreak"652 }653 div := to.AddNext("div", attr("id", tocRefID), attr("class", cls))654 h := p.ctx().header.String("h")655 vignette := p.getVignetteFile(h, config.VigBeforeTitle)656 if len(vignette) > 0 {657 div.AddNext("div", attr("class", "vignette_title_before")).658 AddNext("img", attr("src", path.Join("vignettes", filepath.Base(vignette))), attr("alt", config.VigBeforeTitle))659 }660 header := div.AddNext("div", attr("class", h))661 for _, an := range p.Book.Authors {662 header.AddNext("p", attr("class", "title")).SetText(ReplaceKeywords(p.env.Cfg.Doc.AuthorFormat, CreateAuthorKeywordsMap(an)))663 }664 header.AddNext("p", attr("class", "title")).SetText(p.Book.Title)665 vignette = p.getVignetteFile(h, config.VigAfterTitle)666 if len(vignette) > 0 {667 div.AddNext("div", attr("class", "vignette_title_after")).668 AddNext("img", attr("src", path.Join("vignettes", filepath.Base(vignette))), attr("alt", config.VigAfterTitle))669 }670 p.Book.TOC = append(p.Book.TOC, &tocEntry{671 ref: p.ctx().fname + "#" + tocRefID,672 title: tocTitle,673 level: p.ctx().header,674 bodyName: p.ctx().bodyName,675 main: p.ctx().firstBodyTitle,676 })677 p.ctx().firstBodyTitle = false678 p.ctx().tocIndex++679 }680 p.ctx().header.Inc()681 defer p.ctx().header.Dec()682 if p.env.Cfg.Doc.ChapterPerFile {683 if len(p.ctx().bodyName) == 0 && p.ctx().header.Int() < p.env.Cfg.Doc.ChapterLevel {684 // open next XHTML685 ns := []*etree.Attr{attr("xmlns", `http://www.w3.org/1999/xhtml`)}686 if p.notesMode == NFloatNew {687 ns = append(ns, attr("xmlns:epub", `http://www.idpf.org/2007/ops`))688 }689 var f *dataFile690 to, f = p.ctx().createXHTML("", ns...)691 // store it for future flushing692 p.Book.Files = append(p.Book.Files, f)693 p.Book.Pages[f.fname] = 0694 }695 }696 // Since we are using recursive transfer algorithm when we return current file and other context values697 // will be quite different, so if we want to keep some values for this section we need another stack698 titler := p.ctx().sectionWithTitle.link()699 texter := p.ctx().sectionTextLength.link()700 if err := p.transfer(from, to, "div", "section"); err != nil {701 return err702 }703 hasTitle := titler()704 textLength := texter()705 if len(p.ctx().bodyName) == 0 {706 if textLength > 0 {707 if hasTitle {708 // only place vignette at the chapter end if it had it's own title and chapter has paragraphs with text709 vignette := p.getVignetteFile(p.ctx().header.String("h"), config.VigChapterEnd)710 if len(vignette) > 0 {711 to.AddNext("p", attr("class", "vignette_chapter_end")).712 AddNext("img", attr("src", path.Join("vignettes", filepath.Base(vignette))), attr("alt", config.VigChapterEnd))713 }714 } else if p.env.Cfg.Doc.TOC.NoTitleChapters {715 // section does not have a title - make sure TOC is not empty716 p.Book.TOC = append(p.Book.TOC, &tocEntry{717 ref: p.ctx().fname + "#" + fmt.Sprintf("secref%d", p.ctx().findex),718 title: fmt.Sprintf("%d", p.ctx().findex),719 level: p.ctx().header,720 bodyName: p.ctx().bodyName,721 })722 p.ctx().tocIndex++723 }724 }725 // make sure we have single "div chapter_end" when multiple sections are closing726 var haveEnd bool727 children := to.ChildElements()728 if len(children) > 0 {729 if children[len(children)-1].Tag == "div" && children[len(children)-1].SelectAttrValue("class", "") == "chapter_end" {730 haveEnd = true731 }732 }733 if !haveEnd {734 to.AddNext("div", attr("class", "chapter_end"))735 }736 }737 return nil738}739func transferImage(p *Processor, from, to *etree.Element) error {740 id := getAttrValue(from, "id")741 alt := getAttrValue(from, "alt")742 href := getAttrValue(from, "href")743 if len(href) > 0 {744 if u, err := url.Parse(href); err != nil {745 p.env.Log.Warn("unable to parse image ref-id", zap.String("href", href), zap.Error(err))746 } else {747 href = u.Fragment748 }749 }750 if len(href) == 0 {751 p.env.Log.Warn("Encountered image tag without href, skipping", zap.String("path", from.GetPath()), zap.String("xml", getXMLFragmentFromElement(from)))752 return nil753 }754 // find corresponding image755 var fname string756 for _, b := range p.Book.Images {757 if b.id == href {758 fname = b.fname759 break760 }761 }762 // oups763 if len(fname) == 0 {764 p.env.Log.Warn("Unable to find image for ref-id", zap.String("ref-id", href), zap.String("xml", getXMLFragmentFromElement(from)))765 var err error766 if p.notFound == nil {767 p.notFound, err = p.getNotFoundImage(len(p.Book.Images))768 if err != nil {769 return fmt.Errorf("unable to load not-found image: %w", err)770 }771 p.Book.Images = append(p.Book.Images, p.notFound)772 }773 fname = p.notFound.fname774 alt = id775 }776 if len(alt) == 0 {777 alt = fname778 }779 out := to780 if p.ctx().inParagraph {781 if len(id) > 0 {782 out.AddNext("img", attr("id", id), attr("class", "inlineimage"), attr("src", path.Join(DirImages, fname)), attr("alt", alt)).SetTail(from.Tail())783 } else {784 out.AddNext("img", attr("class", "inlineimage"), attr("src", path.Join(DirImages, fname)), attr("alt", alt)).SetTail(from.Tail())785 }786 } else {787 if len(id) > 0 {788 out = out.AddNext("div", attr("id", id), attr("class", "image"))789 } else {790 out = out.AddNext("div", attr("class", "image"))791 }792 out.AddNext("img", attr("src", path.Join(DirImages, fname)), attr("alt", alt)).SetTail(from.Tail())793 }794 return nil795}796func transferSpan(p *Processor, from, to *etree.Element) error {797 // allow span to keep all attributes798 attrs := make([]*etree.Attr, 0, 1)799 for _, a := range from.Attr {800 attrs = append(attrs, &etree.Attr{Space: a.Space, Key: a.Key, Value: a.Value})801 }802 return p.transfer(from, to.AddNext("span", attrs...))803}804func transferTable(p *Processor, from, to *etree.Element) error {805 attrs := make([]*etree.Attr, 0, 1)806 attrs = append(attrs, attr("class", "table"))807 for _, a := range from.Attr {808 attrs = append(attrs, &etree.Attr{Space: a.Space, Key: a.Key, Value: a.Value})809 }810 return p.transfer(from, to.AddNext("table", attrs...))811}812func transferTableElement(p *Processor, from, to *etree.Element) error {813 attrs := []*etree.Attr{}814 for _, a := range from.Attr {815 attrs = append(attrs, &etree.Attr{Space: a.Space, Key: a.Key, Value: a.Value})816 }817 return p.transfer(from, to.AddNext(from.Tag, attrs...))818}...

Full Screen

Full Screen

td_between.go

Source:td_between.go Github

copy

Full Screen

...240 b.expectedMax = reflect.New(tolerance.Type()).Elem()241 b.expectedMax.SetUint(max)242 }243}244func (b *tdBetween) nFloat(tolerance reflect.Value) {245 if diff := tolerance.Float(); diff != 0 {246 base := b.expectedMin.Float()247 b.expectedMin = reflect.New(tolerance.Type()).Elem()248 b.expectedMin.SetFloat(base - diff)249 b.expectedMax = reflect.New(tolerance.Type()).Elem()250 b.expectedMax.SetFloat(base + diff)251 }252}253// summary(N): compares a number with a tolerance value254// input(N): int,float,cplx(todo)255// N operator compares a numeric data against num ± tolerance. If256// tolerance is missing, it defaults to 0. num and tolerance257// must be the same type as the compared value, except if BeLax config258// flag is true.259//260// td.Cmp(t, 12.2, td.N(12., 0.3)) // succeeds261// td.Cmp(t, 12.2, td.N(12., 0.1)) // fails262//263// TypeBehind method returns the [reflect.Type] of num.264func N(num any, tolerance ...any) TestDeep {265 n := tdBetween{266 base: newBase(3),267 expectedMin: reflect.ValueOf(num),268 minBound: boundIn,269 maxBound: boundIn,270 }271 const usage = "({,U}INT{,8,16,32,64}|FLOAT{32,64}[, TOLERANCE])"272 switch n.expectedMin.Kind() {273 case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,274 reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64,275 reflect.Float32, reflect.Float64:276 default:277 n.err = ctxerr.OpBadUsage("N", usage, num, 1, true)278 return &n279 }280 n.expectedMax = n.expectedMin281 if len(tolerance) > 0 {282 if len(tolerance) > 1 {283 n.err = ctxerr.OpTooManyParams("N", usage)284 return &n285 }286 tol := reflect.ValueOf(tolerance[0])287 if tol.Type() != n.expectedMin.Type() {288 n.err = ctxerr.OpBad("N",289 "N(NUM, TOLERANCE): NUM and TOLERANCE must have the same type: %s ≠ %s",290 n.expectedMin.Type(), tol.Type())291 return &n292 }293 switch tol.Kind() {294 case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:295 n.nInt(tol)296 case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32,297 reflect.Uint64:298 n.nUint(tol)299 default: // case reflect.Float32, reflect.Float64:300 n.nFloat(tol)301 }302 }303 return &n304}305// summary(Gt): checks that a number, string or time.Time is306// greater than a value307// input(Gt): str,int,float,cplx(todo),struct(time.Time)308// Gt operator checks that data is greater than309// minExpectedValue. minExpectedValue can be any numeric, string,310// [time.Time] (or assignable) value or implements at least one of the311// two following methods:312//313// func (a T) Less(b T) bool // returns true if a < b314// func (a T) Compare(b T) int // returns -1 if a < b, 1 if a > b, 0 if a == b...

Full Screen

Full Screen

nFloat

Using AI Code Generation

copy

Full Screen

1import (2type td struct {3}4func (v td) nFloat() float64 {5 return math.Sqrt(v.x*v.x + v.y*v.y)6}7func main() {8 v := td{3, 4}9 fmt.Println(v.nFloat())10}11import (12type td struct {13}14func (v td) nFloat() float64 {15 return math.Sqrt(v.x*v.x + v.y*v.y)16}17func main() {18 v := td{3, 4}19 fmt.Println(v.nFloat())20}21import (22type td struct {23}24func (v td) nFloat() float64 {25 return math.Sqrt(v.x*v.x + v.y*v.y)26}27func main() {28 v := td{3, 4}29 fmt.Println(v.nFloat())30}31import (32type td struct {33}34func (v td) nFloat() float64 {35 return math.Sqrt(v.x*v.x + v.y*v.y)36}37func main() {38 v := td{3, 4}39 fmt.Println(v.nFloat())40}41import (42type td struct {43}44func (v td) nFloat() float64 {45 return math.Sqrt(v.x*v.x + v.y*v.y)46}47func main() {48 v := td{3, 4}49 fmt.Println(v.nFloat())50}51import (52type td struct {53}54func (v td) nFloat() float64 {

Full Screen

Full Screen

nFloat

Using AI Code Generation

copy

Full Screen

1import (2type td struct {3}4func (t td) nFloat() float64 {5 return math.Sqrt(t.r*t.r + t.i*t.i)6}7func main() {8 t := td{3, 4}9 fmt.Println(t.nFloat())10}11Hi, I am new to Go and I am trying to understand how it works. I have a struct that I have created and I have a method that I want to use in the struct. I am not sure how to do this. I have tried to call the method in the main function but it does not work. Any help would be appreciated. Here is my code: package main import ( "fmt" ) type td struct { r, i float64 } func (t td) nFloat() float64 { return math.Sqrt(t.r*t.r + t.i*t.i) } func main() { t := td{3, 4} fmt.Println(t.nFloat()) } Output: 512Hi, I am new to Go and I am trying to understand how it works. I have a struct that I have created and I have a method that I want to use in the struct. I am not sure how to do this. I have tried to call the method in the main function but it does not work. Any help would be appreciated. Here is my code: package main import ( "fmt" ) type td struct { r, i float64 } func (t td) nFloat() float64 { return math.Sqrt(t.r*t.r + t.i*t.i) } func main() { t := td{3, 4} fmt.Println(t.nFloat()) } Output: 513Hi, I am new to Go and I am trying to understand how it works. I have a struct that I have created and I have a method that I want to use in the struct. I am not sure how to do this. I have tried to call the method in the main function but it does not work. Any help would be appreciated. Here is my code: package main import ( "fmt" ) type td struct { r, i float64 } func (t td) nFloat()

Full Screen

Full Screen

nFloat

Using AI Code Generation

copy

Full Screen

1import (2type td struct {3}4func (t td) nFloat() float64 {5 return t.t * math.Pow(10, t.d)6}7func main() {8 t1 := td{t: 1.23, d: 2}9 fmt.Println(t1.nFloat())10}11import (12type td struct {13}14func (t td) nFloat() float64 {15 return t.t * math.Pow(10, t.d)16}17func main() {18 t1 := td{t: 1.23, d: 2}19 fmt.Println(t1.nFloat())20}21import (22type td struct {23}24func (t td) nFloat() float64 {25 return t.t * math.Pow(10, t.d)26}27func main() {28 t1 := td{t: 1.23, d: 2}29 fmt.Println(t1.nFloat())30}31import (32type td struct {33}34func (t td) nFloat() float64 {35 return t.t * math.Pow(10, t.d)36}37func main() {38 t1 := td{t: 1.23, d: 2}39 fmt.Println(t1.nFloat())40}41import (42type td struct {43}44func (t td) nFloat() float64 {45 return t.t * math.Pow(10, t.d)46}47func main() {48 t1 := td{t: 1.23, d: 2}49 fmt.Println(t1.nFloat())50}

Full Screen

Full Screen

nFloat

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 t := td{}4 t.nFloat()5}6import (7type td struct {8}9func (t td) nFloat() {10 fmt.Println("nFloat() method")11}

Full Screen

Full Screen

nFloat

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 fmt.Println(t1.nFloat)4}5import "fmt"6func main() {7 fmt.Println(t1.nInt)8}9import "fmt"10func main() {11 fmt.Println(t1.nString)12}13import "fmt"14func main() {15 fmt.Println(t1.nInterface)16}17import "fmt"18func main() {19 fmt.Println(t1.nInterface)20}21import "fmt"22func main() {23 fmt.Println(t1.nInterface)24}25import "fmt"26func main() {27 fmt.Println(t1.nInterface)28}29import "fmt"30func main() {31 t1.nInterface = []string{"hello", "world"}32 fmt.Println(t1.nInterface)33}34import "fmt"35func main() {36 t1.nInterface = map[string]int{"hello": 1, "world": 2}37 fmt.Println(t1.nInterface)38}

Full Screen

Full Screen

nFloat

Using AI Code Generation

copy

Full Screen

1import (2type td struct {3}4type tdd struct {5}6func (t *td) nFloat() float64 {7 return math.Sqrt(t.x*t.x + t.y*t.y)8}9func (t *tdd) nFloat() float64 {10 return math.Sqrt(t.x*t.x + t.y*t.y)11}12func main() {13 t := td{3, 4}14 fmt.Println(t.nFloat())15 t1 := tdd{3, 4}16 fmt.Println(t1.nFloat())17}18import (19type td struct {20}21type tdd struct {22}23func (t *td) nFloat() float64 {24 return math.Sqrt(t.x*t.x + t.y*t.y)25}26func (t *tdd) nFloat() float64 {27 return math.Sqrt(t.x*t.x + t.y*t.y)28}29func main() {30 t := td{3, 4}31 fmt.Println(t.nFloat())32 t1 := tdd{3, 4}33 fmt.Println(t1.nFloat())34}35import (36type td struct {37}38type tdd struct {39}40func (t *td) nFloat() float64 {41 return math.Sqrt(t.x*t.x + t.y*t.y)42}43func (t *tdd) nFloat() float64 {44 return math.Sqrt(t.x*t.x + t.y*t.y)45}46func main() {47 t := td{3, 4}48 fmt.Println(t.nFloat())49 t1 := tdd{3, 4}50 fmt.Println(t1.nFloat())51}52import (53type td struct {54}55type tdd struct {

Full Screen

Full Screen

nFloat

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 x := td{3, 2}4 fmt.Println(x.nFloat())5}6import (7func main() {8 x := td{3, 2}9 fmt.Println(x.nFloat())10}11import (12func main() {13 x := td{3, 2}14 fmt.Println(x.nFloat())15}16import (17func main() {18 x := td{3, 2}19 fmt.Println(x.nFloat())20}21import (22func main() {23 x := td{3, 2}24 fmt.Println(x.nFloat())25}26import (27func main() {28 x := td{3, 2}29 fmt.Println(x.nFloat())30}31import (32func main() {33 x := td{3, 2}34 fmt.Println(x.nFloat())35}36import (37func main() {38 x := td{3, 2}39 fmt.Println(x.nFloat())40}41import (42func main() {43 x := td{3, 2}44 fmt.Println(x.nFloat())45}46import (47func main() {48 x := td{3, 2}49 fmt.Println(x.nFloat())50}51import (52func main() {53 x := td{3, 2}54 fmt.Println(x.nFloat())

Full Screen

Full Screen

nFloat

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Printf("td.nFloat = %f4}5import (6func main() {7 fmt.Printf("td.nInt = %d8}

Full Screen

Full Screen

nFloat

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(t.nFloat())4}5import (6func main() {7 fmt.Println(t.nFloat())8}9import (10func main() {11 fmt.Println(t.nFloat())12}13import (14func main() {15 fmt.Println(t.nFloat())16}17import (18func main() {19 fmt.Println(t.nFloat())20}21import (22func main() {23 fmt.Println(t.nFloat())24}25import (26func main() {27 fmt.Println(t.nFloat())28}29import (30func main() {31 fmt.Println(t.nFloat())32}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Go-testdeep automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful