diff --git a/build.gradle b/build.gradle index db8a3eebce..a754adf84a 100644 --- a/build.gradle +++ b/build.gradle @@ -64,14 +64,6 @@ subprojects { subproject -> apply plugin: 'jacoco' apply plugin: 'checkstyle' - apply from: "${rootDir}/src/checkstyle/fixFinal.gradle" - apply from: "${rootDir}/src/checkstyle/fixHeaders.gradle" - apply from: "${rootDir}/src/checkstyle/fixModifiers.gradle" - apply from: "${rootDir}/src/checkstyle/fixThis.gradle" - apply from: "${rootDir}/src/checkstyle/fixRightCurly.gradle" - apply from: "${rootDir}/src/checkstyle/fixWhiteAround.gradle" - apply from: "${rootDir}/src/checkstyle/fixParenPad.gradle" - if (project.hasProperty('platformVersion')) { apply plugin: 'spring-io' diff --git a/src/checkstyle/fixFinal.gradle b/src/checkstyle/fixFinal.gradle deleted file mode 100644 index 54e4a68027..0000000000 --- a/src/checkstyle/fixFinal.gradle +++ /dev/null @@ -1,55 +0,0 @@ -task fixFinal << { - fileTree("${buildDir}/reports/checkstyle").include('*.xml').each { report -> - def xml = new XmlParser(false, false).parse(report) - xml.file.each { f -> - def errors = f.error - def finalErrors = [] - errors.each { error -> - if (error.@source == 'com.puppycrawl.tools.checkstyle.checks.design.FinalClassCheck') { - finalErrors.add(error) - } - } - if (finalErrors) { - def errorInx = 0 - def error = finalErrors[errorInx++] - def file = new File(f.@name) - println "Fixing file $file ..." - boolean headerFixed - boolean onNextLine - def outSource = '' - file.eachLine { line, ln -> - if (!headerFixed) { - def matcher = line =~ /Copyright (20\d\d)(?:-(20\d\d))?/ - if (matcher.count) { - def year1 = matcher[0][1] - if (now != year1) { - if (now != matcher[0][2]) { - line = line.replaceFirst(/(20\d\d)(?:-20\d\d)?/, year1 + "-$now") - } - } - headerFixed = true - } - } - - if (onNextLine || error && ln == (error.@line as int)) { - onNextLine = false - if (line.contains('@SuppressWarning')) { - onNextLine = true; - } - else { - line = line.replaceFirst('class', 'final class') - - println "Fixed line $line" - - error = finalErrors[errorInx++] - } - } - - outSource += line + System.lineSeparator() - } - file.write(outSource) - println() - } - } - } -} diff --git a/src/checkstyle/fixHeaders.gradle b/src/checkstyle/fixHeaders.gradle deleted file mode 100644 index 21a1264008..0000000000 --- a/src/checkstyle/fixHeaders.gradle +++ /dev/null @@ -1,43 +0,0 @@ -ext { - headerTemplate = new File('src/checkstyle/checkstyle-header.txt') - .text - .replaceAll(/\^\\Q|\\E\$|\^\$|\^\.\*\$/, '') - .replaceFirst(/\\E20\\d\\d\(\\-20\\d\\d\)\?\\Q/, '{year}') - .trim() + System.lineSeparator() + System.lineSeparator() - - - now = Calendar.instance.get(Calendar.YEAR) as String -} - -task fixHeaders << { - fileTree("${buildDir}/reports/checkstyle").include('*.xml').each { report -> - def xml = new XmlParser(false, false).parse(report) - xml.file.each { - if (it.error.@source == ['com.puppycrawl.tools.checkstyle.checks.header.RegexpHeaderCheck']) { - def years = now - def file = new File(it.@name) - def line - file.withReader { reader -> - while (line = reader.readLine()) { - def matcher = line =~ /Copyright (20\d\d)(?:-20\d\d)?/ - if (matcher.count) { - years = matcher[0][1] - if (years != now) { - years = years + "-$now" - } - break - } - } - } - - def header = headerTemplate.replaceFirst(/\{year}/, years) - - def sourceCode = file.text - sourceCode = sourceCode.replaceFirst(/(?s)(?:.*)(package org\.springframework\.integration.*)/, - "${header}\$1") - file.write(sourceCode) - println "Header fixed for $file" - } - } - } -} diff --git a/src/checkstyle/fixModifiers.gradle b/src/checkstyle/fixModifiers.gradle deleted file mode 100644 index 095f549fc9..0000000000 --- a/src/checkstyle/fixModifiers.gradle +++ /dev/null @@ -1,51 +0,0 @@ -task fixModifiers << { - fileTree("${buildDir}/reports/checkstyle").include('*.xml').each { report -> - def xml = new XmlParser(false, false).parse(report) - xml.file.each { f -> - def errors = f.error - def modifierErrors = [] - errors.each { error -> - if (error.@source == 'com.puppycrawl.tools.checkstyle.checks.modifier.RedundantModifierCheck') { - modifierErrors.add(error) - } - } - if (modifierErrors) { - def errorInx = 0 - def error = modifierErrors[errorInx++] - def file = new File(f.@name) - println "Fixing file $file ..." - boolean headerFixed - def outSource = '' - file.eachLine { line, ln -> - if (!headerFixed) { - def matcher = line =~ /Copyright (20\d\d)(?:-(20\d\d))?/ - if (matcher.count) { - def year1 = matcher[0][1] - if (now != year1) { - if (now != matcher[0][2]) { - line = line.replaceFirst(/(20\d\d)(?:-20\d\d)?/, year1 + "-$now") - } - } - headerFixed = true - } - } - - while (error && ln == (error.@line as int)) { - def message = error.@message - def modifier = message.substring(message.indexOf('\'') + 1, message.lastIndexOf('\'')) - - line = line.replaceFirst(modifier + ' ', '') - - println "Fixed line $line" - - error = modifierErrors[errorInx++] - } - - outSource += line + System.lineSeparator() - } - file.write(outSource) - println() - } - } - } -} diff --git a/src/checkstyle/fixParenPad.gradle b/src/checkstyle/fixParenPad.gradle deleted file mode 100644 index 8324c58836..0000000000 --- a/src/checkstyle/fixParenPad.gradle +++ /dev/null @@ -1,63 +0,0 @@ -task fixParenPad << { - fileTree("${buildDir}/reports/checkstyle").include('*.xml').each { report -> - def xml = new XmlParser(false, false).parse(report) - xml.file.each { f -> - def errors = f.error - def thisErrors = [] - errors.each { error -> - if (error.@source == 'com.puppycrawl.tools.checkstyle.checks.whitespace.ParenPadCheck' || - error.@source == 'com.puppycrawl.tools.checkstyle.checks.whitespace.TypecastParenPadCheck') { - thisErrors.add(error) - } - } - if (thisErrors) { - def errorInx = 0 - def error = thisErrors[errorInx++] - def file = new File(f.@name) - println "Fixing file $file ..." - boolean headerFixed - def outSource = '' - file.eachLine { line, ln -> - if (!headerFixed) { - def matcher = line =~ /Copyright (20\d\d)(?:-(20\d\d))?/ - if (matcher.count) { - def year1 = matcher[0][1] - if (now != year1) { - if (now != matcher[0][2]) { - line = line.replaceFirst(/(20\d\d)(?:-20\d\d)?/, year1 + "-$now") - } - } - headerFixed = true - } - } - - if (error && ln == (error.@line as int)) { - def message = error.@message - def index = (error.@column as int) - 1 - def chars = line.toCharArray() - for (int i = 0; i < index; i++) { - if (chars[i] == '\t') { // tabs before code == 8 - index -= 7; - } - else if (chars[i] != ' ') { // tabs after code start are only counted as 1 - break; - } - } - - line = line.substring(0, index) + line.substring(index + 1) - - println "Fixed line $line" - - while (error && ln == (error.@line as int)) { - error = thisErrors[errorInx++] - } - } - - outSource += line + System.lineSeparator() - } - file.write(outSource) - println() - } - } - } -} diff --git a/src/checkstyle/fixRightCurly.gradle b/src/checkstyle/fixRightCurly.gradle deleted file mode 100644 index 36d583d329..0000000000 --- a/src/checkstyle/fixRightCurly.gradle +++ /dev/null @@ -1,63 +0,0 @@ -task fixRightCurly << { - fileTree("${buildDir}/reports/checkstyle").include('*.xml').each { report -> - def xml = new XmlParser(false, false).parse(report) - xml.file.each { f -> - def errors = f.error - def thisErrors = [] - errors.each { error -> - if (error.@source == 'com.puppycrawl.tools.checkstyle.checks.blocks.RightCurlyCheck') { - thisErrors.add(error) - } - } - if (thisErrors) { - def errorInx = 0 - def error = thisErrors[errorInx++] - def file = new File(f.@name) - println "Fixing file $file ..." - boolean headerFixed - def outSource = '' - file.eachLine { line, ln -> - if (!headerFixed) { - def matcher = line =~ /Copyright (20\d\d)(?:-(20\d\d))?/ - if (matcher.count) { - def year1 = matcher[0][1] - if (now != year1) { - if (now != matcher[0][2]) { - line = line.replaceFirst(/(20\d\d)(?:-20\d\d)?/, year1 + "-$now") - } - } - headerFixed = true - } - } - - if (error && ln == (error.@line as int)) { - def index = (error.@column as int) + 1 - def chars = line.toCharArray() - def nextLine = System.lineSeparator() - for (int i = 0; i < index; i++) { - if (chars[i] == '\t') { // tabs before code == 8 - index -= 7; - nextLine += '\t' - } - else if (chars[i] != ' ') { // tabs after code start are only counted as 1 - break; - } - } - - line = line.substring(0, index-1) + nextLine + line.substring(index) - - println "Fixed line $line" - - while (error && ln == (error.@line as int)) { - error = thisErrors[errorInx++] - } - } - - outSource += line + System.lineSeparator() - } - file.write(outSource) - println() - } - } - } -} diff --git a/src/checkstyle/fixThis.gradle b/src/checkstyle/fixThis.gradle deleted file mode 100644 index 47f8d417f1..0000000000 --- a/src/checkstyle/fixThis.gradle +++ /dev/null @@ -1,66 +0,0 @@ -task fixThis << { - fileTree("${buildDir}/reports/checkstyle").include('*.xml').each { report -> - def xml = new XmlParser(false, false).parse(report) - xml.file.each { f -> - def errors = f.error - def thisErrors = [] - errors.each { error -> - if (error.@source == 'com.puppycrawl.tools.checkstyle.checks.coding.RequireThisCheck') { - thisErrors.add(error) - } - } - if (thisErrors) { - def errorInx = 0 - def error = thisErrors[errorInx++] - def file = new File(f.@name) - println "Fixing file $file ..." - boolean headerFixed - def outSource = '' - file.eachLine { line, ln -> - if (!headerFixed) { - def matcher = line =~ /Copyright (20\d\d)(?:-(20\d\d))?/ - if (matcher.count) { - def year1 = matcher[0][1] - if (now != year1) { - if (now != matcher[0][2]) { - line = line.replaceFirst(/(20\d\d)(?:-20\d\d)?/, year1 + "-$now") - } - } - headerFixed = true - } - } - - if (error && ln == (error.@line as int)) { - def message = error.@message - def property = message.substring(message.indexOf('\'') + 1, message.lastIndexOf('\'')) - def thisPrefix = message.substring(message.indexOf('"') + 1, message.lastIndexOf('"')) - - - def index = (error.@column as int) - 1 - def chars = line.toCharArray() - for (int i = 0; i < index; i++) { - if (chars[i] == '\t') { // tabs before code == 8 - index -= 7; - } - else if (chars[i] != ' ') { // tabs after code start are only counted as 1 - break; - } - } - - line = line.substring(0, index) + thisPrefix + property + line.substring(index + property.length()) - - println "Fixed line $line" - - while (error && ln == (error.@line as int)) { - error = thisErrors[errorInx++] - } - } - - outSource += line + System.lineSeparator() - } - file.write(outSource) - println() - } - } - } -} diff --git a/src/checkstyle/fixWhiteAround.gradle b/src/checkstyle/fixWhiteAround.gradle deleted file mode 100644 index 94cf02812c..0000000000 --- a/src/checkstyle/fixWhiteAround.gradle +++ /dev/null @@ -1,64 +0,0 @@ -task fixWhiteAround << { - fileTree("${buildDir}/reports/checkstyle").include('*.xml').each { report -> - def xml = new XmlParser(false, false).parse(report) - xml.file.each { f -> - def errors = f.error - def thisErrors = [] - errors.each { error -> - if (error.@source == 'com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAfterCheck' || - error.@source == 'com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAroundCheck') { - thisErrors.add(error) - } - } - if (thisErrors) { - def errorInx = 0 - def error = thisErrors[errorInx++] - def file = new File(f.@name) - println "Fixing file $file ..." - boolean headerFixed - def outSource = '' - file.eachLine { line, ln -> - if (!headerFixed) { - def matcher = line =~ /Copyright (20\d\d)(?:-(20\d\d))?/ - if (matcher.count) { - def year1 = matcher[0][1] - if (now != year1) { - if (now != matcher[0][2]) { - line = line.replaceFirst(/(20\d\d)(?:-20\d\d)?/, year1 + "-$now") - } - } - headerFixed = true - } - } - - if (error && ln == (error.@line as int)) { - def message = error.@message - - def index = (error.@column as int) - 1 - def chars = line.toCharArray() - for (int i = 0; i < index; i++) { - if (chars[i] == '\t') { // tabs before code == 8 - index -= 7; - } - else if (chars[i] != ' ') { // tabs after code start are only counted as 1 - break; - } - } - - line = line.substring(0, index) + ' ' + line.substring(index) - - println "Fixed line $line" - - while (error && ln == (error.@line as int)) { - error = thisErrors[errorInx++] - } - } - - outSource += line + System.lineSeparator() - } - file.write(outSource) - println() - } - } - } -}