checkstyle FinalClassCheck
fixes fixModifiers after fixFinal Revert CachingSessionFactory Class is spied in tests. checkstyle - Import Rules checkstyle InterfaceIsType checkstyle InnerTypeLast checkstyle OneStatementPerLine CovariantEquals OneTopLevelClass * Revert `'\n'` -> `System.lineSeparator()` in the Gradle scripts to meet Git `autocrlf = true` on Windows * Fix timing issue with the `LastModifiedFileListFilterTests`, when the `age = 1` might not be enough for the file object when we have some delay before checking
This commit is contained in:
committed by
Artem Bilan
parent
43af472c3a
commit
4ac3a79df7
@@ -5,5 +5,9 @@
|
||||
<suppressions>
|
||||
<suppress files="package-info\.java" checks=".*" />
|
||||
<suppress files="[\\/]test[\\/]" checks="RequireThis" />
|
||||
<suppress files="[\\/]test[\\/]" checks="FinalClass" />
|
||||
<suppress files="[\\/]test[\\/]" checks="AvoidStaticImport" />
|
||||
<suppress files="[\\/]test[\\/]" checks="InnerTypeLast" />
|
||||
<suppress files="CachingSessionFactory" checks="FinalClass" /> <!-- Tests spy -->
|
||||
<suppress files="[\\/]test[\\/]" checks="Javadoc*" />
|
||||
</suppressions>
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
</module>
|
||||
|
||||
<!-- Root Checks -->
|
||||
<module name="RegexpHeader">
|
||||
<property name="headerFile" value="src/checkstyle/checkstyle-header.txt" />
|
||||
<property name="fileExtensions" value="java" />
|
||||
</module>
|
||||
<module name="RegexpHeader">
|
||||
<property name="headerFile" value="src/checkstyle/checkstyle-header.txt" />
|
||||
<property name="fileExtensions" value="java" />
|
||||
</module>
|
||||
|
||||
<module name="NewlineAtEndOfFile">
|
||||
<property name="lineSeparator" value="lf"/>
|
||||
@@ -42,15 +42,15 @@
|
||||
<!-- <module name="AvoidNestedBlocks" /> -->
|
||||
|
||||
<!-- Class Design -->
|
||||
<!-- <module name="FinalClass" /> -->
|
||||
<!-- <module name="InterfaceIsType" /> -->
|
||||
<module name="FinalClass" />
|
||||
<module name="InterfaceIsType" />
|
||||
<module name="HideUtilityClassConstructor" />
|
||||
<!-- <module name="MutableException" /> -->
|
||||
<!-- <module name="InnerTypeLast" /> -->
|
||||
<!-- <module name="OneTopLevelClass" /> -->
|
||||
<module name="InnerTypeLast" />
|
||||
<module name="OneTopLevelClass" />
|
||||
|
||||
<!-- Coding -->
|
||||
<!-- <module name="CovariantEquals" /> -->
|
||||
<module name="CovariantEquals" />
|
||||
<!-- <module name="EmptyStatement" /> -->
|
||||
<!-- <module name="EqualsHashCode" /> -->
|
||||
<!-- <module name="InnerAssignment" /> -->
|
||||
@@ -67,19 +67,19 @@
|
||||
<!-- <property name="max" value="3" /> -->
|
||||
<!-- </module> -->
|
||||
<!-- <module name="MultipleVariableDeclarations" /> -->
|
||||
<module name="RequireThis">
|
||||
<property name="checkMethods" value="false" />
|
||||
</module>
|
||||
<!--<module name="OneStatementPerLine" /> -->
|
||||
<module name="RequireThis">
|
||||
<property name="checkMethods" value="false" />
|
||||
</module>
|
||||
<module name="OneStatementPerLine" />
|
||||
|
||||
<!-- Imports -->
|
||||
<!-- <module name="AvoidStarImport" /> -->
|
||||
<!-- <module name="AvoidStaticImport"> -->
|
||||
<!-- <property name="excludes" -->
|
||||
<!-- value="org.assertj.core.api.Assertions.*, org.junit.Assert.*, org.junit.Assume.*, org.junit.internal.matchers.ThrowableMessageMatcher.*, org.hamcrest.CoreMatchers.*, org.hamcrest.Matchers.*, org.springframework.boot.configurationprocessor.ConfigurationMetadataMatchers.*, org.springframework.boot.configurationprocessor.TestCompiler.*, org.mockito.Mockito.*, org.mockito.BDDMockito.*, org.mockito.Matchers.*, org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*, org.springframework.test.web.servlet.result.MockMvcResultMatchers.*, org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.*, org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.*, org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo" /> -->
|
||||
<!-- </module> -->
|
||||
<!-- <module name="IllegalImport" /> -->
|
||||
<!-- <module name="RedundantImport" /> -->
|
||||
<module name="AvoidStarImport" />
|
||||
<module name="AvoidStaticImport">
|
||||
<property name="excludes"
|
||||
value="org.assertj.core.api.Assertions.*, org.junit.Assert.*, org.junit.Assume.*, org.junit.internal.matchers.ThrowableMessageMatcher.*, org.hamcrest.CoreMatchers.*, org.hamcrest.Matchers.*, org.springframework.boot.configurationprocessor.ConfigurationMetadataMatchers.*, org.springframework.boot.configurationprocessor.TestCompiler.*, org.mockito.Mockito.*, org.mockito.BDDMockito.*, org.mockito.Matchers.*, org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*, org.springframework.test.web.servlet.result.MockMvcResultMatchers.*, org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.*, org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.*, org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo" />
|
||||
</module>
|
||||
<module name="IllegalImport" />
|
||||
<module name="RedundantImport" />
|
||||
<module name="UnusedImports">
|
||||
<property name="processJavadoc" value="true" />
|
||||
</module>
|
||||
@@ -125,7 +125,7 @@
|
||||
<!-- <module name="OuterTypeFilename" /> -->
|
||||
|
||||
<!-- Modifiers -->
|
||||
<module name="RedundantModifier" />
|
||||
<module name="RedundantModifier" />
|
||||
|
||||
<!-- Regexp -->
|
||||
<!-- <module name="RegexpSinglelineJava"> -->
|
||||
@@ -166,5 +166,5 @@
|
||||
<!-- <module name="WhitespaceAfter" /> -->
|
||||
<!-- <module name="WhitespaceAround" /> -->
|
||||
|
||||
</module>
|
||||
</module>
|
||||
</module>
|
||||
|
||||
55
src/checkstyle/fixFinal.gradle
Normal file
55
src/checkstyle/fixFinal.gradle
Normal file
@@ -0,0 +1,55 @@
|
||||
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()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user