| Left: | ||
| Right: | 
| OLD | NEW | 
|---|---|
| (Empty) | |
| 1 <?xml version="1.0"?> | |
| 2 <!DOCTYPE module PUBLIC | |
| 3 "-//Puppy Crawl//DTD Check Configuration 1.3//EN" | |
| 4 "http://www.puppycrawl.com/dtds/configuration_1_3.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 If you set the basedir property below, then all reported file | |
| 36 names will be relative to the specified directory. See | |
| 37 http://checkstyle.sourceforge.net/5.x/config.html#Checker | |
| 38 | |
| 39 <property name="basedir" value="${basedir}"/> | |
| 40 --> | |
| 41 | |
| 42 <property name="fileExtensions" value="java, properties, xml"/> | |
| 43 | |
| 44 <!-- Checks whether files end with a new line. --> | |
| 45 <!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile --> | |
| 46 <module name="NewlineAtEndOfFile"/> | |
| 
 
diegocarloslima
2016/11/03 14:00:51
I think that it would be good to organize our file
 
anton
2016/11/07 07:40:44
No problem
 
 | |
| 47 | |
| 48 <!-- Checks for Size Violations. --> | |
| 49 <!-- See http://checkstyle.sf.net/config_sizes.html --> | |
| 50 <module name="FileLength"/> | |
| 51 | |
| 52 <!-- Checks for whitespace --> | |
| 53 <!-- See http://checkstyle.sf.net/config_whitespace.html --> | |
| 54 <module name="FileTabCharacter"/> | |
| 55 | |
| 56 <!-- Miscellaneous other checks. --> | |
| 57 <!-- See http://checkstyle.sf.net/config_misc.html --> | |
| 58 <module name="RegexpSingleline"> | |
| 59 <property name="format" value="\s+$"/> | |
| 60 <property name="minimum" value="0"/> | |
| 61 <property name="maximum" value="0"/> | |
| 62 <property name="message" value="Line has trailing spaces."/> | |
| 63 </module> | |
| 64 | |
| 65 <!-- Checks for Headers --> | |
| 66 <!-- See http://checkstyle.sf.net/config_header.html --> | |
| 67 <module name="Header"> | |
| 
 
anton
2016/07/19 06:45:44
added this rule (pass filename as argument) since
 
 | |
| 68 <property name="headerFile" value="${checkstyle.header.file}"/> | |
| 69 <property name="fileExtensions" value="java"/> | |
| 70 </module> | |
| 71 | |
| 72 <module name="TreeWalker"> | |
| 73 | |
| 74 <!-- Checks for Javadoc comments. --> | |
| 75 <!-- See http://checkstyle.sf.net/config_javadoc.html --> | |
| 76 <!-- <module name="JavadocMethod"/> --> | |
| 
 
anton
2016/07/19 06:45:44
i know i need to remove commented out lines, but l
 
 | |
| 77 <!-- <module name="JavadocType"/> --> | |
| 78 <!-- <module name="JavadocVariable"/> --> | |
| 79 <!-- <module name="JavadocStyle"/> --> | |
| 80 | |
| 81 <!-- Checks for Naming Conventions. --> | |
| 82 <!-- See http://checkstyle.sf.net/config_naming.html --> | |
| 83 <module name="ConstantName"/> | |
| 84 <module name="LocalFinalVariableName"/> | |
| 85 <module name="LocalVariableName"/> | |
| 86 <module name="MemberName"/> | |
| 87 <module name="MethodName"/> | |
| 88 <module name="PackageName"/> | |
| 89 <module name="ParameterName"/> | |
| 90 <module name="StaticVariableName"/> | |
| 91 <module name="TypeName"/> | |
| 92 | |
| 93 <!-- Checks for imports --> | |
| 94 <!-- See http://checkstyle.sf.net/config_import.html --> | |
| 
 
diegocarloslima
2016/11/03 14:00:51
This link is broken, it should be replaced by http
 
anton
2016/11/07 07:40:44
Acknowledged.
 
 | |
| 95 <module name="AvoidStarImport"/> | |
| 96 <module name="IllegalImport"/> <!-- defaults to sun.* packages --> | |
| 97 <module name="RedundantImport"/> | |
| 98 <module name="UnusedImports"> | |
| 99 <property name="processJavadoc" value="false"/> | |
| 100 </module> | |
| 101 <module name="ImportOrder"> | |
| 102 <!-- Android's import guidelines: http://source.android.com/source/c ode-style.html#order-import-statements --> | |
| 103 <property name="groups" value="org.mozilla,com,net,org,android,java, javax"/> | |
| 
 
anton
2016/07/19 06:45:44
according to mozilla's style org.mozilla should be
 
diegocarloslima
2016/11/03 14:00:51
We usually keep like that for files that are maint
 
René Jeschke
2016/11/24 14:28:18
As this is for having 'in-house' imports at the to
 
anton
2016/12/02 06:21:08
Acknowledged.
 
 | |
| 104 <property name="separated" value="true"/> | |
| 105 </module> | |
| 106 | |
| 107 <!-- Checks for Size Violations. --> | |
| 108 <!-- See http://checkstyle.sf.net/config_sizes.html --> | |
| 109 <module name="LineLength"> | |
| 110 <property name="max" value="100"/> | |
| 
 
anton
2016/07/21 10:12:47
according to mozilla's style one could have lines
 
 | |
