1
<?
xml version="1.0"
?>
2
<!
DOCTYPE module PUBLIC
3
"-//Puppy Crawl//DTD Check Configuration 1.2//EN"
4
"http://www.puppycrawl.com/dtds/configuration_1_2.dtd"
>
5
6
<!--
7
8
Checkstyle configuration that checks the sun coding conventions from:
9
10
- the Java Language Specification at
11
http://java.sun.com/docs/books/jls/second_edition/html/index.html
12
13
- the Sun Code Conventions at http://java.sun.com/docs/codeconv/
14
15
- the Javadoc guidelines at
16
http://java.sun.com/j2se/javadoc/writingdoccomments/index.html
17
18
- the JDK Api documentation http://java.sun.com/j2se/docs/api/index.html
19
20
- some best practices
21
22
Checkstyle is very configurable. Be sure to read the documentation at
23
http://checkstyle.sf.net (or in your downloaded distribution).
24
25
Most Checks are configurable, be sure to consult the documentation.
26
27
To completely disable a check, just comment it out or delete it from the file.
28
29
Finally, it is worth reading the documentation.
30
31
-->
32
33
<
module
name
="Checker"
>
34
<!--
35
重复代码的检查,超过8行就认为重复,UTF-8格式 本检查一定要放在"TreeWalker"节点前,否则在
36
Checkclipse中会无法使用。(在ant下可以)
37
-->
38
<
module
name
="StrictDuplicateCode"
>
39
<
property
name
="min"
value
="8"
/>
40
<
property
name
="charset"
value
="UTF-8"
/>
41
</
module
>
42
<
module
name
="TreeWalker"
>
43
<!--
javadoc的检查
-->
44
<!--
检查所有的interface和class
-->
45
<
module
name
="JavadocType"
/>
46
<!--
检查所有方法的javadoc,可以不声明RuntimeException
-->
47
<
module
name
="JavadocMethod"
>
48
<
property
name
="allowUndeclaredRTE"
value
="true"
/>
49
</
module
>
50
<!--
检查某个变量的javadoc
-->
51
<
module
name
="JavadocVariable"
/>
52
<!--
命名方面的检查,它们都使用了Sun官方定的规则。
-->
53
<!--
类名(class 或interface) 的检查
-->
54
<
module
name
="TypeName"
/>
55
<!--
变量的检查
-->
56
<
module
name
="MemberName"
/>
57
<!--
方法名的检查
-->
58
<
module
name
="MethodName"
/>
59
<!--
方法的参数名
-->
60
<
module
name
="ParameterName "
/>
61
<!--
常量名的检查
-->
62
<
module
name
="ConstantName"
/>
63
<!--
长度方面的检查
-->
64
<!--
文件长度不超过1500行
-->
65
<
module
name
="FileLength"
>
66
<
property
name
="max"
value
="1500"
/>
67
</
module
>
68
<!--
每行不超过120个字
-->
69
<
module
name
="LineLength"
>
70
<
property
name
="max"
value
="120"
/>
71
</
module
>
72
<!--
方法不超过30行
-->
73
<
module
name
="MethodLength"
>
74
<
property
name
="tokens"
value
="METHOD_DEF"
/>
75
<
property
name
="max"
value
="30"
/>
76
</
module
>
77
<!--
方法的参数个数不超过3个。
-->
78
<
module
name
="ParameterNumber"
>
79
<
property
name
="max"
value
="3"
/>
80
</
module
>
81
<!--
多余的关键字
-->
82
<
module
name
="RedundantModifier"
/>
83
<!--
对区域的检查
-->
84
<!--
不能出现空白区域
-->
85
<
module
name
="EmptyBlock"
/>
86
<!--
所有区域都要使用大括号。
-->
87
<
module
name
="NeedBraces"
/>
88
<!--
多余的括号
-->
89
<
module
name
="AvoidNestedBlocks"
>
90
<
property
name
="allowInSwitchCase"
value
="true"
/>
91
</
module
>
92
<!--
编码方面的检查
-->
93
<!--
不许出现空语句
-->
94
<
module
name
="EmptyStatement"
/>
95
<!--
每个类都实现了equals()和hashCode()
-->
96
<
module
name
="EqualsHashCode"
/>
97
<!--
不许使用switch
-->
98
<
module
name
="IllegalToken"
>
99
<
property
name
="tokens"
value
="LITERAL_SWITCH"
/>
100
</
module
>
101
<!--
不许内部赋值
-->
102
<
module
name
="InnerAssignment"
/>
103
<!--
绝对不能容忍魔法数
-->
104
<
module
name
="MagicNumber"
/>
105
<!--
循环控制变量不能被修改
-->
106
<
module
name
="ModifiedControlVariable"
/>
107
<!--
多余的throw
-->
108
<
module
name
="RedundantThrows"
/>
109
<!--
不许使用未被简化的条件表达式
-->
110
<
module
name
="SimplifyBooleanExpression"
/>
111
<!--
不许使用未被简化的布尔返回值
-->
112
<
module
name
="SimplifyBooleanReturn"
/>
113
<!--
String的比较不能用!= 和 ==
-->
114
<
module
name
="StringLiteralEquality"
/>
115
<!--
if最多嵌套3层
-->
116
<
module
name
="NestedIfDepth"
>
117
<
property
name
="max"
value
="3"
/>
118
</
module
>
119
<!--
try最多被嵌套1层
-->
120
<
module
name
="NestedTryDepth"
/>
121
<!--
clone方法必须调用了super.clone()
-->
122
<
module
name
="SuperClone"
/>
123
<!--
finalize 必须调用了super.finalize()
-->
124
<
module
name
="SuperFinalize"
/>
125
<!--
不能catch java.lang.Exception
-->
126
<
module
name
="IllegalCatch"
>
127
<
property
name
="illegalClassNames"
value
="java.lang.Exception"
/>
128
</
module
>
129
<!--
JUnitTestCase 的核心方法存在。
-->
130
<
module
name
="JUnitTestCase"
/>
131
<!--
一个方法中最多有3个return
-->
132
<
module
name
="ReturnCount"
>
133
<
property
name
="max"
value
="3"
/>
134
</
module
>
135
<!--
不许对方法的参数赋值
-->
136
<
module
name
="ParameterAssignment"
/>
137
<!--
不许有同样内容的String
-->
138
<
module
name
="MultipleStringLiterals"
/>
139
<!--
同一行不能有多个声明
-->
140
<
module
name
="MultipleVariableDeclarations"
/>
141
<!--
各种量度
-->
142
<!--
布尔表达式的复杂度,不超过3
-->
143
<
module
name
="BooleanExpressionComplexity"
/>
144
<!--
类数据的抽象耦合,不超过7
-->
145
<
module
name
="ClassDataAbstractionCoupling"
/>
146
<!--
类的分散复杂度,不超过20
-->
147
<
module
name
="ClassFanOutComplexity"
/>
148
<!--
函数的分支复杂度,不超过10
-->
149
<
module
name
="CyclomaticComplexity"
/>
150
<!--
NPath复杂度,不超过200
-->
151
<
module
name
="NPathComplexity"
/>
152
<!--
杂项
-->
153
<!--
禁止使用System.out.println
-->
154
<
module
name
="GenericIllegalRegexp"
>
155
<
property
name
="format"
value
="System\.out\.println"
/>
156
<
property
name
="ignoreComments"
value
="true"
/>
157
</
module
>
158
<!--
不许使用与代

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158
