Skip to content

Commit 6d0617c

Browse files
author
Cameron Mace
authored
Merge pull request #187 from mapbox/111-checkstyle
Introduce new checkstyle
2 parents 3a64580 + 0351f6c commit 6d0617c

8 files changed

Lines changed: 57 additions & 66 deletions

File tree

checkstyle.xml

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,30 @@
33
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
44
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
55

6-
<!--
7-
Checkstyle configuration that checks the Google coding conventions from Google Java Style
8-
that can be found at https://google.github.io/styleguide/javaguide.html.
9-
10-
Checkstyle is very configurable. Be sure to read the documentation at
11-
http://checkstyle.sf.net (or in your downloaded distribution).
12-
13-
To completely disable a check, just comment it out or delete it from the file.
14-
15-
Authors: Max Vetrenko, Ruslan Diachenko, Roman Ivanov.
16-
-->
17-
186
<module name = "Checker">
197
<property name="charset" value="UTF-8"/>
208

9+
<!-- <property name="severity" value="error"/> -->
2110
<property name="severity" value="warning"/>
2211

2312
<property name="fileExtensions" value="java, properties, xml"/>
2413
<!-- Checks for whitespace -->
2514
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
26-
<module name="FileTabCharacter">
15+
<!-- <module name="FileTabCharacter">
2716
<property name="eachLine" value="true"/>
28-
</module>
17+
</module> -->
18+
19+
<!-- <module name="NewlineAtEndOfFile">
20+
<property name="lineSeparator" value="lf" />
21+
</module> -->
22+
<module name="FileLength"/>
23+
<module name="FileTabCharacter"/>
24+
25+
<!-- Trailing spaces -->
26+
<module name="RegexpSingleline">
27+
<property name="format" value="\s+$"/>
28+
<property name="message" value="Line has trailing spaces."/>
29+
</module>
2930

3031
<module name="TreeWalker">
3132
<module name="OuterTypeFilename"/>
@@ -43,7 +44,6 @@
4344
<property name="max" value="120"/>
4445
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
4546
</module>
46-
<module name="AvoidStarImport"/>
4747
<module name="OneTopLevelClass"/>
4848
<module name="NoLineWrap"/>
4949
<module name="EmptyBlock">
@@ -145,24 +145,31 @@
145145
value="GenericWhitespace ''{0}'' is not preceded with whitespace."/>
146146
</module>
147147
<module name="Indentation">
148-
<property name="basicOffset" value="4"/>
148+
<property name="basicOffset" value="2"/>
149149
<property name="braceAdjustment" value="0"/>
150-
<property name="caseIndent" value="4"/>
151-
<property name="throwsIndent" value="4"/>
152-
<property name="lineWrappingIndentation" value="4"/>
153-
<property name="arrayInitIndent" value="4"/>
150+
<property name="caseIndent" value="2"/>
151+
<property name="throwsIndent" value="2"/>
152+
<property name="lineWrappingIndentation" value="2"/>
153+
<property name="arrayInitIndent" value="2"/>
154+
<!-- <property name="forceStrictCondition" value="true"/> -->
154155
</module>
155156
<module name="AbbreviationAsWordInName">
156157
<property name="ignoreFinal" value="false"/>
157158
<property name="allowedAbbreviationLength" value="1"/>
158159
</module>
159160
<module name="OverloadMethodsDeclarationOrder"/>
160161
<module name="VariableDeclarationUsageDistance"/>
161-
<module name="CustomImportOrder">
162+
<module name="AvoidStarImport"/>
163+
<module name="IllegalImport"/> <!-- defaults to sun.* packages -->
164+
<module name="RedundantImport"/>
165+
<module name="UnusedImports">
166+
<property name="processJavadoc" value="true"/>
167+
</module>
168+
<!-- <module name="CustomImportOrder">
162169
<property name="specialImportsRegExp" value="com.google"/>
163170
<property name="sortImportsInGroupAlphabetically" value="true"/>
164171
<property name="customImportOrderRules" value="STATIC###SPECIAL_IMPORTS###THIRD_PARTY_PACKAGE###STANDARD_JAVA_PACKAGE"/>
165-
</module>
172+
</module> -->
166173
<module name="MethodParamPad"/>
167174
<module name="OperatorWrap">
168175
<property name="option" value="NL"/>
@@ -176,32 +183,32 @@
176183
<property name="allowSamelineMultipleAnnotations" value="true"/>
177184
</module>
178185
<module name="NonEmptyAtclauseDescription"/>
179-
<module name="JavadocTagContinuationIndentation"/>
180-
<module name="SummaryJavadoc">
186+
<!-- <module name="JavadocTagContinuationIndentation"/> -->
187+
<!-- <module name="SummaryJavadoc">
181188
<property name="forbiddenSummaryFragments" value="^@return the *|^This method returns |^A [{]@code [a-zA-Z0-9]+[}]( is a )"/>
182189
</module>
183-
<module name="JavadocParagraph"/>
190+
<module name="JavadocParagraph"/> -->
184191
<module name="AtclauseOrder">
185192
<property name="tagOrder" value="@param, @return, @throws, @deprecated"/>
186193
<property name="target" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/>
187194
</module>
188-
<module name="JavadocMethod">
195+
<!-- <module name="JavadocMethod">
189196
<property name="scope" value="public"/>
190197
<property name="allowMissingParamTags" value="true"/>
191198
<property name="allowMissingThrowsTags" value="true"/>
192199
<property name="allowMissingReturnTag" value="true"/>
193200
<property name="minLineCount" value="2"/>
194201
<property name="allowedAnnotations" value="Override, Test"/>
195202
<property name="allowThrowsTagsForSubclasses" value="true"/>
196-
</module>
203+
</module> -->
197204
<module name="MethodName">
198205
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9_]*$"/>
199206
<message key="name.invalidPattern"
200207
value="Method name ''{0}'' must match pattern ''{1}''."/>
201208
</module>
202-
<module name="SingleLineJavadoc">
209+
<!-- <module name="SingleLineJavadoc">
203210
<property name="ignoreInlineTags" value="false"/>
204-
</module>
211+
</module> -->
205212
<module name="EmptyCatchBlock">
206213
<property name="exceptionVariableName" value="expected"/>
207214
</module>

