Skip to content

Commit bd8c20e

Browse files
committed
OMID-170 Configure checkstyle rules for all sub modules
1 parent 90e13cc commit bd8c20e

4 files changed

Lines changed: 95 additions & 29 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.classpath
2+
.DS_Store
23
.project
34
.settings
45
.metadata

omid-checkstyle/pom.xml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
-->
15+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
16+
17+
<modelVersion>4.0.0</modelVersion>
18+
<groupId>org.apache.omid</groupId>
19+
<artifactId>omid-checkstyle</artifactId>
20+
<version>1.0.3-SNAPSHOT</version>
21+
<name>omid - checkstyle</name>
22+
23+
<build>
24+
<plugins>
25+
<plugin>
26+
<artifactId>maven-site-plugin</artifactId>
27+
<configuration>
28+
<skip>true</skip>
29+
</configuration>
30+
</plugin>
31+
<plugin>
32+
<artifactId>maven-assembly-plugin</artifactId>
33+
<configuration>
34+
<skipAssembly>true</skipAssembly>
35+
</configuration>
36+
</plugin>
37+
</plugins>
38+
</build>
39+
</project>

misc/omid_checks.xml renamed to omid-checkstyle/src/main/resources/omid/checkstyle.xml

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from Google Java Style: https://google.github.io/styleguide/javaguide.html.
99
1010
Omid's style main modifications in Modules below:
11-
- LineLength & LeftCurly.maxLineLength: 120 chars instead of 100
11+
- LineLength: 120 chars instead of 100
1212
- Indentation params: 4 spaces instead of 2
1313
- AbbreviationAsWordInName.allowedAbbreviationLength: 4 instead of 1
1414
-->
@@ -25,7 +25,10 @@
2525
<module name="FileTabCharacter">
2626
<property name="eachLine" value="true"/>
2727
</module>
28-
28+
<module name="LineLength">
29+
<property name="max" value="120"/>
30+
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
31+
</module>
2932
<module name="TreeWalker">
3033
<module name="OuterTypeFilename"/>
3134
<module name="IllegalTokenText">
@@ -38,22 +41,14 @@
3841
<property name="allowByTailComment" value="true"/>
3942
<property name="allowNonPrintableEscapes" value="true"/>
4043
</module>
41-
<module name="LineLength">
42-
<property name="max" value="120"/>
43-
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
44-
</module>
45-
<module name="AvoidStarImport"/>
4644
<module name="OneTopLevelClass"/>
4745
<module name="NoLineWrap"/>
4846
<module name="EmptyBlock">
4947
<property name="option" value="TEXT"/>
5048
<property name="tokens" value="LITERAL_TRY, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, LITERAL_SWITCH"/>
5149
</module>
5250
<module name="NeedBraces"/>
53-
<module name="LeftCurly">
54-
<property name="maxLineLength" value="120"/>
55-
</module>
56-
<module name="RightCurly"/>
51+
<module name="LeftCurly"/>
5752
<module name="RightCurly">
5853
<property name="option" value="alone"/>
5954
<property name="tokens" value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO, STATIC_INIT, INSTANCE_INIT"/>
@@ -158,11 +153,6 @@
158153
</module>
159154
<module name="OverloadMethodsDeclarationOrder"/>
160155
<module name="VariableDeclarationUsageDistance"/>
161-
<module name="CustomImportOrder">
162-
<property name="specialImportsRegExp" value="com.google"/>
163-
<property name="sortImportsInGroupAlphabetically" value="true"/>
164-
<property name="customImportOrderRules" value="STATIC###SPECIAL_IMPORTS###THIRD_PARTY_PACKAGE###STANDARD_JAVA_PACKAGE"/>
165-
</module>
166156
<module name="MethodParamPad"/>
167157
<module name="OperatorWrap">
168158
<property name="option" value="NL"/>
@@ -188,11 +178,8 @@
188178
<module name="JavadocMethod">
189179
<property name="scope" value="public"/>
190180
<property name="allowMissingParamTags" value="true"/>
191-
<property name="allowMissingThrowsTags" value="true"/>
192181
<property name="allowMissingReturnTag" value="true"/>
193-
<property name="minLineCount" value="2"/>
194182
<property name="allowedAnnotations" value="Override, Test"/>
195-
<property name="allowThrowsTagsForSubclasses" value="true"/>
196183
</module>
197184
<module name="MethodName">
198185
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9_]*$"/>
@@ -206,6 +193,21 @@
206193
<property name="exceptionVariableName" value="expected"/>
207194
</module>
208195
<module name="CommentsIndentation"/>
196+
<!-- see https://omid.incubator.apache.org/coding-guide-and-style.html for Import ordering -->
197+
<module name="AvoidStarImport"/>
198+
<module name="ImportOrder">
199+
<property name="groups" value="*,javax,java"/>
200+
<property name="ordered" value="true"/>
201+
<property name="separated" value="true"/>
202+
<property name="option" value="bottom"/>
203+
<property name="separatedStaticGroups" value="true"/>
204+
<property name="sortStaticImportsAlphabetically" value="true"/>
205+
</module>
206+
<module name="RedundantImport"/>
207+
<module name="UnusedImports">
208+
<property name="processJavadoc" value="true"/>
209+
</module>
210+
<module name="IllegalImport"/>
209211
</module>
210212

