Skip to content

Commit

Permalink
use default checkstyle version 6.12.1
Browse files Browse the repository at this point in the history
  • Loading branch information
anshulverma committed Nov 18, 2015
1 parent 3172d8d commit 608347a
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 14 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ estilo {
source 'google' // starting point for checkstyle checks (other option: 'sun')
ignoreWarnings true // ignore checkstyle warning and let the build continue
toolVersion '6.12.1' // set version of checkstyle to use
// this block provides a DSL that allows you to
// override, remove or extend checks of the source file
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ repositories {
}

task wrapper(type: Wrapper, description: 'Gradle Wrapper task') {
gradleVersion = '2.4'
gradleVersion = '2.9'
}

dependencies {
compile gradleApi()
compile localGroovy()
compile dependencies.create('com.puppycrawl.tools:checkstyle:6.7') {
compile dependencies.create('com.puppycrawl.tools:checkstyle:6.12.1') {
transitive = false
}
compile 'commons-io:commons-io:2.4'
Expand All @@ -56,7 +56,7 @@ ext {
'instruction': 82,
'branch' : 44,
'line' : 93,
'complexity' : 69,
'complexity' : 68,
'method' : 79,
'class' : 100
]
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sun Nov 01 21:06:16 PST 2015
#Tue Nov 17 21:36:55 PST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.9-bin.zip
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,15 @@ import net.anshulverma.gradle.estilo.checkstyle.checks.CheckType
@Slf4j
class EstiloExtension {

static final String DEFAULT_CHECKSTYLE_VERSION = '6.12.1'

CheckType baseChecks = CheckType.GOOGLE
PropertyCollection checkCollection
PropertyCollection suppressionCollection
ImportControlCollection importControlCollection
Map headerCheckOptions
boolean ignoreCheckstyleWarnings = false
String checkstyleToolVersion = DEFAULT_CHECKSTYLE_VERSION

def source(String type) {
baseChecks = CheckType.valueOf(type.toUpperCase())
Expand All @@ -58,6 +61,10 @@ class EstiloExtension {
this.ignoreCheckstyleWarnings = ignoreCheckstyleWarnings
}

def toolVersion(String checkstyleToolVersion) {
this.checkstyleToolVersion = checkstyleToolVersion
}

boolean hasSuppressions() {
suppressionCollection != null && suppressionCollection.length > 0
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,13 @@ class CheckstylePluginHelper {
task.finalizedBy finalizeTask
}

def settings = (EstiloExtension) project.getExtensions().findByName('estilo')

project.checkstyle {
showViolations = true
ignoreFailures = false
sourceSets = [sourceSets.main, sourceSets.test]
toolVersion = '6.7'
toolVersion = settings.checkstyleToolVersion
configFile = "$buildDir/checkstyle.xml" as File
reportsDir = buildDir as File
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/config/tree-walker-checks.csv
Original file line number Diff line number Diff line change
@@ -1 +1 @@
JavadocTagContinuationIndentation, MethodCount, AvoidStarImport, FinalClass, OneStatementPerLine, NoLineWrap, DescendantToken, MissingSwitchDefault, MissingCtor, ExplicitInitialization, PackageName, EmptyForInitializerPad, SuperClone, EqualsAvoidNull, HiddenField, UpperEll, TypecastParenPad, AvoidEscapedUnicodeCharacters, ExecutableStatementCount, JavadocMethod, IllegalThrows, IllegalCatch, InterfaceTypeParameterName, ClassTypeParameterName, MethodTypeParameterName, PackageAnnotation, JavadocParagraph, RedundantImport, DeclarationOrder, MissingDeprecated, JavadocVariable, ImportControl, TrailingComment, NestedForDepth, JavaNCSS, InnerAssignment, MethodParamPad, AvoidNestedBlocks, OverloadMethodsDeclarationOrder, SuppressWarnings, ArrayTypeStyle, OneTopLevelClass, WriteTag, ParenPad, OuterTypeFilename, ParameterName, EmptyLineSeparator, EmptyBlock, SeparatorWrap, LeftCurly, EmptyForIteratorPad, OperatorWrap, RightCurly, ImportOrder, NoFinalizer, RedundantModifier, LocalVariableName, NonEmptyAtclauseDescription, PackageDeclaration, UnusedImports, IllegalTokenText, NoClone, WhitespaceAfter, MultipleVariableDeclarations, InterfaceIsType, CyclomaticComplexity, VisibilityModifier, LineLength, WhitespaceAround, SummaryJavadoc, UnnecessaryParentheses, IllegalInstantiation, IllegalType, ConstantName, Indentation, UncommentedMain, AvoidInlineConditionals, BooleanExpressionComplexity, CustomImportOrder, SimplifyBooleanReturn, SingleLineJavadoc, AtclauseOrder, TypeName, NoWhitespaceBefore, MissingOverride, EmptyCatchBlock, VariableDeclarationUsageDistance, AnnotationLocation, ClassFanOutComplexity, IllegalImport, NPathComplexity, ModifiedControlVariable, SimplifyBooleanExpression, LocalFinalVariableName, MethodName, MemberName, StaticVariableName, MethodLength, SuperFinalize, AnonInnerLength, RequireThis, TodoComment, ParameterAssignment, NeedBraces, ThrowsCount, ClassDataAbstractionCoupling, DefaultComesLast, ReturnCount, NestedTryDepth, NestedIfDepth, OuterTypeNumber, DesignForExtension, FinalLocalVariable, JavadocStyle, FallThrough, IllegalToken, ParameterNumber, MutableException, RegexpSinglelineJava, Regexp, ArrayTrailingComma, CovariantEquals, FinalParameters, InnerTypeLast, EqualsHashCode, NoWhitespaceAfter, AvoidStaticImport, AbstractClassName, HideUtilityClassConstructor, AbbreviationAsWordInName, AnnotationUseStyle, GenericWhitespace, MagicNumber, StringLiteralEquality, EmptyStatement, ModifierOrder, JavadocType, MultipleStringLiterals
ClassTypeParameterName, JavadocStyle, JavadocMethod, ClassDataAbstractionCoupling, EmptyBlock, IllegalThrows, GenericWhitespace, EmptyLineSeparator, MissingCtor, InnerTypeLast, EmptyStatement, PackageName, OuterTypeFilename, RegexpSinglelineJava, Regexp, SuperFinalize, SuperClone, NestedForDepth, NestedTryDepth, NestedIfDepth, MissingSwitchDefault, MemberName, TypeName, MethodName, StaticVariableName, ConstantName, SimplifyBooleanReturn, InnerAssignment, EmptyForInitializerPad, RightCurly, MutableException, CustomImportOrder, WriteTag, UnusedImports, CommentsIndentation, NoWhitespaceAfter, AnnotationLocation, VisibilityModifier, PackageAnnotation, JavadocTagContinuationIndentation, NoClone, MethodLength, ImportOrder, EmptyForIteratorPad, MethodParamPad, LocalVariableName, LocalFinalVariableName, FinalLocalVariable, InterfaceTypeParameterName, ParameterName, MethodTypeParameterName, ArrayTrailingComma, WhitespaceAround, JavadocParagraph, AtclauseOrder, IllegalToken, StringLiteralEquality, FinalClass, ReturnCount, ArrayTypeStyle, ParameterNumber, HideUtilityClassConstructor, OneStatementPerLine, TypecastParenPad, LeftCurly, ParenPad, SeparatorWrap, OperatorWrap, CyclomaticComplexity, AbstractClassName, ClassFanOutComplexity, DescendantToken, SingleLineJavadoc, NonEmptyAtclauseDescription, SummaryJavadoc, NoFinalizer, SuppressWarnings, HiddenField, ExecutableStatementCount, ModifiedControlVariable, ParameterAssignment, FallThrough, BooleanExpressionComplexity, JavadocType, FinalParameters, OneTopLevelClass, NoLineWrap, IllegalTokenText, IllegalInstantiation, WhitespaceAfter, MagicNumber, OverloadMethodsDeclarationOrder, AvoidStaticImport, MissingOverride, IllegalImport, RequireThis, AvoidInlineConditionals, TrailingComment, LineLength, MultipleVariableDeclarations, DefaultComesLast, JavadocVariable, MissingDeprecated, JavaNCSS, DesignForExtension, AnnotationUseStyle, TodoComment, RedundantModifier, AnonInnerLength, AvoidEscapedUnicodeCharacters, RedundantImport, SimplifyBooleanExpression, EqualsHashCode, EqualsAvoidNull, EmptyCatchBlock, AvoidStarImport, UpperEll, AbbreviationAsWordInName, InterfaceIsType, ExplicitInitialization, DeclarationOrder, ModifierOrder, NPathComplexity, UnnecessaryParentheses, AvoidNestedBlocks, VariableDeclarationUsageDistance, IllegalCatch, UncommentedMain, OuterTypeNumber, Indentation, CovariantEquals, IllegalType, PackageDeclaration, ImportControl, ThrowsCount, NoWhitespaceBefore, MethodCount, NeedBraces, MultipleStringLiterals
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class CheckstyleConfigurationTest extends AbstractSpecification {
extension.showViolations
!extension.ignoreFailures
extension.sourceSets.size() == 2
extension.toolVersion == '6.7'
extension.toolVersion == '6.12.1'
extension.configFile instanceof File
extension.configFile.path == "$buildDir/checkstyle.xml"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import spock.lang.Unroll
*/
class EstiloExtensionTest extends AbstractSpecification {

@Unroll('convert #checkType check type')
def 'Choose a valid base checks type'() {
@Unroll
def 'check type #checkType named #name selection test'() {
given:
def extension = new EstiloExtension()
def closure = {
Expand Down Expand Up @@ -133,6 +133,9 @@ class EstiloExtensionTest extends AbstractSpecification {
then:
extension.checkCollection == null
extension.suppressionCollection == null
!extension.hasImportControl()
!extension.hasSuppressions()
!extension.hasHeader()
}

def 'Allow adding suppressions'() {
Expand Down Expand Up @@ -169,6 +172,9 @@ class EstiloExtensionTest extends AbstractSpecification {

then:
extension.suppressionCollection.length == 6
!extension.hasImportControl()
extension.hasSuppressions()
!extension.hasHeader()

extension.suppressionCollection.collection[0].files == '.*\\QTest.java\\E'
extension.suppressionCollection.collection[0].checks == 'LineLength'
Expand Down Expand Up @@ -229,6 +235,9 @@ class EstiloExtensionTest extends AbstractSpecification {

then:
extension.importControlCollection.length == 8
extension.hasImportControl()
!extension.hasSuppressions()
!extension.hasHeader()

extension.importControlCollection.basePackage == 'com'

Expand Down Expand Up @@ -266,9 +275,42 @@ class EstiloExtensionTest extends AbstractSpecification {

then:
extension.headerCheckOptions.size() == 3
!extension.hasImportControl()
!extension.hasSuppressions()
extension.hasHeader()

extension.headerCheckOptions.regexp == true
extension.headerCheckOptions.multiLines == [22, 23, 24, 25, 27]
extension.headerCheckOptions.template.length() == 70
}

def 'allow adding tool version'() {
given:
def extension = new EstiloExtension()
def closure = {
toolVersion '1.2.3.4'
}
closure.delegate = extension

when:
closure()

then:
extension.checkstyleToolVersion == '1.2.3.4'
}

def 'allow ignoring warnings'() {
given:
def extension = new EstiloExtension()
def closure = {
ignoreWarnings true
}
closure.delegate = extension

when:
closure()

then:
extension.ignoreCheckstyleWarnings
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ class EstiloTaskTest extends AbstractSpecification {

where:
checkType | hash
CheckType.GOOGLE | [-62, 6, -40, 36, -31, -5, -56, 11, 119, 5, 18, -89, -84, 39, -71, 75]
CheckType.SUN | [124, -99, 69, -22, 64, 85, 118, 17, -83, -38, -81, -93, -28, 121, 99, -34]
CheckType.GOOGLE | [-97, -66, 111, -98, 56, -44, 102, -100, -74, 43, 81, 0, 115, 29, 116, -105]
CheckType.SUN | [-12, -22, -63, 29, 93, 19, -115, 107, -17, -52, 21, -4, 2, 100, 71, 79]
}

def 'test suppressions should add a suppression filter module'() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ class FileLoaderTest extends AbstractSpecification {

where:
checkType | hash
CheckType.GOOGLE | [-107, -45, 71, 124, 50, 103, -47, 32, -74, 58, -63, -23, 56, 8, -56, 122]
CheckType.SUN | [118, -45, -18, 87, 12, 27, -77, 123, -122, -14, -128, -107, 121, -53, 119, -29]
CheckType.GOOGLE | [44, -55, 53, -59, -34, -78, 95, -46, -92, 29, 109, -104, 126, -12, 120, -16]
CheckType.SUN | [123, -62, -28, 57, 21, -38, -118, -78, -54, -54, -44, 67, -21, 63, -66, -79]
}

def fileHash(File file) {
Expand Down

0 comments on commit 608347a

Please sign in to comment.