首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

Checkstyle配置例证

2013-11-18 
Checkstyle配置例子?xml?version1.0???2!DOCTYPE?module?PUBLIC??3????-//Puppy?Crawl//DTD?Check?

Checkstyle配置例子
<?xml?version="1.0"?>
??2Checkstyle配置例证<!DOCTYPE?module?PUBLIC
??3Checkstyle配置例证????"-//Puppy?Crawl//DTD?Check?Configuration?1.2//EN"
??4Checkstyle配置例证????"http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
??5Checkstyle配置例证
??6Checkstyle配置例证<!--
??7Checkstyle配置例证
??8Checkstyle配置例证??Checkstyle?configuration?that?checks?the?sun?coding?conventions?from:
??9Checkstyle配置例证
?10Checkstyle配置例证????-?the?Java?Language?Specification?at
?11Checkstyle配置例证??????http://java.sun.com/docs/books/jls/second_edition/html/index.html
?12Checkstyle配置例证
?13Checkstyle配置例证????-?the?Sun?Code?Conventions?at?http://java.sun.com/docs/codeconv/
?14Checkstyle配置例证
?15Checkstyle配置例证????-?the?Javadoc?guidelines?at
?16Checkstyle配置例证??????http://java.sun.com/j2se/javadoc/writingdoccomments/index.html
?17Checkstyle配置例证
?18Checkstyle配置例证????-?the?JDK?Api?documentation?http://java.sun.com/j2se/docs/api/index.html
?19Checkstyle配置例证
?20Checkstyle配置例证????-?some?best?practices
?21Checkstyle配置例证
?22Checkstyle配置例证??Checkstyle?is?very?configurable.?Be?sure?to?read?the?documentation?at
?23Checkstyle配置例证??http://checkstyle.sf.net?(or?in?your?downloaded?distribution).
?24Checkstyle配置例证
?25Checkstyle配置例证??Most?Checks?are?configurable,?be?sure?to?consult?the?documentation.
?26Checkstyle配置例证
?27Checkstyle配置例证??To?completely?disable?a?check,?just?comment?it?out?or?delete?it?from?the?file.
?28Checkstyle配置例证
?29Checkstyle配置例证??Finally,?it?is?worth?reading?the?documentation.
?30Checkstyle配置例证
?31Checkstyle配置例证-->
?32Checkstyle配置例证
?33Checkstyle配置例证<module?name="Checker">
?34Checkstyle配置例证????<!--
?35Checkstyle配置例证????????重复代码的检查,超过8行就认为重复,UTF-8格式?本检查一定要放在"TreeWalker"节点前,否则在
?36Checkstyle配置例证????????Checkclipse中会无法使用。(在ant下可以)
?37Checkstyle配置例证????-->
?38Checkstyle配置例证????<module?name="StrictDuplicateCode">
?39Checkstyle配置例证????????<property?name="min"?value="8"?/>
?40Checkstyle配置例证????????<property?name="charset"?value="UTF-8"?/>
?41Checkstyle配置例证????</module>
?42Checkstyle配置例证????<module?name="TreeWalker">
?43Checkstyle配置例证????????<!--?javadoc的检查?-->
?44Checkstyle配置例证????????<!--?检查所有的interface和class?-->
?45Checkstyle配置例证????????<module?name="JavadocType"?/>
?46Checkstyle配置例证????????<!--?检查所有方法的javadoc,可以不声明RuntimeException?-->
?47Checkstyle配置例证????????<module?name="JavadocMethod">
?48Checkstyle配置例证????????????<property?name="allowUndeclaredRTE"?value="true"?/>
?49Checkstyle配置例证????????</module>
?50Checkstyle配置例证????????<!--?检查某个变量的javadoc?-->
?51Checkstyle配置例证????????<module?name="JavadocVariable"?/>
?52Checkstyle配置例证????????<!--?命名方面的检查,它们都使用了Sun官方定的规则。?-->
?53Checkstyle配置例证????????<!--?类名(class?或interface)?的检查?-->
?54Checkstyle配置例证????????<module?name="TypeName"?/>
?55Checkstyle配置例证????????<!--?变量的检查?-->
?56Checkstyle配置例证????????<module?name="MemberName"?/>
?57Checkstyle配置例证????????<!--?方法名的检查?-->
?58Checkstyle配置例证????????<module?name="MethodName"?/>
?59Checkstyle配置例证????????<!--?方法的参数名?-->
?60Checkstyle配置例证????????<module?name="ParameterName?"?/>
?61Checkstyle配置例证????????<!--?常量名的检查?-->
?62Checkstyle配置例证????????<module?name="ConstantName"?/>
?63Checkstyle配置例证????????<!--?长度方面的检查?-->
?64Checkstyle配置例证????????<!--?文件长度不超过1500行?-->
?65Checkstyle配置例证????????<module?name="FileLength">
?66Checkstyle配置例证????????????<property?name="max"?value="1500"?/>
?67Checkstyle配置例证????????</module>
?68Checkstyle配置例证????????<!--?每行不超过120个字-->
?69Checkstyle配置例证????????<module?name="LineLength">
?70Checkstyle配置例证????????????<property?name="max"?value="120"?/>
?71Checkstyle配置例证????????</module>
?72Checkstyle配置例证????????<!--?方法不超过30行?-->
?73Checkstyle配置例证????????<module?name="MethodLength">
?74Checkstyle配置例证????????????<property?name="tokens"?value="METHOD_DEF"?/>
?75Checkstyle配置例证????????????<property?name="max"?value="30"?/>
?76Checkstyle配置例证????????</module>
?77Checkstyle配置例证????????<!--?方法的参数个数不超过3个。?-->
?78Checkstyle配置例证????????<module?name="ParameterNumber">
?79Checkstyle配置例证????????????<property?name="max"?value="3"?/>
?80Checkstyle配置例证????????</module>
?81Checkstyle配置例证????????<!--?多余的关键字?-->
?82Checkstyle配置例证????????<module?name="RedundantModifier"?/>
?83Checkstyle配置例证????????<!--?对区域的检查?-->
?84Checkstyle配置例证????????<!--?不能出现空白区域?-->
?85Checkstyle配置例证????????<module?name="EmptyBlock"?/>
?86Checkstyle配置例证????????<!--?所有区域都要使用大括号。?-->
?87Checkstyle配置例证????????<module?name="NeedBraces"?/>
?88Checkstyle配置例证????????<!--?多余的括号?-->
?89Checkstyle配置例证????????<module?name="AvoidNestedBlocks">
?90Checkstyle配置例证????????????<property?name="allowInSwitchCase"?value="true"?/>
?91Checkstyle配置例证????????</module>
?92Checkstyle配置例证????????<!--?编码方面的检查?-->
?93Checkstyle配置例证????????<!--?不许出现空语句?-->
?94Checkstyle配置例证????????<module?name="EmptyStatement"?/>
?95Checkstyle配置例证????????<!--?每个类都实现了equals()和hashCode()?-->
?96Checkstyle配置例证????????<module?name="EqualsHashCode"?/>
?97Checkstyle配置例证????????<!--?不许使用switch?-->
?98Checkstyle配置例证????????<module?name="IllegalToken">
?99Checkstyle配置例证????????????<property?name="tokens"?value="LITERAL_SWITCH"?/>
100Checkstyle配置例证????????</module>
101Checkstyle配置例证????????<!--?不许内部赋值?-->
102Checkstyle配置例证????????<module?name="InnerAssignment"?/>
103Checkstyle配置例证????????<!--?绝对不能容忍魔法数?-->
104Checkstyle配置例证????????<module?name="MagicNumber"?/>
105Checkstyle配置例证????????<!--?循环控制变量不能被修改?-->
106Checkstyle配置例证????????<module?name="ModifiedControlVariable"?/>
107Checkstyle配置例证????????<!--?多余的throw?-->
108Checkstyle配置例证????????<module?name="RedundantThrows"?/>
109Checkstyle配置例证????????<!--?不许使用未被简化的条件表达式?-->
110Checkstyle配置例证????????<module?name="SimplifyBooleanExpression"?/>
111Checkstyle配置例证????????<!--?不许使用未被简化的布尔返回值?-->
112Checkstyle配置例证????????<module?name="SimplifyBooleanReturn"?/>
113Checkstyle配置例证????????<!--?String的比较不能用!=?和?==?-->
114Checkstyle配置例证????????<module?name="StringLiteralEquality"?/>
115Checkstyle配置例证????????<!--?if最多嵌套3层?-->
116Checkstyle配置例证????????<module?name="NestedIfDepth">
117Checkstyle配置例证????????????<property?name="max"?value="3"?/>
118Checkstyle配置例证????????</module>
119Checkstyle配置例证????????<!--?try最多被嵌套1层?-->
120Checkstyle配置例证????????<module?name="NestedTryDepth"?/>
121Checkstyle配置例证????????<!--?clone方法必须调用了super.clone()?-->
122Checkstyle配置例证????????<module?name="SuperClone"?/>
123Checkstyle配置例证????????<!--?finalize?必须调用了super.finalize()?-->
124Checkstyle配置例证????????<module?name="SuperFinalize"?/>
125Checkstyle配置例证????????<!--?不能catch?java.lang.Exception?-->
126Checkstyle配置例证????????<module?name="IllegalCatch">
127Checkstyle配置例证????????????<property?name="illegalClassNames"?value="java.lang.Exception"?/>
128Checkstyle配置例证????????</module>
129Checkstyle配置例证????????<!--?JUnitTestCase?的核心方法存在。?-->
130Checkstyle配置例证????????<module?name="JUnitTestCase"?/>
131Checkstyle配置例证????????<!--?一个方法中最多有3个return?-->
132Checkstyle配置例证????????<module?name="ReturnCount">
133Checkstyle配置例证????????????<property?name="max"?value="3"?/>
134Checkstyle配置例证????????</module>
135Checkstyle配置例证????????<!--?不许对方法的参数赋值?-->
136Checkstyle配置例证????????<module?name="ParameterAssignment"?/>
137Checkstyle配置例证????????<!--?不许有同样内容的String?-->
138Checkstyle配置例证????????<module?name="MultipleStringLiterals"?/>
139Checkstyle配置例证????????<!--?同一行不能有多个声明?-->
140Checkstyle配置例证????????<module?name="MultipleVariableDeclarations"?/>
141Checkstyle配置例证????????<!--?各种量度?-->
142Checkstyle配置例证????????<!--?布尔表达式的复杂度,不超过3?-->
143Checkstyle配置例证????????<module?name="BooleanExpressionComplexity"?/>
144Checkstyle配置例证????????<!--?类数据的抽象耦合,不超过7?-->
145Checkstyle配置例证????????<module?name="ClassDataAbstractionCoupling"?/>
146Checkstyle配置例证????????<!--?类的分散复杂度,不超过20?-->
147Checkstyle配置例证????????<module?name="ClassFanOutComplexity"?/>
148Checkstyle配置例证????????<!--?函数的分支复杂度,不超过10?-->
149Checkstyle配置例证????????<module?name="CyclomaticComplexity"?/>
150Checkstyle配置例证????????<!--?NPath复杂度,不超过200?-->
151Checkstyle配置例证????????<module?name="NPathComplexity"?/>
152Checkstyle配置例证????????<!--?杂项?-->
153Checkstyle配置例证????????<!--?禁止使用System.out.println?-->
154Checkstyle配置例证????????<module?name="GenericIllegalRegexp">
155Checkstyle配置例证????????????<property?name="format"?value="System\.out\.println"?/>
156Checkstyle配置例证????????????<property?name="ignoreComments"?value="true"?/>
157Checkstyle配置例证????????</module>
158Checkstyle配置例证????????<!--?不许使用与代Checkstyle配置例证主页:?http://checkstyle.sourceforge.net/ 
Checkstyle配置例证
Checkstyle配置例证Checkstyle配置文件的简要说明
Checkstyle配置例证关于配置文件的各个模块的更多细节,请参考CHECKSTYLE_HOME/docs/index.html?
Checkstyle配置例证<?xml?version="1.0"?encoding="UTF-8"?>
Checkstyle配置例证<!DOCTYPE?module?PUBLIC?"-//Puppy?Crawl//DTD?Check?Configuration?1.2//EN"
Checkstyle配置例证"http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
Checkstyle配置例证<!--?对于所有的模块来书,如果有这个模块则说明检测这一项,没有则不检测这一项?-->
Checkstyle配置例证<!--?所有的模块中,其ROOT必须为Checker?-->
Checkstyle配置例证<module?name="Checker">
Checkstyle配置例证<!--?检验每个包是否存在package.html文件-->
Checkstyle配置例证<!--?See?http://checkstyle.sf.net/config_javadoc.html#PackageHtml?-->
Checkstyle配置例证<!--
Checkstyle配置例证<module?name="PackageHtml"/>
Checkstyle配置例证-->
Checkstyle配置例证<!--?检验每个文件末尾是否有一个空行-->
Checkstyle配置例证<!--?See?http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile?-->
Checkstyle配置例证<!--
Checkstyle配置例证<module?name="NewlineAtEndOfFile"/>
Checkstyle配置例证-->
Checkstyle配置例证<!--?Checks?that?property?files?contain?the?same?keys.?-->
Checkstyle配置例证<!--?See?http://checkstyle.sf.net/config_misc.html#Translation?-->
Checkstyle配置例证<module?name="Translation"/>
Checkstyle配置例证<module?name="TreeWalker">
Checkstyle配置例证<!--?Checks?for?Javadoc?comments.?-->
Checkstyle配置例证<!--?See?http://checkstyle.sf.net/config_javadoc.html?-->
Checkstyle配置例证<!--?Checks?Javadoc?comments?for?method?definitions.-->
Checkstyle配置例证<module?name="JavadocMethod">
Checkstyle配置例证<property?name="scope"?value="public"/>
Checkstyle配置例证<!--?是否允许错误的参数声明,true为允许,缺省为不允许?-->
Checkstyle配置例证<property?name="allowMissingParamTags"?value="true"/>
Checkstyle配置例证<!--?是否允许错误的错误声明,true为允许,缺省为不允许?-->
Checkstyle配置例证<property?name="allowMissingThrowsTags"?value="true"/>
Checkstyle配置例证<!--?是否允许错误的返回类型声明,true为允许,缺省为不允许?-->
Checkstyle配置例证<property?name="allowMissingReturnTag"?value="true"/>
Checkstyle配置例证</module>
Checkstyle配置例证<!--Checks?Javadoc?comments?for?class?and?interface?definitions.-->
Checkstyle配置例证<module?name="JavadocType"/>
Checkstyle配置例证<!--?Checks?that?variables?have?Javadoc?comments.-->
Checkstyle配置例证<module?name="JavadocVariable">
Checkstyle配置例证<property?name="scope"?value="protected"/>
Checkstyle配置例证</module>
Checkstyle配置例证<!--?检查Javadoc的格式?-->
Checkstyle配置例证<module?name="JavadocStyle">
Checkstyle配置例证<property?name="scope"?value="public"/>
Checkstyle配置例证<!--?Comment的第一句的末尾是否要有一个句号,true必须有,default为true?-->
Checkstyle配置例证<property?name="checkFirstSentence"?value="false"/>
Checkstyle配置例证<!--?检查错误的HTML脚本,比如不匹配,true检查,default为true?-->
Checkstyle配置例证<property?name="checkHtml"?value="true"/>
Checkstyle配置例证</module>
Checkstyle配置例证<!--?Checks?for?Naming?Conventions.?-->
Checkstyle配置例证<!--?See?http://checkstyle.sf.net/config_naming.html?-->
Checkstyle配置例证<!--?确省必须以Abstract开始或者以Factory结束?-->
Checkstyle配置例证<!--
Checkstyle配置例证<module?name="AbstractClassName"/>
Checkstyle配置例证-->
Checkstyle配置例证<module?name="ConstantName"/>
Checkstyle配置例证<module?name="LocalFinalVariableName"/>
Checkstyle配置例证<module?name="LocalVariableName"/>
Checkstyle配置例证<module?name="MemberName"/>
Checkstyle配置例证<module?name="MethodName"/>
Checkstyle配置例证<module?name="PackageName"/>
Checkstyle配置例证<module?name="ParameterName"/>
Checkstyle配置例证<module?name="StaticVariableName"/>
Checkstyle配置例证<module?name="TypeName"/>
Checkstyle配置例证<!--?Checks?for?Headers?-->
Checkstyle配置例证<!--?See?http://checkstyle.sf.net/config_header.html?-->
Checkstyle配置例证<!--?检查文件是否以指定文件开始,这里最好是放一些版权信息和工程描述?-->
Checkstyle配置例证<!--?headerFile:指定的文件?-->
Checkstyle配置例证<!--?ignoreLines:忽略哪些行,以","分隔?-->
Checkstyle配置例证<!--
Checkstyle配置例证<module?name="Header">
Checkstyle配置例证<property?name="headerFile"?value="java.header"/>
Checkstyle配置例证<property?name="ignoreLines"?value="2,?3,?4,?5"/>
Checkstyle配置例证</module>
Checkstyle配置例证-->
Checkstyle配置例证<!--?Following?interprets?the?header?file?as?regular?expressions.?-->
Checkstyle配置例证<!--
Checkstyle配置例证<module?name="RegexpHeader"/>
Checkstyle配置例证-->
Checkstyle配置例证<!--?Checks?for?imports?-->
Checkstyle配置例证<!--?See?http://checkstyle.sf.net/config_import.html?-->
Checkstyle配置例证<!--?检查使用*号的导入,默认为全部类?-->
Checkstyle配置例证<module?name="AvoidStarImport"/>
Checkstyle配置例证<!--?检查是否有非法的包,确省检查sun.*;对于某些包是不建议直接调用的?-->
Checkstyle配置例证<module?name="IllegalImport">
Checkstyle配置例证<property?name="illegalPkgs"?value="sun.*"/>
Checkstyle配置例证</module>
Checkstyle配置例证<!--?检查多于的导入,如一个类导入了多次?-->
Checkstyle配置例证<module?name="RedundantImport"/>
Checkstyle配置例证<!--?检查没有使用的导入?-->
Checkstyle配置例证<module?name="UnusedImports"/>
Checkstyle配置例证<!--?导入排序?-->
Checkstyle配置例证<!--?groups:分组,哪些是一组的?-->
Checkstyle配置例证<!--?ordered:同一个组内是否排序,true排序,确省为true?-->
Checkstyle配置例证<!--?separated:各个组之间是否需要用空行分隔,确省为false?-->
Checkstyle配置例证<!--?caseSensitive:是否是大小写敏感的,确省是?-->
Checkstyle配置例证<!--
Checkstyle配置例证<module?name="ImportOrder">
Checkstyle配置例证<property?name="groups"?value="java,javax"/>
Checkstyle配置例证<property?name="ordered"?value="true"/>
Checkstyle配置例证<property?name="separated"?value="true"/>
Checkstyle配置例证<property?name="caseSensitive"?value="true"/>
Checkstyle配置例证</module>
Checkstyle配置例证-->
Checkstyle配置例证<!--?Checks?for?Size?Violations.?-->
Checkstyle配置例证<!--?See?http://checkstyle.sf.net/config_sizes.html?-->
Checkstyle配置例证<!--?检查方法内可执行语句的个数,确省为30行?-->
Checkstyle配置例证<!--
Checkstyle配置例证<module?name="ExecutableStatementCount">
Checkstyle配置例证<property?name="max"?value="30"/>
Checkstyle配置例证</module>
Checkstyle配置例证-->
Checkstyle配置例证<!--?文件的最大行数,缺省为1500?-->
Checkstyle配置例证<module?name="FileLength">
Checkstyle配置例证<property?name="max"?value="2000"/>
Checkstyle配置例证</module>
Checkstyle配置例证<!--?每行的最大字符数,缺省为80?-->
Checkstyle配置例证<module?name="LineLength">
Checkstyle配置例证<!--?忽略指定格式的行,如*号开始的,等?-->
Checkstyle配置例证<!--
Checkstyle配置例证<property?name="ignorePattern"?value="^?*\*?*[^?]+$"/>
Checkstyle配置例证-->
Checkstyle配置例证<property?name="max"?value="120"/>
Checkstyle配置例证</module>
Checkstyle配置例证<!--?方法的最大行数,缺省为150?-->
Checkstyle配置例证<module?name="MethodLength">
Checkstyle配置例证<property?name="max"?value="200"/>
Checkstyle配置例证<!--?统计时是否包括空行和以//开始的注释,缺省为统计(true)-->
Checkstyle配置例证<property?name="countEmpty"?value="false"/>
Checkstyle配置例证</module>
Checkstyle配置例证<!--?匿名类的最大行数,缺省为20?-->
Checkstyle配置例证<module?name="AnonInnerLength">
Checkstyle配置例证<property?name="max"?value="60"/>
Checkstyle配置例证</module>
Checkstyle配置例证<!--?检查方法和构造子参数的最大个数,缺省为7?-->
Checkstyle配置例证<module?name="ParameterNumber"/>
Checkstyle配置例证<!--?Checks?for?whitespace?-->
Checkstyle配置例证<!--?See?http://checkstyle.sf.net/config_whitespace.html?-->
Checkstyle配置例证<module?name="EmptyForInitializerPad"/>
Checkstyle配置例证<module?name="EmptyForIteratorPad"/>
Checkstyle配置例证<module?name="MethodParamPad">
Checkstyle配置例证<property?name="allowLineBreaks"?value="true"/>
Checkstyle配置例证</module>
Checkstyle配置例证<module?name="NoWhitespaceAfter"/>
Checkstyle配置例证<module?name="NoWhitespaceBefore"/>
Checkstyle配置例证<module?name="OperatorWrap"/>
Checkstyle配置例证<module?name="ParenPad"/>
Checkstyle配置例证<module?name="TypecastParenPad"/>
Checkstyle配置例证<module?name="TabCharacter"/>
Checkstyle配置例证<module?name="WhitespaceAfter"/>
Checkstyle配置例证<module?name="WhitespaceAround"/>
Checkstyle配置例证<!--?Modifier?Checks?-->
Checkstyle配置例证<!--?See?http://checkstyle.sf.net/config_modifiers.html?-->
Checkstyle配置例证<!--?要求JLS?suggestions?-->
Checkstyle配置例证<!--
Checkstyle配置例证<module?name="ModifierOrder"/>
Checkstyle配置例证-->
Checkstyle配置例证<module?name="RedundantModifier"/>
Checkstyle配置例证<!--?Checks?for?blocks.?You?know,?those?{}'s?-->
Checkstyle配置例证<!--?See?http://checkstyle.sf.net/config_blocks.html?-->
Checkstyle配置例证<!--?检查空块?-->
Checkstyle配置例证<!--
Checkstyle配置例证<module?name="EmptyBlock"/>
Checkstyle配置例证-->
Checkstyle配置例证<module?name="LeftCurly"/>
Checkstyle配置例证<!--?检查只有必须有{},确省为必须,主要在if,else时有这样的情况?-->
Checkstyle配置例证<module?name="NeedBraces"/>
Checkstyle配置例证<!--?检查"}",确省在同一行?-->
Checkstyle配置例证<module?name="RightCurly">
Checkstyle配置例证<property?name="option"?value="alone"/>
Checkstyle配置例证</module>
Checkstyle配置例证<!--?检查多余嵌套的{},请看文档,不易说明?-->
Checkstyle配置例证<module?name="AvoidNestedBlocks"/>
Checkstyle配置例证<!--?Checks?for?common?coding?problems?-->
Checkstyle配置例证<!--?See?http://checkstyle.sf.net/config_coding.html?-->
Checkstyle配置例证<module?name="AvoidInlineConditionals"/>
Checkstyle配置例证<module?name="CovariantEquals"/>
Checkstyle配置例证<module?name="DeclarationOrder"/>
Checkstyle配置例证<module?name="DefaultComesLast"/>
Checkstyle配置例证<module?name="DoubleCheckedLocking"/>
Checkstyle配置例证<!--
Checkstyle配置例证<module?name="EmptyStatement"/>
Checkstyle配置例证-->
Checkstyle配置例证<module?name="EqualsHashCode"/>
Checkstyle配置例证<!--?变量必须初始化为自己的类型,如果给一个Object类型的变量初始化为null会提示?-->
Checkstyle配置例证<!--
Checkstyle配置例证<module?name="ExplicitInitialization"/>
Checkstyle配置例证-->
Checkstyle配置例证<module?name="FallThrough"/>
Checkstyle配置例证<!--
Checkstyle配置例证<module?name="FinalLocalVariable"/>
Checkstyle配置例证-->
Checkstyle配置例证<module?name="HiddenField">
Checkstyle配置例证<property?name="ignoreConstructorParameter"?value="true"/>
Checkstyle配置例证<property?name="ignoreSetter"?value="true"/>
Checkstyle配置例证</module>
Checkstyle配置例证<!--?Exception,?Throwable,?RuntimeException是不允许catch的?-->
Checkstyle配置例证<!--
Checkstyle配置例证<module?name="IllegalCatch"/>
Checkstyle配置例证-->
Checkstyle配置例证<module?name="IllegalInstantiation"/>
Checkstyle配置例证<!--?
Checkstyle配置例证<module?name="IllegalToken"/>
Checkstyle配置例证-->
Checkstyle配置例证<module?name="IllegalTokenText"/>
Checkstyle配置例证<module?name="IllegalType"/>
Checkstyle配置例证<module?name="InnerAssignment"/>
Checkstyle配置例证<!--检查直接数
Checkstyle配置例证<module?name="MagicNumber"/>
Checkstyle配置例证检查是否有构造子
Checkstyle配置例证<module?name="MissingCtor"/>
Checkstyle配置例证-->
Checkstyle配置例证<module?name="MissingSwitchDefault"/>
Checkstyle配置例证<module?name="MultipleVariableDeclarations"/>
Checkstyle配置例证<!--
Checkstyle配置例证<module?name="JUnitTestCase"/>
Checkstyle配置例证<module?name="NestedIfDepth"">
Checkstyle配置例证<property?name="max"?value="5"/>
Checkstyle配置例证</module>
Checkstyle配置例证<module?name="NestedTryDepth"">
Checkstyle配置例证<property?name="max"?value="5"/>
Checkstyle配置例证</module>
Checkstyle配置例证<module?name="PackageDeclaration"/>
Checkstyle配置例证<module?name="ReturnCount"/>
Checkstyle配置例证-->
Checkstyle配置例证<!--?不能为参数付值?-->
Checkstyle配置例证<!--
Checkstyle配置例证<module?name="ParameterAssignment"/>
Checkstyle配置例证-->
Checkstyle配置例证<module?name="RedundantThrows"/>
Checkstyle配置例证<!--?不能理解的,好像是bug
Checkstyle配置例证<module?name="RequireThis"/>
Checkstyle配置例证-->
Checkstyle配置例证<module?name="SimplifyBooleanExpression"/>
Checkstyle配置例证<module?name="SimplifyBooleanReturn"/>
Checkstyle配置例证<module?name="StringLiteralEquality"/>
Checkstyle配置例证<module?name="SuperClone"/>
Checkstyle配置例证<module?name="SuperFinalize"/>
Checkstyle配置例证<module?name="UnnecessaryParentheses"/>
Checkstyle配置例证<!--?Checks?for?class?design?-->
Checkstyle配置例证<!--?See?http://checkstyle.sf.net/config_design.html?-->
Checkstyle配置例证<!--?要求一个方法必须声明为Extension的,否则必声明为abstract,?final?or?empty?-->
Checkstyle配置例证<!--
Checkstyle配置例证<module?name="DesignForExtension"/>
Checkstyle配置例证-->
Checkstyle配置例证<!--?检查private构造子是否声明为final,这里有个问题,在Java中构造子是不能声明为final的?-->
Checkstyle配置例证<!--
Checkstyle配置例证<module?name="FinalClass"/>
Checkstyle配置例证-->
Checkstyle配置例证<!--?要求一定要有一个构造子?-->
Checkstyle配置例证<!--
Checkstyle配置例证<module?name="HideUtilityClassConstructor"/>
Checkstyle配置例证-->
Checkstyle配置例证<module?name="InterfaceIsType"/>
Checkstyle配置例证<!--?检查变量的可见性,确省只允许static?final?为public,否则只能为private?-->
Checkstyle配置例证<module?name="VisibilityModifier">
Checkstyle配置例证<property?name="packageAllowed"?value="true"/>
Checkstyle配置例证<property?name="protectedAllowed"?value="true"/>
Checkstyle配置例证</module>
Checkstyle配置例证<!--
Checkstyle配置例证<module?name="MutableException"/>
Checkstyle配置例证-->
Checkstyle配置例证<!--?限制抛出声明的指定数量,确省为1?-->
Checkstyle配置例证<!--
Checkstyle配置例证<module?name="ThrowsCount"/>
Checkstyle配置例证-->
Checkstyle配置例证<!--?Miscellaneous?other?checks.?-->
Checkstyle配置例证<!--?See?http://checkstyle.sf.net/config_misc.html?-->
Checkstyle配置例证<!--?数组的声明是否允许Java的类型,确省为允许,Java类型为String[]?xx,C++的类型为String?xx[];?-->
Checkstyle配置例证<module?name="ArrayTypeStyle"/>
Checkstyle配置例证<!--
Checkstyle配置例证<module?name="FinalParameters"/>
Checkstyle配置例证-->
Checkstyle配置例证<!--?一般性的代码问题,不好的习惯等,可以多?-->
Checkstyle配置例证<!--?文件中使用了System.out.print等-->
Checkstyle配置例证<module?name="GenericIllegalRegexp">
Checkstyle配置例证<property?name="format"?value="System\.out\.print"/>
Checkstyle配置例证<property?name="message"?value="bad?practice?of?use?System.out.print"/>
Checkstyle配置例证</module>
Checkstyle配置例证<module?name="GenericIllegalRegexp">
Checkstyle配置例证<property?name="format"?value="System\.exit"/>
Checkstyle配置例证<property?name="message"?value="bad?practice?of?use?System.exit"/>
Checkstyle配置例证</module>
Checkstyle配置例证<module?name="GenericIllegalRegexp">
Checkstyle配置例证<property?name="format"?value="printStackTrace"/>
Checkstyle配置例证<property?name="message"?value="bad?practice?of?use?printStackTrace"/>
Checkstyle配置例证</module>
Checkstyle配置例证<!--?关于Task,你可以声明自己的Task标识?-->
Checkstyle配置例证<module?name="TodoComment">
Checkstyle配置例证<property?name="format"?value="TODO"/>
Checkstyle配置例证</module>
Checkstyle配置例证<!--?强迫//注释必须如何,入下要求只能有一行,具体看文档?-->
Checkstyle配置例证<!--
Checkstyle配置例证<module?name="TrailingComment">
Checkstyle配置例证<property?name="format"?value="^\\s*$"/>
Checkstyle配置例证</module>
Checkstyle配置例证-->
Checkstyle配置例证<!--?main方法经常会在debug时使用,但发行版本的时候可能并不需要这个方法,提示?-->
Checkstyle配置例证<!--
Checkstyle配置例证<module?name="UncommentedMain"/>
Checkstyle配置例证-->
Checkstyle配置例证<!--?当定义一个常量时,希望使用大写的L来代替小写的l,原因是小写的l和数字1很象?-->
Checkstyle配置例证<module?name="UpperEll"/>
Checkstyle配置例证<!--?检查正确的缩进,这个更象是个人习惯?-->
Checkstyle配置例证<!--
Checkstyle配置例证<module?name="Indentation">
Checkstyle配置例证<property?name="braceAdjustment"?value="0"/>
Checkstyle配置例证</module>
Checkstyle配置例证-->
Checkstyle配置例证<!--?Checks?For?Metrics?-->
Checkstyle配置例证<!--?See?http://checkstyle.sf.net/config_metrics.html?-->
Checkstyle配置例证<!--?检查嵌套复杂度?-->
Checkstyle配置例证<module?name="CyclomaticComplexity">
Checkstyle配置例证<property?name="max"?value="12"/>
Checkstyle配置例证</module>
Checkstyle配置例证</module>
Checkstyle配置例证</module>
Checkstyle配置例证Checkstyle常见的输出结果
Checkstyle配置例证1.Type?is?missing?a?javadoc?commentClass?
Checkstyle配置例证缺少类型说明
Checkstyle配置例证2.“{”?should?be?on?the?previous?line
Checkstyle配置例证“{”?应该位于前一行
Checkstyle配置例证3.Methods?is?missing?a?javadoc?comment
Checkstyle配置例证方法前面缺少javadoc注释
Checkstyle配置例证4.Expected?@throws?tag?for?“Exception”
Checkstyle配置例证在注释中希望有@throws的说明
Checkstyle配置例证5.“.”?Is?preceeded?with?whitespace?“.”
Checkstyle配置例证前面不能有空格
Checkstyle配置例证6.“.”?Is?followed?by?whitespace“.”
Checkstyle配置例证后面不能有空格
Checkstyle配置例证7.“=”?is?not?preceeded?with?whitespace
Checkstyle配置例证“=”?前面缺少空格
Checkstyle配置例证8.“=”?is?not?followed?with?whitespace?
Checkstyle配置例证“=”?后面缺少空格
Checkstyle配置例证9.“}”?should?be?on?the?same?line?
Checkstyle配置例证“}”?应该与下条语句位于同一行
Checkstyle配置例证10.Unused?@param?tag?for?“unused”
Checkstyle配置例证没有参数“unused”,不需注释
Checkstyle配置例证11.Variable?“CA”?missing?javadoc
Checkstyle配置例证变量“CA”缺少javadoc注释
Checkstyle配置例证12.Line?longer?than?80characters?
Checkstyle配置例证行长度超过80
Checkstyle配置例证13.Line?contains?a?tab?character
Checkstyle配置例证行含有”tab”?字符
Checkstyle配置例证14.Redundant?“Public”?modifier
Checkstyle配置例证冗余的“public”?modifier
Checkstyle配置例证15.Final?modifier?out?of?order?with?the?JSL
Checkstyle配置例证suggestionFinal?modifier的顺序错误
Checkstyle配置例证16.Avoid?using?the?“.*”?form?of?import
Checkstyle配置例证Import格式避免使用“.*”
Checkstyle配置例证17.Redundant?import?from?the?same?package
Checkstyle配置例证从同一个包中Import内容
Checkstyle配置例证18.Unused?import-java.util.list
Checkstyle配置例证Import进来的java.util.list没有被使用
Checkstyle配置例证19.Duplicate?import?to?line?13
Checkstyle配置例证重复Import同一个内容
Checkstyle配置例证20.Import?from?illegal?package
Checkstyle配置例证从非法包中?Import内容
Checkstyle配置例证21.“while”?construct?must?use?“{}”
Checkstyle配置例证“while”?语句缺少“{}”
Checkstyle配置例证22.Variable?“sTest1”?must?be?private?and?have?accessor?method
Checkstyle配置例证变量“sTest1”应该是private的,并且有调用它的方法
Checkstyle配置例证23.Variable?“ABC”?must?match?pattern?“^[a-z][a-zA-Z0-9]*$”?
Checkstyle配置例证变量“ABC”不符合命名规则“^[a-z][a-zA-Z0-9]*$”
Checkstyle配置例证24.“(”?is?followed?by?whitespace?
Checkstyle配置例证“(”?后面不能有空格
Checkstyle配置例证25.“)”?is?proceeded?by?whitespace
Checkstyle配置例证“)”?前面不能有空格
Checkstyle配置例证?
Checkstyle配置例证
Checkstyle配置例证码同行的注释?-->
159Checkstyle配置例证????????<module?name="TrailingComment"?/>
160Checkstyle配置例证????</module>
161Checkstyle配置例证????<!--?检查翻译文件?-->
162Checkstyle配置例证????<module?name="Translation"?/>
163Checkstyle配置例证</module>
164Checkstyle配置例证




