View Javadoc
1   /*xml
2   <module name="Checker">
3     <module name="TreeWalker">
4       <module name="AvoidInlineConditionals"/>
5     </module>
6   </module>
7   */
8   package com.puppycrawl.tools.checkstyle.checks.coding.avoidinlineconditionals;
9   
10  // xdoc section -- start
11  public class Example1 {
12    public void InvalidExample( String str) {
13      int x = 5;
14      boolean foobar = (x == 5);
15      String text=null;
16      text = (text == null) ? "" : text; // violation, 'Avoid inline conditionals'
17      String b;
18      if (str != null && str.length() >= 1) {
19        b = str.substring(1);
20      }
21      else {
22        b = null;
23      }
24      // violation below, 'Avoid inline conditionals'
25      b = (str != null && str.length() >= 1) ? str.substring(1) : null;
26    }
27  }
28  // xdoc section -- end