BACK TO LIST

Java rules

The Codiga Code Analysis engine supports hundreds of rules for Java, checking that your code is safe and secure. Start using Codiga today to check your code and automate your code reviews to find issues in every pull request and merge with confidence.

AssignmentToNonFinalStatic

Error prone
Warning

Possible unsafe assignment to a non-final static field in a constructor.

Learn more

AvoidBranchingStatementAsLastInLoop

Error prone
Error

Avoid using a branching statement as the last in a loop.

AvoidDecimalLiteralsInBigDecimalConstructor

Error prone
Warning

Avoid creating BigDecimal with a decimal (float/double) literal. Use a String literal

AvoidInstanceofChecksInCatchClause

Error prone
Warning

An instanceof check is being performed on the caught exception. Create a separate catch clause for this exception type.

AvoidMultipleUnaryOperators

Error prone
Error

Using multiple unary operators may be a bug

AvoidUsingOctalValues

Error prone
Warning

Do not start a literal by 0 unless its an octal value

BadComparison

Error prone
Warning

Avoid equality comparisons with Double.NaN

BrokenNullCheck

Error prone
Error

Method call on object which may be null

CheckSkipResult

Error prone
Warning

Check the value returned by the skip() method of an InputStream to see if the requested number of bytes has been skipped.

ClassCastExceptionWithToArray

Error prone
Warning

This usage of the Collection.toArray() method will throw a ClassCastException.

CloseResource

Error prone
Warning

Ensure that resources like this PipedWriter object are closed after use

CompareObjectsWithEquals

Error prone
Warning

Use equals() to compare object references.

ConstructorCallsOverridableMethod

Error prone
Critical

Overridable method 'getAction' called during object construction

DontUseFloatTypeForLoopIndices

Error prone
Warning

Dont use floating point for loop indices. If you must use floating point

EqualsNull

Error prone
Critical

Avoid using equals() to compare against null

IdempotentOperations

Error prone
Warning

Avoid idempotent operations (like assigning a variable to itself).

InstantiationToGetClass

Error prone
Informational

Avoid instantiating an object just to call getClass() on it; use the .class public member instead

JumbledIncrementer

Error prone
Warning

Avoid modifying an outer loop incrementer in an inner loop for update expression

MisplacedNullCheck

Error prone
Warning

The null check here is misplaced; if the variable is null there will be a NullPointerException

MissingBreakInSwitch

Error prone
Warning

A switch statement does not contain a break

MissingStaticMethodInNonInstantiatableClass

Error prone
Warning

Class cannot be instantiated and does not provide any static methods or fields

NonCaseLabelInSwitchStatement

Error prone
Warning

A non-case label was present in a switch statement

NonStaticInitializer

Error prone
Warning

Non-static initializers are confusing

OverrideBothEqualsAndHashcode

Error prone
Warning

Ensure you override both equals() and hashCode()

ReturnEmptyArrayRatherThanNull

Error prone
Critical

Return an empty array rather than null.

ReturnFromFinallyBlock

Error prone
Warning

Avoid returning from a finally block

SimpleDateFormatNeedsLocale

Error prone
Warning

When instantiating a SimpleDateFormat object

SingleMethodSingleton

Error prone
Error

Class contains multiple getInstance methods. Please review.

SingletonClassReturningNewInstance

Error prone
Error

getInstance method always creates a new object and hence does not comply to Singleton Design Pattern behaviour. Please review

UnconditionalIfStatement

Error prone
Warning

Do not use if statements that are always true or always false

UseLocaleWithCaseConversions

Error prone
Warning

Use explicit locale when doing a String.toLowerCase()/toUpperCase() call

We use cookies to improve your site experience, including analytics cookies to understand how you use our product and design better experiences. Please read our Cookie Policy.