Groovy Documentation

Package org.codenarc.rule.basic

 

Class Summary
AbstractFinallyAstVisitor Abstract superclass for AST Visitor classes that check for conditions within a finally block
AddEmptyStringAstVisitor
AddEmptyStringRule Finds empty string literals which are being added.
ArrayReturnTracker
AssignmentInConditionalAstVisitor
AssignmentInConditionalRule An assignment operator (=) was used in a conditional test.
BigDecimalInstantiationAstVisitor
BigDecimalInstantiationRule Rule that checks for calls to the BigDecimal constructor with a double or float literal.
BooleanGetBooleanAstVisitor
BooleanGetBooleanRule This rule catches usages of java.lang.Boolean.getBoolean(String) which reads a boolean from the System properties.
BooleanMethodReturnsNullAstVisitor
BooleanMethodReturnsNullRule Method with Boolean return type returns explicit null.
BooleanReturnTracker
BrokenOddnessCheckAstVisitor
BrokenOddnessCheckRule The code uses x % 2 == 1 to check to see if a value is odd, but this won't work for negative numbers (e.g., (-5) % 2 == -1).
CloneableWithoutCloneAstVisitor
CloneableWithoutCloneRule A class that implements Cloneable should define a clone() method.
CollectionReturnTracker
CompareToWithoutComparableAstVisitor
CompareToWithoutComparableRule If you implement a compareTo method then you should also implement the Comparable interface.
ConfusingTernaryAstVisitor
ConfusingTernaryRule In an "if" expression with an "else" clause, avoid negation in the test.
ConsecutiveLiteralAppendsAstVisitor
ConsecutiveLiteralAppendsRule Violations occur when method calls to append(Object) are chained together with literals as parameters.
ConsecutiveStringConcatenationAstVisitor
ConsecutiveStringConcatenationRule Catches concatenation of two string literals on the same line.
ConstantIfExpressionAstVisitor
ConstantIfExpressionRule Rule that checks for if statement with a constant value for the if expression, such as:
  • if (true) { .. }
  • if (false) { .. }
  • if (Boolean.TRUE) { .. }
  • if (Boolean.FALSE) { .. }
  • if (null) { .. }
  • if (0) { .. }
  • if (99.7) { .. }
  • if ("") { .. }
  • if ("abc") { .. }
  • if ([a:123, b:456]) { .. }
  • if ([a, b]) { .. }
ConstantTernaryExpressionAstVisitor
ConstantTernaryExpressionRule Rule that checks for ternary expressions with a constant value for the boolean expression, such as:
  • true ?
