View Javadoc
1   /*
2   JavaNCSS
3   methodMaximum = (default)50
4   classMaximum = 80
5   fileMaximum = (default)2000
6   recordMaximum = (default)150
7   
8   
9   */
10  
11  package com.puppycrawl.tools.checkstyle.checks.metrics.javancss;
12  
13  public class InputJavaNCSSResolveMutation {
14      // violation above 'NCSS for this class is 84 (max allowed is 80)'
15  
16      public static class Some // violation 'NCSS for this class is 83 (max allowed is 80)'
17      {
18          static class SomeClass {
19              boolean flag = true;
20  
21              static boolean test(boolean k) {
22                  return k;
23              }
24          }
25  
26          private int foo() {
27              if (SomeClass.test(true)) return 4;
28              return 0;
29          }
30  
31          private int foo1() {
32              return 4;
33          }
34  
35          private int foo2() {
36              if (SomeClass.test(true))
37                  return 4;
38              return 0;
39          }
40  
41          private int foo3() {
42              if (SomeClass.test(true)) if (true) return 4;
43              return 0;
44          }
45  
46          private void foo(Object o) {
47              if (o != null) this.notify();
48          }
49  
50          private void foo2(Object o) {
51              if (o != null)
52                  this.notify();
53          }
54  
55          private void loopTest(Object o) {
56              while (o != null) {
57                  this.notify();
58              }
59              while (o != null)
60                  this.notify();
61              while (o != null) this.notify();
62              do {
63                  this.notify();
64              } while (o != null);
65              do this.notify(); while (o != null);
66              do
67                  this.notify();
68              while (o != null);
69              for (; ; )
70                  break;
71              for (; ; ) break;
72              for (int i = 0; i < 10; i++) {
73                  this.notify();
74              }
75              for (int i = 0; i < 10; i++)
76                  this.notify();
77              for (int i = 0; ; ) this.notify();
78          }
79  
80          private int getSmth(int num) {
81              int counter = 0;
82              switch (num) {
83                  case 1:
84                      counter++;
85                      break;
86                  case 2:
87                      counter += 2;
88                      break;
89                  case 3:
90                      counter += 3;
91                      break;
92                  case 6:
93                      counter += 10;
94                      break;
95                  default:
96                      counter = 100;
97                      break;
98              }
99              return counter;
100         }
101 
102         private void testElse(int k) {
103             if (k == 4) System.identityHashCode("yes");
104             else System.identityHashCode("no");
105             for (; ; ) ;
106         }
107 
108         void enhancedForLoop(int[] array) {
109             for (int value : array) return;
110         }
111 
112         private void forEachLoop() {
113             for (String s : new String[]{""}) break;
114             for (String s : new String[]{""})
115                 break;
116             for (; ; )
117                 ;
118         }
119     }
120 }