View Javadoc
1   /*
2   ClassFanOutComplexity
3   max = 0
4   excludedClasses = (default)ArrayIndexOutOfBoundsException, ArrayList, Boolean, Byte, \
5                     Character, Class, Collection, Deprecated, Deque, Double, DoubleStream, \
6                     EnumSet, Exception, Float, FunctionalInterface, HashMap, HashSet, \
7                     IllegalArgumentException, IllegalStateException, IndexOutOfBoundsException, \
8                     IntStream, Integer, LinkedHashMap, LinkedHashSet, LinkedList, List, Long, \
9                     LongStream, Map, NullPointerException, Object, Optional, OptionalDouble, \
10                    OptionalInt, OptionalLong, Override, Queue, RuntimeException, SafeVarargs, \
11                    SecurityException, Set, Short, SortedMap, SortedSet, Stream, String, \
12                    StringBuffer, StringBuilder, SuppressWarnings, Throwable, TreeMap, TreeSet, \
13                    UnsupportedOperationException, Void, boolean, byte, char, double, float, \
14                    int, long, short, var, void
15  excludeClassesRegexps = (default)^$
16  excludedPackages = (default)
17  
18  
19  */
20  
21  package com.puppycrawl.tools.checkstyle.checks.metrics.classfanoutcomplexity;
22  
23  import javax.naming.*;
24  import java.util.*;
25  import java.util.stream.*;
26  
27  public class InputClassFanOutComplexity { // violation
28      private class InnerClass { //singleline comment
29          public List _list = new ArrayList();
30      }
31  
32      private class AnotherInnerClass {
33          public String _string = "";
34      }
35  
36      public Set _set = /*block comment*/new HashSet();
37      public Map _map = new HashMap();
38      public String _string = "";
39      public int[] _intArray = new int[0];
40      public InnerClass _innerClass = new InnerClass();
41      public AnotherInnerClass _anotherInnerClass = new AnotherInnerClass();
42  
43      public void foo() throws NamingException {
44      }
45  
46  }
47  
48  enum InnerEnum {
49      VALUE1;
50  
51      private InnerEnum()
52      {
53          map2 = new HashMap();
54      }
55      private Set map1 = new HashSet();
56      private Map map2;
57  }
58  
59  class InputThrows { // violation
60  
61      public void get() throws NamingException, IllegalArgumentException {
62          new java.lang.ref.ReferenceQueue<Integer>();
63      }
64  }
65  
66  class InputMultiDimensionalArray {
67      public  Object[][] get() {
68          return new Object[][]{};
69      }
70  }
71  
72  class InputCollectionsExt {
73      private Collection col;
74      private EnumSet enumSet;
75      private LinkedHashMap map;
76      private LinkedHashSet set;
77  }
78  
79  class InputOptionals {
80      private Optional<Long> op1;
81      private OptionalInt op2;
82      private OptionalLong op3;
83      private OptionalDouble op4;
84  }
85  
86  class InputStreams {
87      private Stream s1;
88      private IntStream s2;
89      private LongStream s3;
90      private DoubleStream s4;
91  }