AvoidInlineConditionals
Since Checkstyle 3.1
Description
          Detects inline conditionals. Here is one example of an inline conditional:
        
        
String a = getParameter("a");
String b = (a==null || a.length()<1) ? null : a.substring(1);
        Rationale: Some developers find inline conditionals hard to read, so their employer's coding standards forbid them.
Examples
To configure the check:
<module name="Checker">
  <module name="TreeWalker">
    <module name="AvoidInlineConditionals"/>
  </module>
</module>
Example:
public class Example1 {
  public void InvalidExample( String str) {
    int x = 5;
    boolean foobar = (x == 5);
    String text=null;
    text = (text == null) ? "" : text; // violation, 'Avoid inline conditionals'
    String b;
    if (str != null && str.length() >= 1) {
      b = str.substring(1);
    }
    else {
      b = null;
    }
    // violation below, 'Avoid inline conditionals'
    b = (str != null && str.length() >= 1) ? str.substring(1) : null;
  }
}
Example of Usage
Violation Messages
All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.
Package
com.puppycrawl.tools.checkstyle.checks.coding






