Skip to content

Commit 2d43f28

Browse files
committed
fix build and add checkstyle
1 parent f822a0e commit 2d43f28

10 files changed

+580
-100
lines changed

checkstyle.xml

+387
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,387 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Copyright © 2014-2015 Cask Data, Inc.
4+
Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
use this file except in compliance with the License. You may obtain a copy of
6+
the License at
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
Unless required by applicable law or agreed to in writing, software
9+
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10+
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11+
License for the specific language governing permissions and limitations under
12+
the License.
13+
-->
14+
15+
<!DOCTYPE module PUBLIC
16+
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
17+
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
18+
19+
<!-- This is a checkstyle configuration file. For descriptions of
20+
what the following rules do, please see the checkstyle configuration
21+
page at http://checkstyle.sourceforge.net/config.html -->
22+
23+
<module name="Checker">
24+
25+
<module name="FileTabCharacter">
26+
<property name="severity" value="error"/>
27+
<!-- Checks that there are no tab characters in the file.
28+
-->
29+
</module>
30+
31+
<!--
32+
LENGTH CHECKS FOR FILES
33+
-->
34+
35+
<module name="FileLength">
36+
<property name="max" value="3000"/>
37+
<property name="severity" value="warning"/>
38+
</module>
39+
40+
41+
<module name="NewlineAtEndOfFile">
42+
<property name="lineSeparator" value="lf"/>
43+
</module>
44+
45+
<module name="RegexpSingleline">
46+
<!-- Checks that FIXME is not used in comments. TODO is preferred.
47+
-->
48+
<property name="format" value="((//.*)|(\*.*))FIXME" />
49+
<property name="message" value='TODO is preferred to FIXME. e.g. "TODO: (ENG-123) - Refactor when v2 is released."' />
50+
</module>
51+
52+
<module name="RegexpSingleline">
53+
<!-- Checks that TODOs are named with some basic formatting. Checks for the following pattern TODO: (
54+
-->
55+
<property name="format" value="((//.*)|(\*.*))TODO[^: (]" />
56+
<property name="message" value='All TODOs should be named. e.g. "TODO: (ENG-123) - Refactor when v2 is released."' />
57+
</module>
58+
59+
<module name="JavadocPackage">
60+
<!-- Checks that each Java package has a Javadoc file used for commenting.
61+
Only allows a package-info.java, not package.html. -->
62+
<property name="severity" value="error"/>
63+
</module>
64+
65+
<!-- All Java AST specific tests live under TreeWalker module. -->
66+
<module name="TreeWalker">
67+
68+
<!-- required for SupressionCommentFilter and SuppressWithNearbyCommentFilter -->
69+
<module name="FileContentsHolder"/>
70+
71+
<!--
72+
IMPORT CHECKS
73+
-->
74+
75+
<module name="AvoidStarImport">
76+
<property name="allowClassImports" value="false"/>
77+
<property name="severity" value="error"/>
78+
</module>
79+
80+
<module name="RedundantImport">
81+
<!-- Checks for redundant import statements. -->
82+
<property name="severity" value="error"/>
83+
</module>
84+
85+
<module name="ImportOrder">
86+
<!-- Checks for out of order import statements. -->
87+
<property name="severity" value="error"/>
88+
<property name="ordered" value="true"/>
89+
<property name="groups" value="/([^j]|.[^a]|..[^v]|...[^a])/,/^javax?\./"/>
90+
<!-- This ensures that static imports go to the end. -->
91+
<property name="option" value="bottom"/>
92+
<property name="tokens" value="STATIC_IMPORT, IMPORT"/>
93+
</module>
94+
95+
<module name="IllegalImport">
96+
<property name="illegalPkgs" value="junit.framework"/>
97+
</module>
98+
99+
<!--
100+
METHOD LENGTH CHECKS
101+
-->
102+
103+
<module name="MethodLength">
104+
<property name="tokens" value="METHOD_DEF"/>
105+
<property name="max" value="300"/>
106+
<property name="countEmpty" value="false"/>
107+
<property name="severity" value="warning"/>
108+
</module>
109+
110+
<!--
111+
JAVADOC CHECKS
112+
-->
113+
114+
<!-- Checks for Javadoc comments. -->
115+
<!-- See http://checkstyle.sf.net/config_javadoc.html -->
116+
<module name="JavadocMethod">
117+
<property name="scope" value="protected"/>
118+
<property name="severity" value="error"/>
119+
<property name="allowMissingJavadoc" value="true"/>
120+
<property name="allowMissingParamTags" value="true"/>
121+
<property name="allowMissingReturnTag" value="true"/>
122+
<property name="allowMissingThrowsTags" value="true"/>
123+
<property name="allowThrowsTagsForSubclasses" value="true"/>
124+
<property name="allowUndeclaredRTE" value="true"/>
125+
</module>
126+
127+
<module name="JavadocType">
128+
<property name="scope" value="protected"/>
129+
<property name="severity" value="error"/>
130+
</module>
131+
132+
<module name="JavadocStyle">
133+
<property name="severity" value="error"/>
134+
</module>
135+
136+
<!--
137+
NAMING CHECKS
138+
-->
139+
140+
<!-- Item 38 - Adhere to generally accepted naming conventions -->
141+
142+
<module name="PackageName">
143+
<!-- Validates identifiers for package names against the
144+
supplied expression. -->
145+
<!-- Here the default checkstyle rule restricts package name parts to
146+
seven characters, this is not in line with common practice at Google.
147+
-->
148+
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9]{1,})*$"/>
149+
<property name="severity" value="error"/>
150+
</module>
151+
152+
<module name="TypeNameCheck">
153+
<!-- Validates static, final fields against the
154+
expression "^[A-Z][a-zA-Z0-9]*$". -->
155+
<metadata name="altname" value="TypeName"/>
156+
<property name="severity" value="error"/>
157+
</module>
158+
159+
<module name="ConstantNameCheck">
160+
<!-- Validates non-private, static, final fields against the supplied
161+
public/package final fields "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$". -->
162+
<metadata name="altname" value="ConstantName"/>
163+
<property name="applyToPublic" value="true"/>
164+
<property name="applyToProtected" value="true"/>
165+
<property name="applyToPackage" value="true"/>
166+
<property name="applyToPrivate" value="false"/>
167+
<property name="format" value="^([A-Z][A-Z0-9]*(_[A-Z0-9]+)*|FLAG_.*)$"/>
168+
<message key="name.invalidPattern"
169+
value="Variable ''{0}'' should be in ALL_CAPS (if it is a constant) or be private (otherwise)."/>
170+
<property name="severity" value="error"/>
171+
</module>
172+
173+
<module name="StaticVariableNameCheck">
174+
<!-- Validates static, non-final fields against the supplied
175+
expression "^[a-z][a-zA-Z0-9]*_?$". -->
176+
<metadata name="altname" value="StaticVariableName"/>
177+
<property name="applyToPublic" value="true"/>
178+
<property name="applyToProtected" value="true"/>
179+
<property name="applyToPackage" value="true"/>
180+
<property name="applyToPrivate" value="true"/>
181+
<property name="format" value="^[a-z][a-zA-Z0-9]*_?$"/>
182+
<property name="severity" value="error"/>
183+
</module>
184+
185+
<module name="MemberNameCheck">
186+
<!-- Validates non-static members against the supplied expression. -->
187+
<metadata name="altname" value="MemberName"/>
188+
<property name="applyToPublic" value="true"/>
189+
<property name="applyToProtected" value="true"/>
190+
<property name="applyToPackage" value="true"/>
191+
<property name="applyToPrivate" value="true"/>
192+
<property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
193+
<property name="severity" value="error"/>
194+
</module>
195+
196+
<module name="MethodNameCheck">
197+
<!-- Validates identifiers for method names. -->
198+
<metadata name="altname" value="MethodName"/>
199+
<property name="format" value="^[a-z][a-zA-Z0-9]*(_[a-zA-Z0-9]+)*$"/>
200+
<property name="severity" value="error"/>
201+
</module>
202+
203+
<module name="ParameterName">
204+
<!-- Validates identifiers for method parameters against the
205+
expression "^[a-z][a-zA-Z0-9]*$". -->
206+
<property name="severity" value="error"/>
207+
</module>
208+
209+
<module name="LocalFinalVariableName">
210+
<!-- Validates identifiers for local final variables against the
211+
expression "^[a-z][a-zA-Z0-9]*$". -->
212+
<property name="severity" value="error"/>
213+
</module>
214+
215+
<module name="LocalVariableName">
216+
<!-- Validates identifiers for local variables against the
217+
expression "^[a-z][a-zA-Z0-9]*$". -->
218+
<property name="severity" value="error"/>
219+
</module>
220+
221+
222+
<!--
223+
LENGTH and CODING CHECKS
224+
-->
225+
226+
<module name="LineLength">
227+
<!-- Checks if a line is too long. -->
228+
<property name="max" value="120" default="120"/>
229+
<property name="severity" value="error"/>
230+
231+
<!--
232+
The default ignore pattern exempts the following elements:
233+
- import statements
234+
- long URLs inside comments
235+
-->
236+
237+
<property name="ignorePattern"
238+
value="${com.puppycrawl.tools.checkstyle.checks.sizes.LineLength.ignorePattern}"
239+
default="^(package .*;\s*)|(import .*;\s*)|( *\* *https?://.*)$"/>
240+
</module>
241+
242+
<module name="LeftCurly">
243+
<!-- Checks for placement of the left curly brace ('{'). -->
244+
<property name="severity" value="error"/>
245+
</module>
246+
247+
<module name="RightCurly">
248+
<!-- Checks right curlies on CATCH, ELSE, and TRY blocks are on
249+
the same line. e.g., the following example is fine:
250+
<pre>
251+
if {
252+
...
253+
} else
254+
</pre>
255+
-->
256+
<!-- This next example is not fine:
257+
<pre>
258+
if {
259+
...
260+
}
261+
else
262+
</pre>
263+
-->
264+
<property name="option" value="same"/>
265+
<property name="severity" value="error"/>
266+
</module>
267+
268+
<!-- Checks for braces around if and else blocks -->
269+
<module name="NeedBraces">
270+
<property name="severity" value="error"/>
271+
<property name="tokens" value="LITERAL_IF, LITERAL_ELSE, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO"/>
272+
</module>
273+
274+
<module name="UpperEll">
275+
<!-- Checks that long constants are defined with an upper ell.-->
276+
<property name="severity" value="error"/>
277+
</module>
278+
279+
<module name="FallThrough">
280+
<!-- Warn about falling through to the next case statement. Similar to
281+
javac -Xlint:fallthrough, but the check is suppressed if a single-line comment
282+
on the last non-blank line preceding the fallen-into case contains 'fall through' (or
283+
some other variants which we don't publicized to promote consistency).
284+
-->
285+
<property name="reliefPattern"
286+
value="fall through|Fall through|fallthru|Fallthru|falls through|Falls through|fallthrough|Fallthrough|No break|NO break|no break|continue on"/>
287+
<property name="severity" value="error"/>
288+
</module>
289+
290+
291+
<!--
292+
MODIFIERS CHECKS
293+
-->
294+
295+
<module name="ModifierOrder">
296+
<!-- Warn if modifier order is inconsistent with JLS3 8.1.1, 8.3.1, and
297+
8.4.3. The prescribed order is:
298+
public, protected, private, abstract, static, final, transient, volatile,
299+
synchronized, native, strictfp
300+
-->
301+
</module>
302+
303+
<module name="RedundantModifier">
304+
<!-- Checks for redundant modifiers in:
305+
- interface and annotation definitions,
306+
- the final modifier on methods of final classes, and
307+
- inner interface declarations that are declared as static.
308+
-->
309+
</module>
310+
311+
312+
<!--
313+
WHITESPACE CHECKS
314+
-->
315+
<module name="GenericWhitespace"/>
316+
317+
<module name="WhitespaceAround">
318+
<!-- Checks that various tokens are surrounded by whitespace.
319+
This includes most binary operators and keywords followed
320+
by regular or curly braces.
321+
-->
322+
<property name="tokens" value="ASSIGN, BAND, BAND_ASSIGN, BOR,
323+
BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN,
324+
EQUAL, GE, GT, LAND, LCURLY, LE, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE,
325+
LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN,
326+
LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS,
327+
MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION,
328+
SL, SLIST, SL_ASSIGN, SR_ASSIGN, STAR, STAR_ASSIGN"/>
329+
<property name="allowEmptyConstructors" value="true"/>
330+
<property name="allowEmptyMethods" value="true"/>
331+
<property name="severity" value="error"/>
332+
</module>
333+
334+
<module name="WhitespaceAfter">
335+
<!-- Checks that commas, semicolons and typecasts are followed by
336+
whitespace.
337+
-->
338+
<property name="tokens" value="COMMA, SEMI, TYPECAST"/>
339+
<property name="severity" value="error"/>
340+
</module>
341+
342+
<module name="NoWhitespaceAfter">
343+
<!-- Checks that there is no whitespace after various unary operators.
344+
Linebreaks are allowed.
345+
-->
346+
<property name="tokens" value="BNOT, DEC, DOT, INC, LNOT, UNARY_MINUS,
347+
UNARY_PLUS"/>
348+
<property name="allowLineBreaks" value="true"/>
349+
<property name="severity" value="error"/>
350+
</module>
351+
352+
<module name="NoWhitespaceBefore">
353+
<!-- Checks that there is no whitespace before various unary operators.
354+
Linebreaks are allowed.
355+
-->
356+
<property name="tokens" value="SEMI, DOT, POST_DEC, POST_INC"/>
357+
<property name="allowLineBreaks" value="true"/>
358+
<property name="severity" value="error"/>
359+
</module>
360+
361+
<module name="ParenPad">
362+
<!-- Checks that there is no whitespace before close parens or after
363+
open parens.
364+
-->
365+
<property name="severity" value="error"/>
366+
</module>
367+
368+
</module>
369+
370+
<!--
371+
Optional suppression filter. It is optional because when running with Maven, it should be the
372+
checkstyle plugin who provides it. It is only used when this file is used in IntelliJ.
373+
-->
374+
375+
<module name="SuppressionFilter">
376+
<property name="file" value="suppressions.xml"/>
377+
<property name="optional" value="true"/>
378+
</module>
379+
380+
<module name="SuppressionCommentFilter">
381+
<property name="offCommentFormat" value="CHECKSTYLE OFF: (.+)" />
382+
<property name="onCommentFormat" value="CHECKSTYLE ON" />
383+
<property name="checkFormat" value="Javadoc.*"/>
384+
<property name="messageFormat" value="$1"/>
385+
</module>
386+
387+
</module>

0 commit comments

Comments
 (0)