Skip to content
This repository was archived by the owner on Dec 23, 2017. It is now read-only.

Commit 66b372f

Browse files
author
Jochen Schalanda
committed
Add "pedantic" build profile for static code analysis
1 parent 1c2407a commit 66b372f

File tree

2 files changed

+468
-9
lines changed

2 files changed

+468
-9
lines changed

config/checkstyle.xml

Lines changed: 293 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,293 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
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+
<!-- This is a checkstyle configuration file. For descriptions of
7+
what the following rules do, please see the checkstyle configuration
8+
page at http://checkstyle.sourceforge.net/config.html -->
9+
10+
<module name="Checker">
11+
<module name="FileTabCharacter"/>
12+
<module name="NewlineAtEndOfFile"/>
13+
14+
<!-- All Java AST specific tests live under TreeWalker module. -->
15+
<module name="TreeWalker">
16+
17+
<!--
18+
IMPORT CHECKS
19+
-->
20+
21+
<module name="RedundantImport">
22+
<!-- Checks for redundant import statements. -->
23+
<property name="severity" value="error"/>
24+
</module>
25+
26+
<module name="ImportOrder">
27+
<!-- Checks for out of order import statements. -->
28+
29+
<property name="severity" value="warning"/>
30+
<property name="groups" value="com.google,android,junit,net,org,java,javax"/>
31+
<!-- This ensures that static imports go first. -->
32+
<property name="option" value="top"/>
33+
<property name="tokens" value="STATIC_IMPORT, IMPORT"/>
34+
</module>
35+
36+
<!--
37+
38+
JAVADOC CHECKS
39+
40+
-->
41+
42+
<!-- Checks for Javadoc comments. -->
43+
<!-- See http://checkstyle.sf.net/config_javadoc.html -->
44+
<module name="JavadocMethod">
45+
<property name="scope" value="protected"/>
46+
<property name="severity" value="warning"/>
47+
<property name="allowMissingJavadoc" value="true"/>
48+
<property name="allowMissingParamTags" value="true"/>
49+
<property name="allowMissingReturnTag" value="true"/>
50+
<property name="allowMissingThrowsTags" value="true"/>
51+
<property name="allowThrowsTagsForSubclasses" value="true"/>
52+
<property name="allowUndeclaredRTE" value="true"/>
53+
</module>
54+
55+
<module name="JavadocType">
56+
<property name="scope" value="protected"/>
57+
<property name="severity" value="error"/>
58+
</module>
59+
60+
<module name="JavadocStyle">
61+
<property name="severity" value="warning"/>
62+
</module>
63+
64+
<!--
65+
66+
NAMING CHECKS
67+
68+
-->
69+
70+
<!-- Item 38 - Adhere to generally accepted naming conventions -->
71+
72+
<module name="PackageName">
73+
<!-- Validates identifiers for package names against the
74+
supplied expression. -->
75+
<!-- Here the default checkstyle rule restricts package name parts to
76+
seven characters, this is not in line with common practice at Google.
77+
-->
78+
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9]{1,})*$"/>
79+
<property name="severity" value="warning"/>
80+
</module>
81+
82+
<module name="TypeNameCheck">
83+
<!-- Validates static, final fields against the
84+
expression "^[A-Z][a-zA-Z0-9]*$". -->
85+
<metadata name="altname" value="TypeName"/>
86+
<property name="severity" value="warning"/>
87+
</module>
88+
89+
<module name="ConstantNameCheck">
90+
<!-- Validates non-private, static, final fields against the supplied
91+
public/package final fields "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$". -->
92+
<metadata name="altname" value="ConstantName"/>
93+
<property name="applyToPublic" value="true"/>
94+
<property name="applyToProtected" value="true"/>
95+
<property name="applyToPackage" value="true"/>
96+
<property name="applyToPrivate" value="false"/>
97+
<property name="format" value="^([A-Z][A-Z0-9]*(_[A-Z0-9]+)*|FLAG_.*)$"/>
98+
<message key="name.invalidPattern"
99+
value="Variable ''{0}'' should be in ALL_CAPS (if it is a constant) or be private (otherwise)."/>
100+
<property name="severity" value="warning"/>
101+
</module>
102+
103+
<module name="StaticVariableNameCheck">
104+
<!-- Validates static, non-final fields against the supplied
105+
expression "^[a-z][a-zA-Z0-9]*_?$". -->
106+
<metadata name="altname" value="StaticVariableName"/>
107+
<property name="applyToPublic" value="true"/>
108+
<property name="applyToProtected" value="true"/>
109+
<property name="applyToPackage" value="true"/>
110+
<property name="applyToPrivate" value="true"/>
111+
<property name="format" value="^[a-z][a-zA-Z0-9]*_?$"/>
112+
<property name="severity" value="warning"/>
113+
</module>
114+
115+
<module name="MemberNameCheck">
116+
<!-- Validates non-static members against the supplied expression. -->
117+
<metadata name="altname" value="MemberName"/>
118+
<property name="applyToPublic" value="true"/>
119+
<property name="applyToProtected" value="true"/>
120+
<property name="applyToPackage" value="true"/>
121+
<property name="applyToPrivate" value="true"/>
122+
<property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
123+
<property name="severity" value="warning"/>
124+
</module>
125+
126+
<module name="MethodNameCheck">
127+
<!-- Validates identifiers for method names. -->
128+
<metadata name="altname" value="MethodName"/>
129+
<property name="format" value="^[a-z][a-zA-Z0-9]*(_[a-zA-Z0-9]+)*$"/>
130+
<property name="severity" value="warning"/>
131+
</module>
132+
133+
<module name="ParameterName">
134+
<!-- Validates identifiers for method parameters against the
135+
expression "^[a-z][a-zA-Z0-9]*$". -->
136+
<property name="severity" value="warning"/>
137+
</module>
138+
139+
<module name="LocalFinalVariableName">
140+
<!-- Validates identifiers for local final variables against the
141+
expression "^[a-z][a-zA-Z0-9]*$". -->
142+
<property name="severity" value="warning"/>
143+
</module>
144+
145+
<module name="LocalVariableName">
146+
<!-- Validates identifiers for local variables against the
147+
expression "^[a-z][a-zA-Z0-9]*$". -->
148+
<property name="severity" value="warning"/>
149+
</module>
150+
151+
152+
<!--
153+
154+
LENGTH and CODING CHECKS
155+
156+
-->
157+
158+
<module name="LineLength">
159+
<!-- Checks if a line is too long. -->
160+
<property name="max" value="${com.puppycrawl.tools.checkstyle.checks.sizes.LineLength.max}" default="160"/>
161+
<property name="severity" value="error"/>
162+
163+
<!--
164+
The default ignore pattern exempts the following elements:
165+
- import statements
166+
- long URLs inside comments
167+
-->
168+
169+
<property name="ignorePattern"
170+
value="${com.puppycrawl.tools.checkstyle.checks.sizes.LineLength.ignorePattern}"
171+
default="^(package .*;\s*)|(import .*;\s*)|( *\* *https?://.*)$"/>
172+
</module>
173+
174+
<module name="LeftCurly">
175+
<!-- Checks for placement of the left curly brace ('{'). -->
176+
<property name="severity" value="warning"/>
177+
</module>
178+
179+
<module name="RightCurly">
180+
<!-- Checks right curlies on CATCH, ELSE, and TRY blocks are on
181+
the same line. e.g., the following example is fine:
182+
<pre>
183+
if {
184+
...
185+
} else
186+
</pre>
187+
-->
188+
<!-- This next example is not fine:
189+
<pre>
190+
if {
191+
...
192+
}
193+
else
194+
</pre>
195+
-->
196+
<property name="option" value="same"/>
197+
<property name="severity" value="warning"/>
198+
</module>
199+
200+
<!-- Checks for braces around if and else blocks -->
201+
<module name="NeedBraces">
202+
<property name="severity" value="warning"/>
203+
<property name="tokens" value="LITERAL_IF, LITERAL_ELSE, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO"/>
204+
</module>
205+
206+
<module name="UpperEll">
207+
<!-- Checks that long constants are defined with an upper ell.-->
208+
<property name="severity" value="error"/>
209+
</module>
210+
211+
<module name="FallThrough">
212+
<!-- Warn about falling through to the next case statement. Similar to
213+
javac -Xlint:fallthrough, but the check is suppressed if a single-line comment
214+
on the last non-blank line preceding the fallen-into case contains 'fall through' (or
215+
some other variants which we don't publicized to promote consistency).
216+
-->
217+
<property name="reliefPattern"
218+
value="fall through|Fall through|fallthru|Fallthru|falls through|Falls through|fallthrough|Fallthrough|No break|NO break|no break|continue on"/>
219+
<property name="severity" value="error"/>
220+
</module>
221+
222+
223+
<!--
224+
225+
MODIFIERS CHECKS
226+
227+
-->
228+
229+
<module name="ModifierOrder">
230+
<!-- Warn if modifier order is inconsistent with JLS3 8.1.1, 8.3.1, and
231+
8.4.3. The prescribed order is:
232+
public, protected, private, abstract, static, final, transient, volatile,
233+
synchronized, native, strictfp
234+
-->
235+
</module>
236+
237+
238+
<!--
239+
240+
WHITESPACE CHECKS
241+
242+
-->
243+
244+
<module name="WhitespaceAround">
245+
<!-- Checks that various tokens are surrounded by whitespace.
246+
This includes most binary operators and keywords followed
247+
by regular or curly braces.
248+
-->
249+
<property name="tokens" value="ASSIGN, BAND, BAND_ASSIGN, BOR,
250+
BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN,
251+
EQUAL, GE, GT, LAND, LE, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE,
252+
LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN,
253+
LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS,
254+
MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION,
255+
SL, SL_ASSIGN, SR_ASSIGN, STAR, STAR_ASSIGN"/>
256+
<property name="severity" value="error"/>
257+
</module>
258+
259+
<module name="WhitespaceAfter">
260+
<!-- Checks that commas, semicolons and typecasts are followed by
261+
whitespace.
262+
-->
263+
<property name="tokens" value="COMMA, SEMI, TYPECAST"/>
264+
</module>
265+
266+
<module name="NoWhitespaceAfter">
267+
<!-- Checks that there is no whitespace after various unary operators.
268+
Linebreaks are allowed.
269+
-->
270+
<property name="tokens" value="BNOT, DEC, DOT, INC, LNOT, UNARY_MINUS,
271+
UNARY_PLUS"/>
272+
<property name="allowLineBreaks" value="true"/>
273+
<property name="severity" value="error"/>
274+
</module>
275+
276+
<module name="NoWhitespaceBefore">
277+
<!-- Checks that there is no whitespace before various unary operators.
278+
Linebreaks are allowed.
279+
-->
280+
<property name="tokens" value="SEMI, DOT, POST_DEC, POST_INC"/>
281+
<property name="allowLineBreaks" value="true"/>
282+
<property name="severity" value="error"/>
283+
</module>
284+
285+
<module name="ParenPad">
286+
<!-- Checks that there is no whitespace before close parens or after
287+
open parens.
288+
-->
289+
<property name="severity" value="warning"/>
290+
</module>
291+
292+
</module>
293+
</module>

0 commit comments

Comments
 (0)