Child pages
  • Inspections

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Fixed error in "Pointless Boolean Expression"

...

Conditional expression

 

This inspection reports any instances of the ternary condition operator. Some coding standards prohibit the use of the condition operator, in favor of if-else statements.

 

Double negation

 

This inspection reports any instances of double negation in Groovy code, like if (!!functionCall()).

 

Statement with empty body

 

This inspection reports any instances of if,while, do or forstatements in Groovy code having empty bodies. While occasionally intended, this construction is confusing, and often the result of a typo.

 

Negated conditional expression

 

This inspection reports any instances of Groovy conditional expressions whose conditions are negated. Flipping the order of the conditional expression branches will usually increase the clarity of such statements.

 

Negated if condition expression

 

This inspection reports any instances of if statements which contain else branches and whose conditions are negated. Flipping the order of the if and elsebranches will usually increase the clarity of such statements.

 

Nested conditional expression

 

This inspection reports any ternary conditional expressions in Groovy script file that are nested inside other conditional expressions. Such nested conditionals may be very confusing. "Elvis" expressions are counted as conditionals for purpose of this inspection.

 

Nested switch statement

 

This inspection reports anyswitch statements in Groovy script file that are nested inside otherswitch statements. Such nested switch statements are confusing, and may result in unexpected behaviour.

 

Octal integer

 

This inspection reports any instances of Groovy octal integer literals. Some coding standards prohibit the use of octal literals, as they may be easily confused with decimal literals.

 

Overly complex arithmetic expression

 

This inspection reports reports any instances of Groovy arithmetic expressions with too many terms. Such expressions may be confusing and bug-prone.Use the field provided below to specify the maximum number of terms allowed in an arithmetic expression.

 

Overly complex boolean expression

 

This inspection reports reports any instances of Groovy boolean expressions with too many terms. Such expressions may be confusing and bug-prone.Use the field provided below to specify the maximum number of terms allowed in an boolean expression.

 

Pointless arithmetic expression

 

This inspection reports any instances of pointless arithmetic expressions in Groovy code. Such expressions include adding or subtracting zero, multiplying by zero or one, division by one, and shift by zero. Such expressions may be the result of automated refactorings not completely followed through to completion, and in any case are unlikely to be what the developer intended to do.

 

s Pointless boolean expressi expression

 

This inspection reports any instances of pointless or pointlessly complicated boolean expressions in Groovy code. Such expressions include anding with true, oring with false, equality comparison with a boolean literal, or negation of a boolean literal. Such expressions may be the result of automated refactorings not completely followed through to completion, and in any case are unlikely to be what the developer intended to do.

 

Result of increment or decrement used

 

This inspection reports any instances of Groovy increment or decrement expressions nested inside other expressions. While admirably terse, such expressions may be confusing, and violate the general design principle that a given construct should do precisely one thing.

 

...

Break statement

 

This inspection reports any instances of break statements in a Groovy script, other than in switch statements.

 

Conditional expression can be conditional call

 

This inspection reports instances of Groovy ternary conditional expressions which can be replaced by the conditional call (?.) operation.

 

Conditional expression can be elvis

 

This inspection reports any uses of the ternary condition operator in Groovy which can be replaced by the simpler "elvis" operator.

 

Conditional expression with identical branches

 

This inspection reports any instances of Groovy conditional expressions with identical "then" and "else" branches. Such expressions are almost certainly programmer error.

 

Constant conditional expression

 

This inspection reports any instances of Groovy conditional expressions of the formtrue?result1:result2 or false?result1:result2. These expressions sometimes occur as the result of automatic refactorings, and may obviously be simplified.

 

Constant if statement

 

This inspection reports any instances of if statements of the formif(true)... or if(false).... These statements sometimes occur due to automatic refactorings, and may obviously be simplified.

 

Continue statement

 

This inspection reports any instances of continue statements in a Groovy script.

 

Fallthrough in switch statement

 

This inspection reports any instances of 'fallthrough' in a Groovy switch statement. While occasionally useful, fallthrough is often unintended, and may lead to surpising bugs.

 

If statement with identical branches

 

This inspection reports any instances of Groovy ifstatements with identical "then" and else branches. Such statements are almost certainly programmer error.

 

If statement with too many branches

 

This inspection reports instances of Groovy if statements with too many branches. Such statements may be confusing, and are often the sign of inadequate levels of design abstraction.Use the field provided below to specify the maximum number of branches expected.

 

Loop statement that doesn't loop

 

This inspection reports any instance of Groovy for orwhile statements whose bodies are guaranteed to execute at most once. Normally, this is an indication of a bug.

 

'return' statement can be implicit

 

This inspection reports any return statements at the end of Groovy closures which can be made implicit. Groovy closures implicitly return the value of the last statement in them.

 

Switch statement with no default case

 

This inspection reports any instances of Groovy switch statements that do not containdefault labels.

 

Redundant conditional expression

 

This inspection reports any instances of Groovy ternary conditional operators of the form x?true:false or similar, which can be trivially simplified.

 

Redundant 'if' statement

 

This inspection reports instances of Groovy if statements which can be simplified to single assignment orreturn statements. For example:

No Format
 if(foo())
    {
       return true;
    }
    else
    {
       return false;
    }


can be simplified to

No Format
  return foo();

 

Unnecessary 'continue' statement

 

This inspection reports on any unnecessary Groovy continue statements at the end of loops. These may be safely removed.

 

Unnecessary 'return' statement

 

This inspection reports on any unnecessary Groovy return statements at the end of constructors and methods returningvoid. These may be safely removed.

 

...