libandroid/lib/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ dependencies {
4646
}
4747

4848
apply from: 'gradle-javadoc.gradle'
49-
apply from: 'gradle-checkstyle.gradle'
5049
apply from: 'gradle-mvn-push.gradle'
5150

5251
// See: https://github.com/chrisbanes/gradle-mvn-push/issues/43#issuecomment-84140513

libandroid/lib/gradle-checkstyle.gradle

Lines changed: 0 additions & 16 deletions
This file was deleted.

libjava/build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
jcenter()
66
}
77
dependencies {
8-
classpath 'com.android.tools.build:gradle:2.1.2'
8+
classpath 'com.android.tools.build:gradle:2.1.3'
99

1010
// NOTE: Do not place your application dependencies here; they belong
1111
// in the individual module build.gradle files
@@ -21,3 +21,5 @@ allprojects {
2121
task clean(type: Delete) {
2222
delete rootProject.buildDir
2323
}
24+
25+
apply from: 'checkstyle.gradle'

libjava/checkstyle.gradle

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apply plugin: 'checkstyle'
2+
3+
checkstyle.toolVersion = '7.1'
4+
5+
task checkstyle(type: Checkstyle) {
6+
description 'Checks if the code adheres to coding standards'
7+
group 'verification'
8+
9+
configFile = new File(rootDir, "checkstyle.xml")
10+
source 'src'
11+
include '**/*.java'
12+
exclude '**/gen/**'
13+
14+
classpath = files()
15+
ignoreFailures = false
16+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Tue Apr 12 11:41:26 EDT 2016
1+
#Tue Aug 30 18:10:44 EDT 2016
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip

libjava/lib/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,4 @@ task JavadocGeneration(type: Javadoc) {
2121
classpath = configurations.compile
2222
}
2323

24-
apply from: 'gradle-checkstyle.gradle'
2524
apply from: 'gradle-mvn-push.gradle'

libjava/lib/gradle-checkstyle.gradle

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)