소스 검색

Add Checkstyle

Fixes gh-3746
Rob Winch 9 년 전
부모
커밋
b52ffe038e
5개의 변경된 파일86개의 추가작업 그리고 0개의 파일을 삭제
  1. 3 0
      build.gradle
  2. 36 0
      etc/checkstyle/checkstyle.xml
  3. 16 0
      etc/checkstyle/header.txt
  4. 19 0
      etc/checkstyle/suppressions.xml
  5. 12 0
      gradle/checkstyle.gradle

+ 3 - 0
build.gradle

@@ -91,6 +91,9 @@ configure(javaProjects) {
 	ext.TOMCAT_GRADLE = "$rootDir/gradle/tomcat.gradle"
 	ext.WAR_SAMPLE_GRADLE = "$rootDir/gradle/war-sample.gradle"
 	apply from: "$rootDir/gradle/javaprojects.gradle"
+	if(!project.name.contains('gae')) {
+		apply from: "$rootDir/gradle/checkstyle.gradle"
+	}
 	apply from: "$rootDir/gradle/release-checks.gradle"
 	apply from: "$rootDir/gradle/maven-deployment.gradle"
 }

+ 36 - 0
etc/checkstyle/checkstyle.xml

@@ -0,0 +1,36 @@
+<?xml version="1.0"?>
+<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
+		"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
+<module name="Checker">
+	<!-- Suppressions -->
+	<module name="SuppressionFilter">
+		<property name="file" value="${configDir}/suppressions.xml"/>
+	</module>
+	
+	<!-- Root Checks -->
+	<module name="RegexpHeader">
+		<property name="headerFile" value="${configDir}/header.txt"/>
+		<property name="fileExtensions" value="java"/>
+	</module>
+
+	<!-- Root Checks -->
+	<module name="TreeWalker">
+		<!-- Regexp -->
+		<module name="RegexpSinglelineJava">
+			<property name="format" value="^\t* +\t*\S"/>
+			<property name="message" value="Line has leading space characters; indentation should be performed with tabs only."/>
+			<property name="ignoreComments" value="true"/>
+		</module>
+		<module name="RegexpSinglelineJava">
+			<property name="maximum" value="0"/>
+			<property name="format" value="org\.junit\.Assert\.assert"/>
+			<property name="message" value="Please use AssertJ imports."/>
+			<property name="ignoreComments" value="true"/>
+		</module>
+		<module name="Regexp">
+			<property name="format" value="[ \t]+$"/>
+			<property name="illegalPattern" value="true"/>
+			<property name="message" value="Trailing whitespace"/>
+		</module>
+	</module>
+</module>

+ 16 - 0
etc/checkstyle/header.txt

@@ -0,0 +1,16 @@
+^\Q/*\E$
+^\Q * Copyright\E (\d{4}\-\d{4} the original author or authors\.|(\d{4}, )*(\d{4}) Acegi Technology Pty Limited)$
+^\Q *\E$
+^\Q * Licensed under the Apache License, Version 2.0 (the "License");\E$
+^\Q * you may not use this file except in compliance with the License.\E$
+^\Q * You may obtain a copy of the License at\E$
+^\Q *\E$
+^\Q *      http://www.apache.org/licenses/LICENSE-2.0\E$
+^\Q *\E$
+^\Q * Unless required by applicable law or agreed to in writing, software\E$
+^\Q * distributed under the License is distributed on an "AS IS" BASIS,\E$
+^\Q * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\E$
+^\Q * See the License for the specific language governing permissions and\E$
+^\Q * limitations under the License.\E$
+^\Q */\E$
+^.*$

+ 19 - 0
etc/checkstyle/suppressions.xml

@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<!DOCTYPE suppressions PUBLIC "-//Puppy Crawl//DTD Suppressions 1.1//EN"
+		"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
+<suppressions>
+	<suppress files=".+Application\.java" checks="HideUtilityClassConstructor"/>
+	<suppress files=".+Configuration\.java" checks="HideUtilityClassConstructor"/>
+	<suppress files="[\\/]BCrypt(Tests)?\.java" checks="RegexpHeader"/>
+
+	<suppress files="[\\/]src[\\/]test[\\/]java[\\/]" checks="Javadoc"/>
+	<suppress files="[\\/]src[\\/]integration-test[\\/]java[\\/]" checks="Javadoc"/>
+
+	<suppress files="[\\/]docs[\\/]" checks="Javadoc"/>
+	<suppress files="[\\/]docs[\\/]" checks="CommentsIndentation"/>
+	<suppress files="[\\/]docs[\\/]" checks="InnerTypeLast"/>
+
+	<suppress files="[\\/]samples[\\/]" checks="Javadoc"/>
+	<suppress files="[\\/]samples[\\/]" checks="CommentsIndentation"/>
+	<suppress files="[\\/]samples[\\/]" checks="InnerTypeLast"/>
+</suppressions>

+ 12 - 0
gradle/checkstyle.gradle

@@ -0,0 +1,12 @@
+apply plugin: 'checkstyle'
+
+checkstyle {
+	configFile = rootProject.file('etc/checkstyle/checkstyle.xml')
+	configProperties.configDir = configFile.parentFile
+	toolVersion = '6.16.1'
+}
+task checkstyle {
+	dependsOn project.tasks.findAll { task -> task.name.matches('checkstyle\\w+') }
+}
+
+check.dependsOn tasks.checkstyle