View Javadoc
1   package com.google.checkstyle.test.chapter4formatting.rule412nonemptyblocks;
2   
3   import java.util.Scanner;
4   
5   /**
6    * Test input for GitHub issue #3090.
7    * https://github.com/checkstyle/checkstyle/issues/3090
8    */
9   public class InputRightCurlyDoWhile {
10  
11      public void foo1() {
12          do {
13          } while (true);
14      }
15  
16      public void foo2() {
17          int i = 1;
18          while (i < 5) {
19              String.CASE_INSENSITIVE_ORDER.equals(i + " ");
20              i++;
21          }
22      }
23  
24      public void foo3() {
25          int i = 1;
26          do {
27              i++;
28              String.CASE_INSENSITIVE_ORDER.equals(i + " ");
29          } while (i < 5);
30      }
31  
32      public void foo4() {
33          int prog, user;
34          prog = (int)(Math.random() * 10) + 1;
35          Scanner input = new Scanner(System.in, "utf-8");
36          if( input.hasNextInt() ) {
37              do {
38                  user = input.nextInt();
39                  if(user == prog) {
40                      String.CASE_INSENSITIVE_ORDER.equals("Good!");
41                  } else {
42                      if (user > 0 && user <= 10) {
43                          String.CASE_INSENSITIVE_ORDER.equals("Bad! ");
44                          if( prog < user ) {
45                              String.CASE_INSENSITIVE_ORDER.equals("My number is less than yours.");
46                          } else {
47                              String.CASE_INSENSITIVE_ORDER.equals("My number is greater than yours.");
48                          }
49                      } else {
50                          String.CASE_INSENSITIVE_ORDER.equals("Error!");
51                      }
52                  }
53              } while( user != prog );
54          } else {
55              String.CASE_INSENSITIVE_ORDER.equals("Error!");
56          }
57          String.CASE_INSENSITIVE_ORDER.equals("Goodbye!");
58      }
59  
60      public void foo5() {
61          do {
62          } // warn
63          while (true);
64      }
65  
66      public void foo6() {
67          do {} // warn
68          while (true);
69      }
70  
71      public void foo7() {
72          do
73          {
74  
75          } while (true);
76      }
77  
78      public void foo8() {
79          do
80  
81          {
82  
83          } // warn
84  
85          while
86  
87              (true);
88      }
89  
90      public void foo9() {
91          do {} while (true);
92      }
93  }