Groovy Documentation

groovy.org.codenarc.rule.convention
[Groovy] Class IfStatementCouldBeTernaryRule

java.lang.Object
  org.codenarc.rule.AbstractAstVisitorRule
      groovy.org.codenarc.rule.convention.IfStatementCouldBeTernaryRule

class IfStatementCouldBeTernaryRule
extends AbstractAstVisitorRule

Checks for: (1) An if statements where both the if and else blocks contain only a single return statement with a constant or literal value. (2) When the second-to-last statement in a block is an if statement with no else, where the block contains a single return statement, and the last statement in the block is a return statement, and both return statements return a constant or literal value. This checks can be disabled by setting checkLastStatementImplicitElse to false.

Authors:
Chris Mair


Property Summary
Class astVisitorClass

boolean checkLastStatementImplicitElse

String name

int priority

 

Property Detail

astVisitorClass

Class astVisitorClass


checkLastStatementImplicitElse

boolean checkLastStatementImplicitElse


name

String name


priority

int priority


 

Groovy Documentation