# Package groovy.org.codenarc.rule.unnecessary

- Class Summary
  Class | Description
  --- | ---
  AddEmptyStringAstVisitor |
  AddEmptyStringRule | Finds empty string literals which are being added.
  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.
  UnnecessaryBigDecimalInstantiationAstVisitor |
  UnnecessaryBigDecimalInstantiationRule | It is unnecessary to instantiate BigDecimal objects.
  UnnecessaryBigIntegerInstantiationAstVisitor |
  UnnecessaryBigIntegerInstantiationRule | It is unnecessary to instantiate BigInteger objects.
  UnnecessaryBooleanExpressionAstVisitor |
  UnnecessaryBooleanExpressionRule | Rule that checks unnecessary boolean expressions, including ANDing (&&) or ORing (||) with `true`, `false`, `null`, or a Map/List/String/Number literal.
  UnnecessaryBooleanInstantiationAstVisitor |
  UnnecessaryBooleanInstantiationRule | Rule that checks for direct call to Boolean constructor - use Boolean.valueOf() instead.
  UnnecessaryCallForLastElementAstVisitor |
  UnnecessaryCallForLastElementRule | This rule checks for excessively verbose methods of accessing the last element of an array or list.
  UnnecessaryCallToSubstringAstVisitor |
  UnnecessaryCallToSubstringRule | Calling String.substring(0) always returns the original string.
  UnnecessaryCastAstVisitor |
  UnnecessaryCastRule | Checks for unnecessary cast operations
  UnnecessaryCatchBlockAstVisitor |
  UnnecessaryCatchBlockRule | Violations are triggered when a catch block does nothing but throw the original exception.
  UnnecessaryCollectCallAstVisitor |
  UnnecessaryCollectCallRule | Some method calls to Object.collect(Closure) can be replaced with the spread operator.
  UnnecessaryCollectionCallAstVisitor |
  UnnecessaryCollectionCallRule | Useless call to collections.
  UnnecessaryConstructorAstVisitor |
  UnnecessaryConstructorRule | UnnecessaryConstructor
  UnnecessaryDefInFieldDeclarationAstVisitor |
  UnnecessaryDefInFieldDeclarationRule | If a field has a visibility modifier or a type declaration, then the def keyword is unneeded.
  UnnecessaryDefInMethodDeclarationAstVisitor |
  UnnecessaryDefInMethodDeclarationRule | If a method has a visibility modifier or a type declaration, then the def keyword is unneeded.
  UnnecessaryDefInVariableDeclarationAstVisitor |
  UnnecessaryDefInVariableDeclarationRule | If a variable has a visibility modifier or a type declaration, then the def keyword is unneeded.
  UnnecessaryDotClassAstVisitor |
  UnnecessaryDotClassRule | To make a reference to a class, it is unnecessary to specify the '.class' identifier.
  UnnecessaryDoubleInstantiationAstVisitor |
  UnnecessaryDoubleInstantiationRule | It is unnecessary to instantiate Double objects.
  UnnecessaryElseStatementAstVisitor |
  UnnecessaryElseStatementRule | When an if statement block ends with a return statement the else is unnecessary
  UnnecessaryFinalOnPrivateMethodAstVisitor |
  UnnecessaryFinalOnPrivateMethodRule | A private method is marked final.
  UnnecessaryFloatInstantiationAstVisitor |
  UnnecessaryFloatInstantiationRule | It is unnecessary to instantiate Float objects.
  UnnecessaryGStringAstVisitor |
  UnnecessaryGStringRule | String objects should be created with single quotes, and GString objects created with double quotes.
  UnnecessaryGetterAstVisitor |
  UnnecessaryGetterRule | Checks for explicit calls to getter/accessor methods which can, for the most part, be replaced by property access.
  UnnecessaryIfStatementAstVisitor |
  UnnecessaryIfStatementRule | Rule that checks for unnecessary if statements.
  UnnecessaryInstanceOfCheckAstVisitor |
  UnnecessaryInstanceOfCheckRule | This rule finds instanceof checks that cannot possibly evaluate to true.
  UnnecessaryInstantiationAstVisitor | Base visitor for unnecessary constructor calls.
  UnnecessaryInstantiationToGetClassAstVisitor |
  UnnecessaryInstantiationToGetClassRule | Avoid instantiating an object just to call getClass() on it; use the .class public member instead.
  UnnecessaryIntegerInstantiationAstVisitor |
  UnnecessaryIntegerInstantiationRule | It is unnecessary to instantiate Integer objects.
  UnnecessaryLongInstantiationAstVisitor |
  UnnecessaryLongInstantiationRule | It is unnecessary to instantiate Long objects.
  UnnecessaryModOneAstVisitor |
  UnnecessaryModOneRule | Any expression mod 1 (exp % 1) is guaranteed to always return zero.
  UnnecessaryNullCheckAstVisitor |
  UnnecessaryNullCheckBeforeInstanceOfAstVisitor |
  UnnecessaryNullCheckBeforeInstanceOfRule | There is no need to check for null before an instanceof; the instanceof keyword returns false when given a null argument.
  UnnecessaryNullCheckRule | Groovy contains the safe dereference operator, which can be used in boolean conditional statements to safely replace explicit "x == null" tests.
  UnnecessaryObjectReferencesAstVisitor |
  UnnecessaryObjectReferencesRule | Violations are triggered when an excessive set of consecutive statements all reference the same variable.
  UnnecessaryOverridingMethodAstVisitor |
  UnnecessaryOverridingMethodRule | The overriding method merely calls the same method defined in a superclass.
  UnnecessaryPackageReferenceAstVisitor |
  UnnecessaryPackageReferenceRule | Checks for explicit package reference for classes that Groovy imports by default, such as java.lang.String, java.util.Map and groovy.lang.Closure, as well as classes that were explicitly imported.
  UnnecessaryParenthesesForMethodCallWithClosureAstVisitor |
  UnnecessaryParenthesesForMethodCallWithClosureRule | If a method is called and the only parameter to that method is an inline closure then the brackets of the method call can be omitted.
  UnnecessaryPublicModifierAstVisitor |
  UnnecessaryPublicModifierRule | The 'public' modifier is not required on methods, constructors or classes.
  UnnecessaryReturnKeywordAstVisitor |
  UnnecessaryReturnKeywordRule | In Groovy, the return keyword is often optional.
  UnnecessarySafeNavigationOperatorAstVisitor |
  UnnecessarySafeNavigationOperatorRule | Check for safe navigation operator (?.)
  UnnecessarySelfAssignmentAstVisitor |
  UnnecessarySelfAssignmentRule | Method contains a pointless self-assignment to a variable or property.
  UnnecessarySemicolonAstVisitor |
  UnnecessarySemicolonRule | Semicolons as line terminators are not required in Groovy: remove them.
  UnnecessaryStringInstantiationAstVisitor |
  UnnecessaryStringInstantiationRule | Rule that checks for direct call to the String constructor that accepts a String literal.
  UnnecessarySubstringAstVisitor |
  UnnecessarySubstringRule | This rule finds usages of String.substring(int) and String.substring(int, int) that can be replaced by use of the subscript operator.
  UnnecessaryTernaryExpressionAstVisitor |
  UnnecessaryTernaryExpressionRule | Rule that checks for ternary expressions where the conditional expression always evaluates to a boolean and the true and false expressions are merely returning `true` and `false` constants.
  UnnecessaryToStringAstVisitor |
  UnnecessaryToStringRule | Checks for unnecessary calls to toString().
  UnnecessaryTransientModifierAstVisitor |
  UnnecessaryTransientModifierRule | The field is marked as transient, but the class isn't Serializable, so marking it as transient should have no effect.
  VariableUsageFinder |