Skip to content

Commit f93ddf8

Browse files
committed
Add codestyle checks to fail for inconsistent codestyles
1 parent d88519a commit f93ddf8

File tree

8 files changed

+1151
-8
lines changed

8 files changed

+1151
-8
lines changed

dev/checkstyle/checkstyle.xml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
* Licensed to the Apache Software Foundation (ASF) under one
4+
* or more contributor license agreements. See the NOTICE file
5+
* distributed with this work for additional information
6+
* regarding copyright ownership. The ASF licenses this file
7+
* to you under the Apache License, Version 2.0 (the
8+
* "License"); you may not use this file except in compliance
9+
* with the License. You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing,
14+
* software distributed under the License is distributed on an
15+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
* KIND, either express or implied. See the License for the
17+
* specific language governing permissions and limitations
18+
* under the License.
19+
-->
20+
21+
<!DOCTYPE module PUBLIC
22+
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
23+
"https://checkstyle.org/dtds/configuration_1_3.dtd">
24+
25+
<module name="Checker">
26+
<module name="SuppressionFilter">
27+
<property name="file" value="dev/checkstyle/suppressions.xml"/>
28+
</module>
29+
30+
<module name="TreeWalker">
31+
<!-- XPath-based suppressions (target specific AST patterns) -->
32+
<module name="SuppressionXpathFilter">
33+
<property name="file" value="dev/checkstyle/suppressions-xpath.xml"/>
34+
</module>
35+
36+
<module name="UnusedImports"/>
37+
<module name="RedundantImport"/>
38+
<module name="AvoidStarImport"/>
39+
<module name="IllegalImport"/>
40+
<module name="PackageName"/>
41+
<module name="TypeName"/>
42+
<!-- 1) Private fields must be _lowerCamelCase -->
43+
<!--<module name="MemberName">
44+
<property name="applyToPublic" value="false"/>
45+
<property name="applyToProtected" value="false"/>
46+
<property name="applyToPackage" value="false"/>
47+
<property name="applyToPrivate" value="true"/>
48+
49+
<property name="format" value="^_[a-z][a-zA-Z0-9]*$"/>
50+
</module>-->
51+
<!-- 2) Non-private fields must be lowerCamelCase (no leading underscore) -->
52+
<!--<module name="MemberName">
53+
<property name="applyToPublic" value="true"/>
54+
<property name="applyToProtected" value="false"/>
55+
<property name="applyToPackage" value="true"/>
56+
<property name="applyToPrivate" value="false"/>
57+
<property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
58+
</module>-->
59+
<module name="MethodName"/>
60+
<!--<module name="ParameterName"/>-->
61+
<module name="LocalVariableName">
62+
<property name="format"
63+
value="^[a-zA-Z][a-zA-Z0-9_]*$"/>
64+
</module>
65+
</module>
66+
67+
<!-- to detect leading spaces (should be tabs) -->
68+
<module name="RegexpMultiline">
69+
<property name="format"
70+
value="(?m)^( +)(?!\*)(?!//)(?!/\*)\S"/>
71+
<property name="message"
72+
value="Indentation must use tabs (no leading spaces)."/>
73+
</module>
74+
</module>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
* Licensed to the Apache Software Foundation (ASF) under one
4+
* or more contributor license agreements. See the NOTICE file
5+
* distributed with this work for additional information
6+
* regarding copyright ownership. The ASF licenses this file
7+
* to you under the Apache License, Version 2.0 (the
8+
* "License"); you may not use this file except in compliance
9+
* with the License. You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing,
14+
* software distributed under the License is distributed on an
15+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
* KIND, either express or implied. See the License for the
17+
* specific language governing permissions and limitations
18+
* under the License.
19+
-->
20+
21+
<!DOCTYPE suppressions PUBLIC
22+
"-//Checkstyle//DTD SuppressionXpathFilter Experimental Configuration 1.2//EN"
23+
"https://checkstyle.org/dtds/suppressions_1_2_xpath_experimental.dtd">
24+
25+
<suppressions>
26+
<!-- Suppress MemberName for private final fields -->
27+
<suppress-xpath
28+
checks="MemberNameCheck"
29+
query="//VARIABLE_DEF[
30+
./MODIFIERS/LITERAL_PRIVATE
31+
and ./MODIFIERS/FINAL
32+
]/IDENT"/>
33+
34+
<!-- Suppress MemberName for private static fields -->
35+
<suppress-xpath
36+
checks="MemberNameCheck"
37+
query="//VARIABLE_DEF[
38+
./MODIFIERS/LITERAL_PRIVATE
39+
and ./MODIFIERS/LITERAL_STATIC
40+
]/IDENT"/>
41+
</suppressions>

0 commit comments

Comments
 (0)