211213
</module>

pom.xml

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
</developers>
103103

104104
<modules>
105+
<module>omid-checkstyle</module>
105106
<module>benchmarks</module>
106107
<module>common</module>
107108
<module>statemachine</module>
@@ -203,7 +204,7 @@
203204
<maven-cobertura-plugin.version>2.7</maven-cobertura-plugin.version>
204205
<maven-license-plugin.version>2.11</maven-license-plugin.version>
205206
<maven-pmd-plugin.version>3.4</maven-pmd-plugin.version>
206-
<maven-checkstyle-plugin.version>2.17</maven-checkstyle-plugin.version>
207+
<maven-checkstyle-plugin.version>3.1.1</maven-checkstyle-plugin.version>
207208
<maven-jxr-plugin.version>2.3</maven-jxr-plugin.version>
208209
<maven-findbugs-maven-plugin.version>3.0.1</maven-findbugs-maven-plugin.version>
209210
<maven-owasp-plugin.version>5.3.2</maven-owasp-plugin.version>
@@ -331,6 +332,38 @@
331332
</pluginManagement>
332333

333334
<plugins>
335+
<plugin>
336+
<groupId>org.apache.maven.plugins</groupId>
337+
<artifactId>maven-checkstyle-plugin</artifactId>
338+
<version>${maven-checkstyle-plugin.version}</version>
339+
<dependencies>
340+
<dependency>
341+
<groupId>org.apache.omid</groupId>
342+
<artifactId>omid-checkstyle</artifactId>
343+
<version>${project.version}</version>
344+
</dependency>
345+
</dependencies>
346+
<configuration>
347+
<configLocation>omid/checkstyle.xml</configLocation>
348+
<encoding>UTF-8</encoding>
349+
<consoleOutput>true</consoleOutput>
350+
<!-- https://issues.apache.org/jira/browse/OMID-169 -->
351+
<!-- enable following config to make checking for violations as part of the build-->
352+
<!-- <violationSeverity>warning</violationSeverity> -->
353+
<failsOnError>true</failsOnError>
354+
<linkXRef>false</linkXRef>
355+
<includeTestSourceDirectory>true</includeTestSourceDirectory>
356+
</configuration>
357+
<executions>
358+
<execution>
359+
<id>validate</id>
360+
<phase>validate</phase>
361+
<goals>
362+
<goal>check</goal>
363+
</goals>
364+
</execution>
365+
</executions>
366+
</plugin>
334367

335368
<plugin>
336369
<groupId>org.apache.maven.plugins</groupId>
@@ -684,15 +717,6 @@
684717
<version>${maven-jxr-plugin.version}</version>
685718
</plugin>
686719

687-
<plugin>
688-
<groupId>org.apache.maven.plugins</groupId>
689-
<artifactId>maven-checkstyle-plugin</artifactId>
690-
<version>${maven-checkstyle-plugin.version}</version>
691-
<configuration>
692-
<configLocation>misc/omid_checks.xml</configLocation>
693-
</configuration>
694-
</plugin>
695-
696720
<plugin>
697721
<groupId>org.apache.maven.plugins</groupId>
698722
<artifactId>maven-pmd-plugin</artifactId>

0 commit comments

Comments
 (0)