checkStyle结果分析

<property name="charset" value="UTF-8"/>

????????????????????? <module name="TreeWalker">

??????????? 如果是UTF-8的话,就添加加粗的那条语句,就可以了。

37、 Got an exception - java.lang.RuntimeException: Unable to get class information for @throws tag *whatever*.
??? 网上参考解决方法:选中CheckSytle的JavaDoc --> Method JavaDoc --> logLoadErrors。如果是CheckStyle自己加载时出错的,打个Log就可以了,不要整出Errors吓人。
?? 还有一处也可能包出同样的错误。Coding Problems --> Redundant Throws --> logLoadErrors选中即可


38、Expected @param tag for 'dataManager'.??? 缺少dataManager参数的注释?? 解决方法:在注释中添加@param? dataManager? DataManager

网上一些其他错误的解答:
1. Parameter X should be final.
public class Foo
{
??? private int bar;

??? public Foo(int bar)
??? {
??????? this.bar = bar;
??? }

??? public final int getBar()
??? {
??????? return bar;
??? }
}

解释:public Foo(int bar)的局部变量,被认为是不可改变的,检查需要加上final关键字定义public Foo(final int bar)此错误,可以忽略不检查。

2. Redundant 'X' modifier.

public interface CacheHRTreeService extends Manager {

?/**
? * Organization Tree
? * @param orgDto
? * @return
? * @throws Exception
? */
?public void setOrganization(OrganizationDTO orgDto) throws Exception;

?/**
? * Organization Tree
? * @return
? * @throws Exception
? */
?public OrganizationDTO getOrganization() throws Exception;
......
}

解释:多余的字段。public OrganizationDTO getOrganization() throws Exception;此时public为多余的字段,因为interface定义的时候,就是public的。

需要检查。

3. - Class X should be declared as final.

解释:对于单例设计模式,要求返回唯一的类对象。但是HRFactory和ContextFactory为优化的两个类,不需求检查。
其他的单例类,依然需要进行检查。

4. - Method 'addChildrenId' is not designed for extension - needs to be
? abstract, final or empty.

解释:通过父类继承的,此类有点特殊可以忽略此类。

5. Variable 'id' must be private and have accessor methods.解释:BaseHRDTO类,为父类,属性给子类继承,比较特殊。但是其他的类,声名需要加上范围'private'关键字。需要检查。

6. -Array brackets at illegal position.解释:代码写法,习惯不一样。需要检查,仅仅提示

热点排行