DeadCodeAstVisitor
DeadCodeRule Dead code appears after a return statement or an exception is thrown.
DoubleNegativeAstVisitor
DoubleNegativeRule There is no point in using a double negative, it is always positive.
DuplicateCaseStatementAstVisitor
DuplicateCaseStatementRule Rule that checks for duplicate case statements in a switch block, such as two equal integers or strings.
EmptyCatchBlockAstVisitor
EmptyCatchBlockRule Rule that checks for empty catch blocks
EmptyElseBlockAstVisitor
EmptyElseBlockRule Rule that checks for empty else blocks
EmptyFinallyBlockAstVisitor
EmptyFinallyBlockRule Rule that checks for empty finally blocks
EmptyForStatementAstVisitor
EmptyForStatementRule Rule that checks for empty for statements
EmptyIfStatementAstVisitor
EmptyIfStatementRule Rule that checks for empty if statements
EmptyInstanceInitializerAstVisitor
EmptyInstanceInitializerRule The class has an empty instance initializer.
EmptyMethodAstVisitor
EmptyMethodRule A method was found without an implementation.
EmptyStaticInitializerAstVisitor
EmptyStaticInitializerRule An empty static initializer was found.
EmptySwitchStatementAstVisitor
EmptySwitchStatementRule Rule that checks for empty switch statements
EmptySynchronizedStatementAstVisitor
EmptySynchronizedStatementRule Rule that checks for empty synchronized statement
EmptyTryBlockAstVisitor
EmptyTryBlockRule Rule that checks for empty try blocks
EmptyWhileStatementAstVisitor
EmptyWhileStatementRule Rule that checks for empty while statements
EqualsAndHashCodeAstVisitor
EqualsAndHashCodeRule Rule that checks that if either the boolean equals(Object) or the int hashCode() methods are overridden within a class, then both must be overridden.
ExplicitArrayListInstantiationRule This rule checks for the explicit instantiation of an ArrayList using the no-arg constructor.
ExplicitCallToAndMethodAstVisitor
ExplicitCallToAndMethodRule This rule detects when the and(Object) method is called directly in code instead of using the & operator.
ExplicitCallToCompareToMethodAstVisitor
ExplicitCallToCompareToMethodRule This rule detects when the compareTo(Object) method is called directly in code instead of using the <=>, >, >=, <, and <= operators.
ExplicitCallToDivMethodAstVisitor
ExplicitCallToDivMethodRule This rule detects when the div(Object) method is called directly in code instead of using the / operator.
ExplicitCallToEqualsMethodAstVisitor
ExplicitCallToEqualsMethodRule This rule detects when the equals(Object) method is called directly in code instead of using the == or !
ExplicitCallToGetAtMethodAstVisitor
ExplicitCallToGetAtMethodRule This rule detects when the getAt(Object) method is called directly in code instead of using the [] index operator.
ExplicitCallToLeftShiftMethodAstVisitor
ExplicitCallToLeftShiftMethodRule This rule detects when the leftShift(Object) method is called directly in code instead of using the << operator.
ExplicitCallToMethodAstVisitor Parent Visitor for "ExplicitCallToX" Rules.
ExplicitCallToMinusMethodAstVisitor
ExplicitCallToMinusMethodRule This rule detects when the minus(Object) method is called directly in code instead of using the - operator.
ExplicitCallToModMethodAstVisitor
ExplicitCallToModMethodRule This rule detects when the mod(Object) method is called directly in code instead of using the % operator.
ExplicitCallToMultiplyMethodAstVisitor
ExplicitCallToMultiplyMethodRule This rule detects when the multiply(Object) method is called directly in code instead of using the * operator.
ExplicitCallToOrMethodAstVisitor
ExplicitCallToOrMethodRule This rule detects when the or(Object) method is called directly in code instead of using the | operator.
ExplicitCallToPlusMethodAstVisitor
ExplicitCallToPlusMethodRule This rule detects when the plus(Object) method is called directly in code instead of using the + operator.
ExplicitCallToPowerMethodAstVisitor
ExplicitCallToPowerMethodRule This rule detects when the power(Object) method is called directly in code instead of using the ** operator.
ExplicitCallToRightShiftMethodAstVisitor
ExplicitCallToRightShiftMethodRule This rule detects when the rightShift(Object) method is called directly in code instead of using the >> operator.
ExplicitCallToXorMethodAstVisitor
ExplicitCallToXorMethodRule This rule detects when the xor(Object) method is called directly in code instead of using the ^ operator.
ExplicitGarbageCollectionAstVisitor
ExplicitGarbageCollectionRule Calls to System.gc(), Runtime.getRuntime().gc(), and System.runFinalization() are not advised.
ExplicitHashMapInstantiationRule This rule checks for the explicit instantiation of a HashMap using the no-arg constructor.
ExplicitHashSetInstantiationRule This rule checks for the explicit instantiation of a HashSet using the no-arg constructor.
ExplicitLinkedListInstantiationRule This rule checks for the explicit instantiation of a LinkedList using the no-arg constructor.
ExplicitStackInstantiationRule This rule checks for the explicit instantiation of a Stack using the no-arg constructor.
ExplicitTreeSetInstantiationRule This rule checks for the explicit instantiation of a TreeSet using the no-arg constructor.
ExplicitTypeInstantiationAstVisitor AstVisitor that checks for no-arg constructor calls for the type specified in the constructor.
GStringAsMapKeyAstVisitor
GStringAsMapKeyRule A rule that disallows GStrings as map keys as they might change their hashcode over time.
GroovyLangImmutableAstVisitor
GroovyLangImmutableRule The groovy.lang.Immutable annotation has been deprecated and replaced by groovy.transform.Immutable.
IntegerGetIntegerAstVisitor
IntegerGetIntegerRule This rule catches usages of java.lang.Integer.getInteger(String, ...) which reads an Integer from the System properties.
InvertedIfElseAstVisitor
InvertedIfElseRule An inverted if-else statement is one in which there is a single if statement with a single else branch and the boolean test of the if is negated.
NullReturnTracker Helper AST visitor that adds rule violation if a return statement is encountered that returns a null constant.
RemoveAllOnSelfAstVisitor
RemoveAllOnSelfRule This rule catches calling the method removeAll with yourself as a parameter.
ReturnFromFinallyBlockAstVisitor
ReturnFromFinallyBlockRule Rule that checks for a return from within a finally block
ReturnsNullInsteadOfEmptyArrayAstVisitor
ReturnsNullInsteadOfEmptyArrayRule This rule detects when null is returned from a method that might return an array.
ReturnsNullInsteadOfEmptyCollectionRule This rule detects when null is returned from a method that might return a collection.
ReturnsNullInsteadOfEmptyCollectionRuleAstVisitor
SerialVersionUIDAstVisitor
SerialVersionUIDRule Rule that checks that serialVersionUID field is static final and type long, and is not a property.
SerializableClassMustDefineSerialVersionUIDAstVisitor
SerializableClassMustDefineSerialVersionUIDRule Classes that implement Serializable should define a serialVersionUID.
SimpleDateFormatMissingLocaleAstVisitor
SimpleDateFormatMissingLocaleRule Be sure to specify a Locale when creating a new instance of SimpleDateFormat; the class is locale-sensitive.
ThrowExceptionFromFinallyBlockAstVisitor
ThrowExceptionFromFinallyBlockRule Rule that checks for throwing an exception from within a finally block
 


Groovy Documentation