Skip to content

Commit d74d315

Browse files
committed
Added checkstyle.
- Added maven's checkstyle plugin (applies to main and test .java files). - Added a check for line length <= 120 (currently marked as ignored due to >7000 violations). - Disallow whitespace indents (force TABs). - Disallow star imports (import blabla.*). - Disallow empty blocks ({}). - Disallow trailing whitespaces/tabs.
1 parent 6c607f2 commit d74d315

2 files changed

Lines changed: 78 additions & 13 deletions

File tree

checkstyle.xml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
3+
4+
<!--
5+
Checkstyle-Configuration: CommandHelper
6+
Description: A checkstyle configuration for CommandHelper.
7+
Author: P.J.S. Kools
8+
-->
9+
<module name="Checker">
10+
<property name="severity" value="error"/>
11+
<module name="TreeWalker">
12+
13+
<!-- Line length <= 120 characters. -->
14+
<module name="LineLength">
15+
<property name="severity" value="ignore"/> <!-- TODO: Change to "error" once the >7000 violations have been resolved. -->
16+
<property name="max" value="120"/>
17+
</module>
18+
19+
<!-- Indent must use tab characters. -->
20+
<module name="RegexpSinglelineJava">
21+
<property name="format" value="^\t* ([^\*]|$)"/> <!-- Javadoc and multiline comments have a single leading whitespace, so allow " *". -->
22+
<property name="message" value="Indent must use tab characters"/>
23+
<property name="ignoreComments" value="false"/>
24+
</module>
25+
26+
<module name="AvoidStarImport"/>
27+
<module name="EmptyBlock"/>
28+
29+
</module>
30+
31+
<!-- Disallow trailing whitespaces/tabs. -->
32+
<module name="RegexpSingleline">
33+
<property name="severity" value="error"/>
34+
<property name="format" value="(?&lt;! \*)\s+$"/> <!-- Empty javadoc and multiline comment lines have a single trailing whitespace, so allow " * ". -->
35+
<property name="message" value="Line has trailing whitespaces/tabs."/>
36+
<metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="inherit"/>
37+
</module>
38+
</module>

pom.xml

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,10 @@
200200
<!-- Used for IRC hooks -->
201201
<!-- NOT READY YET
202202
<dependency>
203-
<groupId>org.jibble</groupId>
204-
<artifactId>pircbot</artifactId>
205-
<version>1.5.0</version>
206-
<scope>compile</scope>
203+
<groupId>org.jibble</groupId>
204+
<artifactId>pircbot</artifactId>
205+
<version>1.5.0</version>
206+
<scope>compile</scope>
207207
</dependency>
208208
-->
209209

@@ -280,17 +280,17 @@
280280

281281
<!-- Evil-y things (currently not used) -->
282282
<!--<dependency>
283-
<groupId>cglib</groupId>
284-
<artifactId>cglib</artifactId>
285-
<version>2.2.2</version>
286-
<scope>compile</scope>
287-
<type>jar</type>
283+
<groupId>cglib</groupId>
284+
<artifactId>cglib</artifactId>
285+
<version>2.2.2</version>
286+
<scope>compile</scope>
287+
<type>jar</type>
288288
</dependency>
289289
<dependency>
290-
<groupId>org.javassist</groupId>
291-
<artifactId>javassist</artifactId>
292-
<version>3.15.0-GA</version>
293-
<type>jar</type>
290+
<groupId>org.javassist</groupId>
291+
<artifactId>javassist</artifactId>
292+
<version>3.15.0-GA</version>
293+
<type>jar</type>
294294
</dependency>-->
295295
<!-- Embedded SSH Client -->
296296
<dependency>
@@ -914,6 +914,33 @@
914914
</execution>
915915
</executions>
916916
</plugin>
917+
918+
<!-- Checkstyle plugin -->
919+
<plugin>
920+
<groupId>org.apache.maven.plugins</groupId>
921+
<artifactId>maven-checkstyle-plugin</artifactId>
922+
<version>3.0.0</version>
923+
<executions>
924+
<execution>
925+
<id>validate</id>
926+
<phase>validate</phase>
927+
<configuration>
928+
<sourceDirectories>${project.compileSourceRoots}</sourceDirectories>
929+
<testSourceDirectories>${project.testCompileSourceRoots}</testSourceDirectories>
930+
<includeTestSourceDirectory>true</includeTestSourceDirectory>
931+
<configLocation>${basedir}/checkstyle.xml</configLocation>
932+
<encoding>UTF-8</encoding>
933+
<consoleOutput>true</consoleOutput>
934+
<failsOnError>true</failsOnError>
935+
<linkXRef>false</linkXRef>
936+
</configuration>
937+
<goals>
938+
<goal>check</goal>
939+
</goals>
940+
</execution>
941+
</executions>
942+
</plugin>
943+
917944
</plugins>
918945
</build>
919946
<profiles>

0 commit comments

Comments
 (0)