Java rules
tx0 checks .java files with 363 rules, 108 of them in the default tier. Files that say a tool generated them are skipped. Each rule's page explains what it finds and what it leaves alone.
Default: 108 rules
Bugs and security problems with measured precision. They run without a tx0.toml.
-
tx0/java:abs-of-hashdefaultMath.absof a hash code or random number, which can still be negative -
tx0/java:ambiguous-injection-constructorsdefaultMore than one constructor of a class is marked @Autowired, which Spring rejects
-
tx0/java:append-object-streamdefaultAn ObjectOutputStream appends to a file, adding a second stream header that readers reject
-
tx0/java:arithmetic-comparatordefaultA reference to max, min or sum is passed where a comparator is expected
-
tx0/java:array-equalsdefaultArrays are compared with
equals, which compares references -
tx0/java:assertion-type-mismatchdefaultAn assertion compares a string with a number or truth value, which are never equal
-
tx0/java:atomic-equalsdefaultequalsis called on an atomic number, which compares identity rather than values -
tx0/java:cache-put-and-cacheabledefaultA method is both @Cacheable and @CachePut, which ask for opposite things
-
tx0/java:char-as-capacitydefaultA character passed to a string builder's constructor sets its capacity, not its content
-
tx0/java:compare-min-valuedefaultA comparison method returns
Integer.MIN_VALUE, which stays negative when negated -
tx0/java:competing-test-annotationsdefaultA test method carries @Test together with another annotation that makes it a test
-
tx0/java:constant-overflowdefaultArithmetic on
intconstants overflows before the result is widened -
tx0/java:dereference-of-nulldefaultA variable is dereferenced right where a test has shown it to be null
-
tx0/java:doubled-unarydefaultA unary
!,-or+is applied twice in a row and cancels out -
tx0/java:duplicate-conditiondefaultA condition of an if-else chain repeats an earlier one
-
tx0/java:duplicate-factory-elementdefaultSet.oforMap.ofgets the same element or key twice and throws when it runs -
tx0/java:duration-unit-mismatchdefaultAn amount converted to one time unit is passed together with another TimeUnit
-
tx0/java:empty-database-passworddefaultA database connection is opened with an empty password
-
tx0/java:equals-swapped-fieldsdefaultEquals compares a field of this object with a differently named field of the other
-
tx0/java:equals-unrelated-typedefaultequalscompares a string or box with a value of another type, which is never equal -
tx0/java:final-proxied-classdefaultA class that the framework subclasses at run time is final, or an entity has final methods
-
tx0/java:finalize-overloaddefaultA method named finalize has parameters or a result, so the runtime never calls it
-
tx0/java:finalizers-on-exitdefaultRunFinalizersOnExit is called, which is unsafe and no longer exists in current JDKs
-
tx0/java:finally-jumpdefaultreturn,breakorcontinueleaves afinallyblock -
tx0/java:format-argumentsdefaultA format string and its arguments do not match
-
tx0/java:frozen-loop-conditiondefaultA loop tests only local variables that the loop never changes, so once entered it never ends
-
tx0/java:has-next-calls-nextdefaulthasNext()of an iterator calls its ownnext() -
tx0/java:identical-operandsdefaultBoth operands of an operator or comparison are the same
-
tx0/java:ignored-read-countdefaultThe count returned by reading into an array is dropped, so partial reads go unnoticed
-
tx0/java:ignored-resultdefaultThe result of a method of an immutable value is not used
-
tx0/java:ignored-serial-versiondefaultA
serialVersionUIDfield is notstatic final long, so serialization ignores it -
tx0/java:ignored-serialization-hookdefaultA
writeObject,readObjectorreadObjectNoDatamethod has a signature serialization does not call -
tx0/java:immutable-collection-mutationdefaultA collection from an unmodifiable or fixed-size factory is changed, which throws
-
tx0/java:impossible-maskdefaultA masked value is compared with a constant it can never equal, or always equals
-
tx0/java:index-removal-skips-elementdefaultElements are removed by index in a loop counting up, so the element after each removed one is skipped
-
tx0/java:inexact-bigdecimal-literaldefaultA
BigDecimalis made from a floating-point literal it cannot hold exactly -
tx0/java:insecure-xml-signaturedefaultThe secure validation of XML signatures is switched off
-
tx0/java:int-bits-to-doubledefaultDouble.longBitsToDoublegets a 32-bit value, which it widens before decoding -
tx0/java:invalid-chrono-unitdefaultA date or time value is given a ChronoUnit it does not support, which throws
-
tx0/java:invalid-regexdefaultA pattern string is malformed, so Pattern.compile throws
-
tx0/java:inverted-clampdefaultNested
Math.minandMath.maxhave their bounds swapped and always give the same value -
tx0/java:invisible-annotation-lookupdefaultReflection looks for an annotation that is not retained at run time, so it is never found
-
tx0/java:jdbc-index-zerodefaultA JDBC parameter or column is addressed with index 0 or less, but they are numbered from 1
-
tx0/java:label-never-targeteddefaultA statement label is never the target of a
breakorcontinue -
tx0/java:ldap-unsafe-optionsdefaultAn LDAP search turns entries into objects, or a connection binds anonymously
-
tx0/java:lock-on-lock-objectdefaultA
synchronizedblock takes the monitor of ajava.util.concurrentlock instead of the lock -
tx0/java:lock-on-valuedefaultA
synchronizedblock locks a string or a boxed primitive, which other code may share -
tx0/java:loop-never-entereddefaultA for loop starts its counter where its condition is already false, so its body never runs
-
tx0/java:mask-with-zerodefaultA value is masked with & 0, which is always 0
-
tx0/java:method-named-like-classdefaultA
voidmethod is named like its class, so it is not the constructor it looks like -
tx0/java:mismatched-lookup-typedefaultA collection is searched for a value of a type its elements or keys can never have
-
tx0/java:misspelled-object-methoddefaultA method named like
hashCode,toStringorequalsbut spelled differently -
tx0/java:mixed-box-conditionaldefaultA conditional expression mixes different numeric boxes, so both are unboxed and converted
-
tx0/java:monitor-call-on-conditiondefaultwaitornotifyis called on a lockCondition, whereawaitorsignalwas meant -
tx0/java:monitor-on-threaddefaultwait,notifyornotifyAllis called on aThread, whose monitor the runtime uses -
tx0/java:negative-size-checkdefaultA size or length is compared with 0 in a way that is always true or always false
-
tx0/java:nested-test-class-unmarkeddefaultAn inner class with JUnit 5 tests lacks @Nested, so its tests never run
-
tx0/java:null-into-non-nulldefaultNull is assigned to, or returned from, something annotated as never null
-
tx0/java:null-where-empty-expecteddefaultnullis passed toOptional.ofor returned where anOptionalis declared -
tx0/java:out-of-range-comparisondefaultA byte, short or char is compared with a constant outside its range, so the result never changes
-
tx0/java:out-of-range-date-fielddefaultA month, day, hour, minute or second is set to a number outside its range
-
tx0/java:overwritten-entrydefaultA map entry or array element is written twice in a row, losing the first value
-
tx0/java:overwritten-incrementdefaultA variable is assigned its own postfix increment or decrement, which leaves it unchanged
-
tx0/java:primitive-array-as-listdefaultAn array of primitives passed to
Arrays.asListbecomes the single element of the list -
tx0/java:regex-duplicate-alternativedefaultAn alternative of a regular expression repeats an earlier one, so it can never be the one that matches
-
tx0/java:regex-impossible-lookaheaddefaultA lookahead in a regular expression contradicts the character that follows it, so the pattern never matches
-
tx0/java:regex-possessive-starvesdefaultA possessive quantifier takes the characters that the next part of the regular expression needs, so it never matches
-
tx0/java:regex-unmatchable-anchordefaultA ^ or $ in a regular expression stands where it can never match, so the pattern never matches
-
tx0/java:regex-unmatched-backreferencedefaultA pattern refers back to a capture that does not exist yet at that point
-
tx0/java:reused-streamdefaultA stream kept in a variable is operated on a second time, which throws
-
tx0/java:rpc-object-extensionsdefaultThe vendor extensions of Apache XML-RPC are switched on, which lets requests deserialize objects
-
tx0/java:same-value-assertiondefaultAn assertion compares a value with itself, so it can never fail
-
tx0/java:scheduled-pool-max-sizedefaultThe maximum pool size of a ScheduledThreadPoolExecutor is set, which has no effect
-
tx0/java:security-debug-enableddefaultThe debug mode of Spring Security is switched on
-
tx0/java:seeded-secure-randomdefaultA
SecureRandomgets a seed written in the source -
tx0/java:self-assignmentdefaultA variable is assigned to itself
-
tx0/java:self-bulk-operationdefaultA collection is passed to its own
addAll,removeAll,retainAllorcontainsAll -
tx0/java:session-fixation-offdefaultThe protection against session fixation is switched off
-
tx0/java:shared-iterator-statedefaultEach call of
iterator()hands out the same object, so all loops share one position -
tx0/java:shift-rangedefaultA shift distance is outside the range of the shifted type
-
tx0/java:signed-byte-readdefaultread()of an input stream returns a signed byte, so bytes above 127 look like the end -
tx0/java:skipped-junit-testdefaultA JUnit 5 test method is private, static or returns a value, so JUnit silently skips it
-
tx0/java:split-metacharacterdefaultA string is split at a single regular expression metacharacter
-
tx0/java:spring-app-default-packagedefaultA Spring Boot application class is in the default package, so component scanning reads every class on the class path
-
tx0/java:spring-callback-shapedefaultA method that Spring calls has a signature that Spring rejects or cannot use
-
tx0/java:static-member-annotationdefaultAn injection or validation annotation sits on a static field, where it is ignored
-
tx0/java:stray-semicolon-bodydefaultThe body of an
if,elseor loop is a lone;right after its head -
tx0/java:swapped-assign-operatordefault=+,=-or=!is written where+=,-=or!=was likely meant -
tx0/java:thread-rundefaultThread.runis called wherestartwas meant -
tx0/java:truncated-randomdefaultA random fraction below 1 is cast to an integer type, which always gives 0
-
tx0/java:trust-all-packagesdefaultAn ActiveMQ connection factory is allowed to deserialize objects of every class
-
tx0/java:unchecked-read-castdefaultThe result of
read()is cast tocharorbytebefore the end of input is checked -
tx0/java:unclosed-resourcedefaultA file, socket or archive is opened into a local variable and never closed nor handed on
-
tx0/java:unconditional-self-calldefaultA method calls itself before anything else runs, so it never returns
-
tx0/java:unfinished-test-checkdefaultAn assertion or mock setup is started but never completed, so it checks or does nothing
-
tx0/java:unknown-path-variabledefaultA path variable parameter names a variable that the path template does not have
-
tx0/java:unproxied-annotationdefaultA transaction, async or cache annotation sits on a private or static method, where a proxy cannot apply it
-
tx0/java:unsafe-lazy-initdefaultA field is initialized lazily with a check outside the lock, but is not
volatile -
tx0/java:unsigned-jwtdefaultA JSON Web Token is created or checked with the none algorithm, which has no signature
-
tx0/java:unthrown-exceptiondefaultAn exception is created and dropped instead of thrown
-
tx0/java:untyped-to-array-castdefaultThe
Object[]fromtoArray()is cast to a more specific array type -
tx0/java:unused-streamdefaultA stream pipeline ends without a terminal operation, so none of its steps run
-
tx0/java:value-based-identitydefaultValues of a value-based class such as LocalDate or Optional are compared with == or !=
-
tx0/java:weak-password-encoderdefaultA password encoder keeps passwords readable or hashes them with a quick digest
-
tx0/java:week-year-patterndefaultA date pattern with month and day uses
Y, the week-based year, which is off by one around New Year -
tx0/java:wrong-loop-directiondefaultA loop steps its counter away from the bound of its condition
-
tx0/java:zero-core-threadsdefaultA scheduled executor is built with a core pool size of 0, so its delayed tasks lack a thread
-
tx0/java:zero-divisordefaultAn integer is divided by the literal 0, which throws an ArithmeticException
Recommended: 130 rules
Likely bugs, resource and performance problems.
-
tx0/java:accessor-wrong-fieldrecommendedA getter or setter reads or writes a different field than the one its name says
-
tx0/java:anonymous-collection-subclassrecommendedA collection is filled in an anonymous subclass with an initializer block
-
tx0/java:any-origin-allowedrecommendedCross-origin requests are allowed from every web site with
* -
tx0/java:approximate-math-constantrecommendedPi or e is written as a literal approximation instead of Math.PI or Math.E
-
tx0/java:array-to-stringrecommendedAn array is turned into a string or hash code by identity
-
tx0/java:assert-side-effectrecommendedThe condition of an
assertchanges state, which happens only when assertions are enabled -
tx0/java:assignment-as-conditionrecommendedThe condition of an
if, loop or?:is an assignment rather than a comparison -
tx0/java:basic-auth-headerrecommendedCredentials are sent with HTTP basic authentication, which only encodes them
-
tx0/java:boolean-return-ifrecommendedAn
ifreturnstruein one branch andfalsein the other instead of returning its condition -
tx0/java:boxed-identityrecommendedBoxed numbers are compared with
==or!=, which compare references -
tx0/java:boxing-constructorrecommendedA box is created with its deprecated constructor
-
tx0/java:case-folded-comparisonrecommendedTwo strings are compared after changing their case, where equalsIgnoreCase does it directly
-
tx0/java:catch-null-pointerrecommendedA
NullPointerExceptionis caught instead of checking fornull -
tx0/java:catch-rethrowrecommendedA
catchclause only rethrows the exception it caught -
tx0/java:caught-monitor-staterecommendedAn IllegalMonitorStateException is caught, which only signals a missing synchronized block
-
tx0/java:class-name-comparisonrecommendedA class is identified by comparing its name with a string literal
-
tx0/java:class-of-new-instancerecommendedAn instance is built just to read its Class object
-
tx0/java:clone-without-superrecommendedclone()of a class that can be extended does not callsuper.clone() -
tx0/java:cloneable-without-overriderecommendedA class implements Cloneable but does not override clone()
-
tx0/java:close-in-resource-blockrecommendedA resource of try-with-resources is also closed by hand inside the block
-
tx0/java:command-from-stringsrecommendedAn operating system command is built by joining strings at run time
-
tx0/java:compare-subtractionrecommendedA comparison method returns a difference of two numbers, which can overflow and flip the sign
-
tx0/java:compare-to-constantrecommendedThe result of
compareToorcompareis compared with 1 or -1 -
tx0/java:compare-to-wrong-typerecommendedCompareTo takes another type than the class compares itself with, so Comparable never calls it
-
tx0/java:constant-ivrecommendedAn initialization vector is a constant or an array of zeros
-
tx0/java:constant-saltrecommendedA password is hashed with a salt written in the code
-
tx0/java:cookie-protection-offrecommendedA cookie's
SecureorHttpOnlyflag is switched off or never switched on -
tx0/java:dangling-elserecommendedAn else after two nested ifs without braces belongs to the inner if, whatever the indentation says
-
tx0/java:dead-local-variablerecommendedA local variable is never read or written after its declaration
-
tx0/java:dead-private-fieldrecommendedNothing in its file reads or writes a private field
-
tx0/java:dead-private-typerecommendedNothing in its file refers to a private nested type
-
tx0/java:default-typing-enabledrecommendedJSON input is allowed to name the Java class it is turned into
-
tx0/java:duplicate-lifecycle-methodrecommendedA test class has two setup or teardown methods of the same kind, which run in no fixed order
-
tx0/java:empty-blockrecommendedA block of an
if,else,try,finally,synchronizedor initializer is empty -
tx0/java:empty-catchrecommendedAn exception is caught and ignored without a comment
-
tx0/java:equals-nullrecommendedequalsis called withnull -
tx0/java:equals-overloadrecommendedequalstakes a parameter that is notObject, so it does not overrideObject.equals -
tx0/java:equals-unchecked-castrecommendedequalscasts its argument without checking its type, throwing instead of returningfalse -
tx0/java:equals-without-hashcoderecommendedA class overrides
equalsbut nothashCode -
tx0/java:exception-name-mismatchrecommendedA class whose name ends in
Exceptionis not aThrowable -
tx0/java:exit-time-deletionrecommendedA file is marked with deleteOnExit, which keeps its name in memory until the JVM stops
-
tx0/java:explicit-gcrecommendedA garbage collection is requested from code
-
tx0/java:exposed-static-staterecommendedA
public staticfield can be reassigned, or holds an array whose elements anyone can change -
tx0/java:externalizable-without-no-argrecommendedAn
Externalizableclass has no public constructor without parameters, so it cannot be read back -
tx0/java:finalize-callrecommendedfinalize()is called explicitly -
tx0/java:finalize-overriderecommendedA class overrides
finalize(), which is deprecated and unreliable -
tx0/java:finalize-without-superrecommendedfinalize()of a subclass does not callsuper.finalize() -
tx0/java:float-equalityrecommendedFloating-point values are compared with
==or!=, which rounding makes unreliable -
tx0/java:float-incrementrecommendedA floating-point variable is changed with
++or-- -
tx0/java:forgery-protection-offrecommendedThe protection against cross-site request forgery is switched off
-
tx0/java:fresh-get-instancerecommendedA static getInstance() creates a new object on every call
-
tx0/java:hardcoded-credentialrecommendedA password or secret is written in the source as a string literal
-
tx0/java:hash-field-not-in-equalsrecommendedHashCode mixes in a field that equals ignores, so equal objects can hash differently
-
tx0/java:hashcode-without-equalsrecommendedA class overrides
hashCodebut notequals -
tx0/java:identical-branchesrecommendedEvery branch of an if-else or conditional expression is the same
-
tx0/java:identity-map-value-keyrecommendedAn IdentityHashMap is keyed by boxed numbers or strings, which are equal without being the same object
-
tx0/java:idle-type-parameterrecommendedA method declares a type parameter that it never uses
-
tx0/java:if-after-closing-bracerecommendedAn if starts on the line where the previous if ends, which reads like a missing else
-
tx0/java:ignored-private-parameterrecommendedA private method ignores one of its parameters
-
tx0/java:ignored-status-resultrecommendedA method that reports failure through its result is called and the result is dropped
-
tx0/java:incomplete-copy-constructorrecommendedA copy constructor leaves out a field of its class
-
tx0/java:instanceof-covers-nullrecommendedA value is compared with
nullright before aninstanceoftest that covers it -
tx0/java:int-product-widenedrecommendedTwo ints are multiplied and the result is stored in a long, after it may already have overflowed
-
tx0/java:integer-divisionrecommendedAn integer division is converted to a floating-point number after the fraction is lost
-
tx0/java:internal-api-importrecommendedA class of the JDK's internal packages is imported
-
tx0/java:iterator-next-without-endrecommendedNext() of an iterator neither checks for the end nor delegates, so it fails with the wrong exception
-
tx0/java:javascript-interfacerecommendedA Java object is exposed to the scripts of a WebView
-
tx0/java:jdbc-driver-loadrecommendedA JDBC driver is loaded with Class.forName, which JDBC 4 does by itself
-
tx0/java:lock-on-get-classrecommendedA
synchronizedblock locksgetClass(), which differs between subclasses -
tx0/java:log-and-rethrowrecommendedA caught exception is logged and then thrown again, so it is logged twice or more
-
tx0/java:modified-while-iteratingrecommendedA collection is changed inside an enhanced
forloop over it -
tx0/java:monitor-without-lockrecommendedwait,notifyornotifyAllis called outsidesynchronizedcode -
tx0/java:mutable-enum-fieldrecommendedAn enum has an instance field that is not
final, making its constants shared mutable state -
tx0/java:needless-boxingrecommendedA box is created only to convert or print its value, where a static method does it directly
-
tx0/java:needless-final-jumprecommendedA return or continue is the last statement of its body and changes nothing
-
tx0/java:needless-importrecommendedAn import repeats another or names a class the file sees anyway
-
tx0/java:not-of-equalityrecommendedAn equality comparison is negated with
!instead of using the opposite operator -
tx0/java:null-from-computerecommendedA map's mapping function returns
null, which stores nothing or removes the entry -
tx0/java:null-from-to-stringrecommendedA method callers rely on for a description or a copy hands back
null -
tx0/java:octal-literalrecommendedAn integer literal starts with
0, which makes it octal -
tx0/java:odd-remainderrecommendedAn odd check compares
% 2with 1, which fails for negative numbers -
tx0/java:overridable-call-in-constructorrecommendedA constructor calls a method that a subclass can override before the subclass is set up
-
tx0/java:pointless-finalizer-cleanuprecommendedFinalize() sets fields to null, which does not help the garbage collector
-
tx0/java:predictable-secretrecommendedA secret such as a token or salt comes from a generator whose output can be predicted
-
tx0/java:public-temp-pathrecommendedA file is created at a fixed path in a directory that every user can write to
-
tx0/java:quadratic-string-buildingrecommendedA string is extended with
+on every pass of a loop, copying it each time -
tx0/java:query-from-stringsrecommendedA database query is built by joining strings at run time
-
tx0/java:raw-empty-collectionrecommendedAn empty collection constant of raw type is used instead of its typed factory method
-
tx0/java:reassigned-lock-fieldrecommendedA synchronized block locks a field that other code assigns, so threads can hold different locks
-
tx0/java:record-array-componentrecommendedA record holds an array, which its generated
equalsandhashCodecompare by identity -
tx0/java:regex-anchor-binds-one-alternativerecommendedA ^ or $ in a regular expression applies only to the first or last alternative, not to all of them
-
tx0/java:regex-duplicate-class-memberrecommendedA bracket expression in a pattern names one character more than once
-
tx0/java:regex-empty-grouprecommendedA group of a regular expression is empty, so it matches nothing
-
tx0/java:regex-empty-repeatrecommendedAn unbounded repetition in a regular expression repeats a part that can match nothing
-
tx0/java:regex-lazy-at-endrecommendedA regular expression used to search ends in a reluctant quantifier, which then matches as little as possible: nothing
-
tx0/java:regex-nested-quantifierrecommendedA repeated part of a regular expression contains another unbounded repetition, which can take exponential time
-
tx0/java:regex-replace-literalrecommendedreplaceAllis given a pattern with no regular expression syntax -
tx0/java:regex-unicode-case-missingrecommendedA regular expression ignores case for letters beyond ASCII without the flag that makes it do so
-
tx0/java:repeated-statement-preparationrecommendedA JDBC statement is prepared again on every pass of a loop
-
tx0/java:requested-session-idrecommendedThe session id that the client sent is read and may be trusted
-
tx0/java:scale-sensitive-equalsrecommendedBigDecimal.equalsis used, which also compares the scale, so2.0and2.00differ -
tx0/java:shared-servlet-staterecommendedA servlet keeps per-request data in a mutable field that every thread sees
-
tx0/java:shared-unsafe-instancerecommendedA
staticfield holds a formatter, calendar, digest or matcher, which is not thread-safe -
tx0/java:short-crypto-keyrecommendedA key generator is set to a key size that can be broken
-
tx0/java:sign-extended-byterecommendedA signed byte is combined with shifted bits without a mask, so its sign bits overwrite them
-
tx0/java:single-pass-looprecommendedA loop body always ends in
break,returnorthrow, so it runs at most once -
tx0/java:single-use-randomrecommendedA
Randomis created to produce a single value and then dropped -
tx0/java:sleep-while-lockedrecommendedThread.sleepis called while a monitor is held -
tx0/java:string-copy-constructorrecommendedA string is copied with new String, which only makes a duplicate
-
tx0/java:string-identityrecommendedStrings are compared with
==or!=, which compare references -
tx0/java:string-to-stringrecommendedA
Stringis converted to aStringwithtoString() -
tx0/java:swallowed-interruptrecommendedAn
InterruptedExceptionis caught and the interrupt is lost -
tx0/java:switch-fallthroughrecommendedA
caseruns on into the next one without a comment saying it is meant -
tx0/java:synchronized-read-objectrecommendedReadObject is synchronized, although no other thread can see the object it reads
-
tx0/java:thread-as-runnablerecommendedA Thread object is passed where only a Runnable task is needed
-
tx0/java:thread-without-taskrecommendedA subclass of
Threadneither overridesrun()nor passes a task to its constructor -
tx0/java:trust-all-certificatesrecommendedA certificate or host name check accepts everything
-
tx0/java:uncalled-private-methodrecommendedNothing in its file calls a private method
-
tx0/java:unchecked-optional-getrecommendedThe value of an
Optionalis taken withget()without checking that it is there -
tx0/java:unhardened-xml-parserrecommendedAn XML parser factory is created without any setting that limits external entities
-
tx0/java:unlock-outside-finallyrecommendedA lock is released outside a
finallyblock, so an exception leaves it held -
tx0/java:unsynchronized-getterrecommendedA setter is synchronized but the matching getter is not, so readers may see stale values
-
tx0/java:unused-importrecommendedAn imported name is not used in the file
-
tx0/java:url-equalityrecommendedURL objects are compared with equals or hashCode, which resolve host names over the network
-
tx0/java:volatile-compoundrecommendedA
volatilefield is updated with++,--or a compound assignment, which is not atomic -
tx0/java:wait-holding-two-locksrecommendedWait() is called while two monitors are held, so the outer one stays locked while waiting
-
tx0/java:wait-outside-looprecommendedwait()is called without a loop that checks the condition again -
tx0/java:weak-crypto-algorithmrecommendedA digest, cipher or protocol known to be broken is requested by name
-
tx0/java:webview-file-accessrecommendedA WebView is allowed to read local files, to run its debugger, or to expose Java objects to scripts
-
tx0/java:world-writable-filerecommendedA file is given permissions that let every user of the machine change or read it
Strict: 125 rules
Code that can be written more plainly.
-
tx0/java:accessibility-overridestrictReflection switches off the access checks of a member
-
tx0/java:any-http-method-mappingstrictA request handler is mapped without naming its HTTP methods, so it answers all of them
-
tx0/java:bare-blockstrictA block stands among statements without a statement that owns it
-
tx0/java:bool-literal-comparisonstrictA value is compared with
trueorfalse -
tx0/java:boolean-ternarystrictA conditional expression chooses between
trueandfalse -
tx0/java:broad-throwstrictA
throwcreates an instance of a broad base class that callers cannot single out -
tx0/java:c-style-arraystrictArray brackets follow the name of a variable or the parameters of a method instead of the type
-
tx0/java:catch-throwablestrictA handler for every throwable, or for fatal errors, lets the program go on after them
-
tx0/java:class-fan-outstrictA class refers to more distinct types than the limit
-
tx0/java:class-literal-is-instancestrictisInstanceis called on a class literal instead of usinginstanceof -
tx0/java:code-in-commentstrictA comment holds code that was switched off
-
tx0/java:collapsible-ifstrictAn
ifcontains only anotherif, and neither has anelse -
tx0/java:command-path-lookupstrictAn operating system command is started by a bare name, found through the PATH
-
tx0/java:concat-in-appendstrictThe argument of
StringBuilder.appendis built with+ -
tx0/java:console-outputstrictOutput is written to standard output or standard error directly
-
tx0/java:constant-interfacestrictAn interface declares only constants
-
tx0/java:constant-namingstrictThe name of a constant does not match the configured pattern
-
tx0/java:contextual-keyword-namestrictA declaration is named with a word that later Java versions made a keyword
-
tx0/java:cyclomatic-complexitystrictA method has more independent paths through it than the limit
-
tx0/java:deep-nestingstrictControl statements are nested deeper than the limit
-
tx0/java:default-value-initializerstrictA field initializer repeats the value the field has before it runs
-
tx0/java:diamondstrictThe type arguments of an instance creation repeat those of the declared type
-
tx0/java:eager-log-messagestrictA log message is built with + before the logger checks whether the level is enabled
-
tx0/java:early-thread-startstrictA constructor starts a thread before the object is fully built
-
tx0/java:embedded-assignmentstrictThe value of an assignment feeds into a larger expression
-
tx0/java:empty-classstrictA class declares nothing and extends nothing
-
tx0/java:empty-methodstrictA method has an empty body without a comment
-
tx0/java:empty-string-conversionstrictA literal is turned into a string by adding it to an empty string
-
tx0/java:error-subclassstrictA class extends Error, which is meant for failures of the virtual machine
-
tx0/java:explicit-array-initializerstrictAn array variable is initialized with new and a type that its declaration already gives
-
tx0/java:external-storagestrictFiles are kept in the external storage of an Android device, which other apps can read
-
tx0/java:field-countstrictThe number of fields of a class is above the limit
-
tx0/java:field-namingstrictThe name of a field does not match the configured pattern
-
tx0/java:float-literal-caststrictA double literal is cast to float instead of being written as a float literal
-
tx0/java:for-as-whilestrictA
forloop has only a condition, like awhileloop -
tx0/java:generic-throwsstrictA method declares
throws Exceptionorthrows Throwable -
tx0/java:generic-without-argumentsstrictA generic JDK type is used without type arguments
-
tx0/java:hardcoded-ip-addressstrictAn IP address is written in the code as a string
-
tx0/java:if-chain-without-elsestrictAn if-else-if chain ends without an else
-
tx0/java:implied-modifierstrictA modifier states what the language already implies
-
tx0/java:import-on-demandstrictEvery class of a package is imported with
* -
tx0/java:index-of-positivestrictThe result of indexOf is compared with > 0, which misses a match at the start
-
tx0/java:inline-numeric-literalstrictA numeric literal other than a small common one is written inline instead of named
-
tx0/java:instance-initializerstrictA named class has an instance initializer block
-
tx0/java:instanceof-on-caughtstrictA caught exception is tested with instanceof instead of being caught by its own type
-
tx0/java:instantiable-utility-classstrictA class with only static members has an implicit public constructor
-
tx0/java:key-set-lookupstrictA loop over a map's keys looks each value up again with
get -
tx0/java:labeled-statementstrictA statement carries a label for a break or continue that jumps out of nested loops
-
tx0/java:lambda-block-bodystrictA lambda body is a block with a single statement where an expression would do
-
tx0/java:lambda-param-parensstrictThe single untyped parameter of a lambda is put in parentheses
-
tx0/java:legacy-date-apistrictDates are handled with Date, Calendar or SimpleDateFormat instead of java.time
-
tx0/java:legacy-synchronized-classstrictA collection or buffer that locks on every call is created
-
tx0/java:legacy-thread-groupingstrictA ThreadGroup is created, whose operations are mostly deprecated and unsafe
-
tx0/java:local-hides-fieldstrictA local variable has the name of a field of its class, which it hides
-
tx0/java:local-namingstrictThe name of a local variable or parameter does not match the configured pattern
-
tx0/java:logger-of-other-classstrictA logger is named after another class than the one it is declared in
-
tx0/java:long-anonymous-classstrictAn anonymous class has more lines of code than the limit
-
tx0/java:long-boolean-expressionstrictA boolean expression joins more conditions with
&&and||than the limit -
tx0/java:long-casestrictA
caseof aswitchhas more lines of code than the limit -
tx0/java:long-filestrictA file has more lines of code than the limit
-
tx0/java:long-lambdastrictA lambda body has more lines of code than the limit
-
tx0/java:long-linestrictA line has more characters than the limit
-
tx0/java:long-methodstrictA method body has more lines of code than the limit
-
tx0/java:long-parameter-liststrictThe parameter list of a method or constructor is longer than the limit
-
tx0/java:loop-inequalitystrictA counting loop ends on
!=instead of<or> -
tx0/java:lost-exception-causestrictAn exception is thrown from a
catchblock without the caught exception as its cause -
tx0/java:lowercase-literal-suffixstrictA numeric literal ends in a lower case l, f or d, and l looks like the digit 1
-
tx0/java:manual-array-copystrictAn array is copied element by element in a loop
-
tx0/java:many-loop-jumpsstrictA loop has more exits and restarts than the limit allows
-
tx0/java:mergeable-catchesstrictTwo catch clauses of one try have the same body and could be one multi-catch
-
tx0/java:method-countstrictThe number of methods of a type is above the limit
-
tx0/java:method-namingstrictA method name does not match the configured pattern
-
tx0/java:missing-bracesstrictThe body of an
if,elseor loop is a single statement without braces -
tx0/java:missing-override-annotationstrictA method that overrides a method of Object lacks @Override
-
tx0/java:missing-serial-versionstrictA serializable class leaves its stream version to be computed from its shape
-
tx0/java:modifier-orderstrictModifiers are written in another order than the one the language specification recommends
-
tx0/java:multiple-declaratorsstrictSeveral variables are declared in one declaration
-
tx0/java:names-differ-by-casestrictA field name differs from a method name only in case
-
tx0/java:nan-checkstrictA number is compared with itself to test for NaN
-
tx0/java:native-deserializationstrictObjects are read back with Java's built-in serialization
-
tx0/java:negated-ternary-conditionstrictThe condition of a conditional expression is negated, where swapping the branches reads plainer
-
tx0/java:nested-conditionalstrictA conditional expression is nested inside another one
-
tx0/java:nested-switchstrictA
switchis nested inside anotherswitch -
tx0/java:nested-trystrictA
trywith handlers is nested in the block of another one -
tx0/java:nesting-weighted-complexitystrictA method's branches, weighted by how deep they are nested, add up past the limit
-
tx0/java:no-op-arithmeticstrictAn arithmetic or bit operation leaves its operand unchanged, as x * 1 or x | 0
-
tx0/java:non-short-circuit-logicstrictBoolean conditions are joined with & or | instead of && or ||, so both sides always run
-
tx0/java:notify-onestrictnotify()wakes a single waiting thread chosen by the runtime -
tx0/java:optional-in-signaturestrictA method or constructor takes an
Optionalparameter -
tx0/java:optional-null-comparisonstrictAn
Optionalis compared withnull -
tx0/java:optional-wrapped-containerstrictA method hands back an Optional around a collection, map or array
-
tx0/java:overlapping-throwsstrictA throws clause lists an exception twice, or one that another listed exception covers
-
tx0/java:package-namingstrictThe name of a package does not match the configured pattern
-
tx0/java:pass-through-overridestrictA method overrides another only to call it with the same arguments
-
tx0/java:platform-charsetstrictText is converted to or from bytes with the platform default charset
-
tx0/java:print-stack-tracestrictAn exception is printed to standard error with
printStackTrace() -
tx0/java:private-read-resolvestrictReadResolve of a class that can be extended is private, so subclasses do not inherit it
-
tx0/java:process-exitstrictThe virtual machine is stopped outside a
mainmethod -
tx0/java:public-finalizestrictFinalize() is overridden as public, so any code can call it
-
tx0/java:public-instance-fieldstrictA class has a public field that is neither static nor final
-
tx0/java:reflective-class-loadstrictA class is loaded by a name computed at run time
-
tx0/java:regex-char-alternationstrictA choice between single characters in a regular expression is written with | instead of a class
-
tx0/java:regex-redundant-groupstrictA non-capturing group of a regular expression neither holds a choice nor is repeated, so it changes nothing
-
tx0/java:regex-redundant-quantifierstrictA regular expression has a quantifier {1}, which changes nothing, or {0}, which removes its part
-
tx0/java:regex-repeated-spacesstrictA regular expression holds several spaces in a row, which are hard to count
-
tx0/java:regex-single-member-classstrictA bracket expression in a pattern contains just one letter or digit
-
tx0/java:repeated-string-literalstrictThe same string literal is written several times in a file
-
tx0/java:return-countstrictThe number of
returnstatements in a method is above the limit -
tx0/java:return-fresh-localstrictA local variable is returned or thrown right after it is declared
-
tx0/java:serializable-inner-classstrictA serializable inner class is not static, so serializing it also serializes its outer object
-
tx0/java:shared-temp-filestrictA temporary file is created with the default permissions of the process
-
tx0/java:size-compared-for-emptinessstrictEmptiness is tested by comparing a size or length with 0 or by equality with an empty string
-
tx0/java:static-written-from-instancestrictAn instance method or constructor assigns a static field, which all instances share
-
tx0/java:stray-semicolonstrictA semicolon stands alone where it does nothing
-
tx0/java:stream-for-eachstrictA stream is created only to call forEach, which the collection has itself
-
tx0/java:suppressed-warningsstrictCompiler warnings are switched off with @SuppressWarnings
-
tx0/java:switch-shapestrictA
switchstatement lacks adefault, has it before other labels, or has fewer than three labels -
tx0/java:task-commentstrictA comment marks work left to do with
TODO,FIXMEorXXX -
tx0/java:throw-in-finallystrictAn exception is thrown from a
finallyblock, replacing any exception being thrown -
tx0/java:transient-without-serializationstrictA field is transient in a class that cannot be serializable
-
tx0/java:type-namingstrictA class, interface, enum or record name does not match the configured pattern
-
tx0/java:type-parameter-hides-outerstrictA method declares a type parameter with the name of a type parameter of its class
-
tx0/java:type-parameter-namingstrictThe name of a type parameter does not match the configured pattern
-
tx0/java:unencrypted-urlstrictA connection address uses a protocol without encryption
-
tx0/java:webview-javascript-enabledstrictJavaScript is switched on for a WebView