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 java.lang.annotation.ElementType;
24  import java.lang.annotation.Target;
25  
26  import java.util.Calendar;
27  
28  /* This input file is intended to be used on strict configuration: max=0 */
29  public class InputClassFanOutComplexityAnnotations { // violation
30  
31      private int dayOfWeek = Calendar.MONDAY;
32  
33      public void foo1(@TypeAnnotation char a) {}
34  
35      public void foo2(final char @TypeAnnotation [] a) {}
36  
37      @MethodAnnotation
38      public void foo3() {}
39  
40      @Override
41      public String toString() {
42          return super.toString();
43      }
44  
45      @MyAnnotation // violation
46      public class InnerClass {
47  
48          @MyAnnotation
49          @MethodAnnotation
50          public void innerClassMethod() {}
51  
52      }
53  
54      public class InnerClass2 { // violation
55  
56          @MethodAnnotation
57          @MyAnnotation
58          public String innerClass2Method(@TypeAnnotation String parameter) {
59              return parameter.trim();
60          }
61  
62      }
63  
64      public class InnerClass3 { // violation
65  
66          @TypeAnnotation
67          private final String warningsType = "boxing";
68  
69          @MyAnnotation
70          @SuppressWarnings(value = warningsType)
71          public String innerClass3Method() {
72              return new Integer(5).toString();
73          }
74  
75      }
76  
77  }
78  
79  class OuterClass { // violation
80  
81      private static final String name = "1";
82  
83      private static final String value = "4";
84  
85      @TwoParametersAnnotation(value = "4", dayOfWeek = 1)
86      public static final String EMPTY_STRING = "";
87  
88      @TwoParametersAnnotation(value = value, dayOfWeek = Calendar.TUESDAY)
89      public static final String TAB = "\t";
90  
91  }
92  
93  @Target(ElementType.TYPE_USE)
94  @interface TypeAnnotation {}
95  
96  @Target(ElementType.METHOD)
97  @interface MethodAnnotation {}
98  
99  @MyAnnotation // violation
100 class MyClass {}
101 
102 @MyAnnotation // violation
103 interface MyInterface {}
104 
105 @interface MyAnnotation {}
106 
107 @interface TwoParametersAnnotation {
108 
109     String value();
110 
111     int dayOfWeek();
112 
113 }