| 111 </module> | |
| 112 <module name="MethodLength"/> | |
| 113 <module name="ParameterNumber"/> | |
| 114 | |
| 115 <!-- Checks for whitespace --> | |
| 116 <!-- See http://checkstyle.sf.net/config_whitespace.html --> | |
| 117 <module name="EmptyForIteratorPad"/> | |
| 118 <module name="GenericWhitespace"/> | |
| 119 <module name="MethodParamPad"/> | |
| 120 <module name="NoWhitespaceAfter"/> | |
| 121 <module name="NoWhitespaceBefore"/> | |
| 122 <!-- <module name="OperatorWrap"/> --> | |
| 123 <module name="ParenPad"/> | |
| 124 <module name="TypecastParenPad"/> | |
| 125 <module name="WhitespaceAfter"/> | |
| 
 
anton
2016/07/21 10:12:47
could be changed from default to COMMA and SEMI on
 
diegocarloslima
2016/11/03 14:00:50
I personally prefer a white space after a typecast
 
René Jeschke
2016/11/21 11:44:20
I think we have spaces after type casts ... but I'
 
 | |
| 126 <module name="WhitespaceAround"/> | |
| 127 | |
| 128 <!-- Modifier Checks --> | |
| 129 <!-- See http://checkstyle.sf.net/config_modifiers.html --> | |
| 130 <module name="ModifierOrder"/> | |
| 
 
anton
2016/07/21 10:12:46
currently we have "final static" almost in most pl
 
diegocarloslima
2016/11/03 14:00:51
I would go for the recommended one, 'static final'
 
anton
2016/11/07 07:40:44
Agree, i prefer "static final" too. Rene?
 
René Jeschke
2016/11/21 11:44:19
Yes, I also strongly prefer using the recommended
 
anton
2016/11/23 12:01:11
Acknowledged.
 
 | |
| 131 <module name="RedundantModifier"/> | |
| 132 | |
| 133 <!-- Checks for blocks. You know, those {}'s --> | |
| 134 <!-- See http://checkstyle.sf.net/config_blocks.html --> | |
| 135 <module name="AvoidNestedBlocks"/> | |
| 136 <module name="EmptyBlock"/> | |
| 137 <module name="LeftCurly"> | |
| 138 <property name="option" value="nl"/> | |
| 
 
anton
2016/07/19 06:45:45
according to eyeo's style on new line, f.e.
void
 
René Jeschke
2016/11/21 11:44:20
Well, I could list reasons why having the curlies
 
anton
2016/11/23 12:01:12
No problem.
 
 | |
| 139 </module> | |
| 140 <module name="NeedBraces"/> | |
| 141 <module name="RightCurly"> | |
| 142 <property name="option" value="alone_or_singleline"/> | |
| 143 </module> | |
| 144 | |
| 145 <!-- Checks for common coding problems --> | |
| 146 <!-- See http://checkstyle.sf.net/config_coding.html --> | |
| 147 <module name="AvoidInlineConditionals"/> | |
| 
 
anton
2016/07/19 06:45:44
is it bad to use (case?positive_branch:negative_br
 
diegocarloslima
2016/11/03 14:00:50
I also use it from time to time. I think it depend
 
anton
2016/11/07 07:40:44
Agree. I think we need one person (like Rene or Fe
 
René Jeschke
2016/11/21 11:44:19
I don't think we should disable the ternary operat
 
anton
2016/11/23 12:01:12
Acknowledged.
 
 | |
| 148 <module name="EmptyStatement"/> | |
| 149 <module name="EqualsHashCode"/> | |
| 150 <!-- <module name="HiddenField"/> --> | |
| 151 <module name="IllegalInstantiation"/> | |
| 152 <module name="InnerAssignment"/> | |
| 153 <module name="MagicNumber"/> | |
| 
 
anton
2016/07/21 10:12:46
a bit discussed it with Rene. In tests we can have
 
 | |
| 154 <module name="MissingSwitchDefault"/> | |
| 155 <module name="SimplifyBooleanExpression"/> | |
| 156 <module name="SimplifyBooleanReturn"/> | |
| 157 | |
| 158 <!-- Checks for class design --> | |
| 159 <!-- See http://checkstyle.sf.net/config_design.html --> | |
| 160 <!-- <module name="DesignForExtension"/> --> | |
| 161 <module name="FinalClass"/> | |
| 162 <module name="HideUtilityClassConstructor"/> | |
| 163 <module name="InterfaceIsType"/> | |
| 164 <!-- <module name="VisibilityModifier"/> --> | |
| 165 | |
| 166 <!-- Miscellaneous other checks. --> | |
| 167 <!-- See http://checkstyle.sf.net/config_misc.html --> | |
| 168 <module name="ArrayTypeStyle"/> | |
| 169 <module name="Indentation"> | |
| 170 <property name="basicOffset" value="2"/> | |
| 171 </module> | |
| 172 <!-- <module name="FinalParameters"/> --> | |
| 173 <module name="TodoComment"/> | |
| 
 
anton
2016/07/21 10:12:47
afaik it's not allowed to add TODO: but actually w
 
René Jeschke
2016/11/21 11:44:20
Yes, we should not use TODO/FIXME/XXX comments in
 
anton
2016/11/23 12:01:11
Acknowledged.
 
 | |
| 174 <module name="UpperEll"/> | |
| 
 
anton
2016/07/19 06:45:44
does it make sense to write L instead of l? f.e. 1
 
diegocarloslima
2016/11/03 14:00:51
I think it does, helps to maintain good readabilit
 
anton
2016/11/07 07:40:44
Usually it's highlighted by IDE so it's not a prob
 
René Jeschke
2016/11/21 11:44:20
Yes, 'L' is a lot better readable than 'l'.
 
anton
2016/11/23 12:01:11
Acknowledged.
 
 | |
| 175 | |
| 176 </module> | |
| 177 | |
| 178 </module> | |
| OLD | NEW |