CodeConformanceTest: revert formatting committed by mistake
This commit is contained in:
@@ -27,32 +27,32 @@ class CodeConformanceTest : TestCase() {
|
|||||||
private val JAVA_FILE_PATTERN = Pattern.compile(".+\\.java")
|
private val JAVA_FILE_PATTERN = Pattern.compile(".+\\.java")
|
||||||
private val SOURCES_FILE_PATTERN = Pattern.compile("(.+\\.java|.+\\.kt|.+\\.js)")
|
private val SOURCES_FILE_PATTERN = Pattern.compile("(.+\\.java|.+\\.kt|.+\\.js)")
|
||||||
private val EXCLUDED_FILES_AND_DIRS = listOf(
|
private val EXCLUDED_FILES_AND_DIRS = listOf(
|
||||||
"android.tests.dependencies",
|
"android.tests.dependencies",
|
||||||
"buildSrc",
|
"buildSrc",
|
||||||
"core/reflection.jvm/src/kotlin/reflect/jvm/internal/pcollections",
|
"core/reflection.jvm/src/kotlin/reflect/jvm/internal/pcollections",
|
||||||
"js/js.tests/.gradle",
|
"js/js.tests/.gradle",
|
||||||
"js/js.translator/testData/node_modules",
|
"js/js.translator/testData/node_modules",
|
||||||
"libraries/kotlin.test/js/it/.gradle",
|
"libraries/kotlin.test/js/it/.gradle",
|
||||||
"libraries/kotlin.test/js/it/node_modules",
|
"libraries/kotlin.test/js/it/node_modules",
|
||||||
"libraries/stdlib/js/.gradle",
|
"libraries/stdlib/js/.gradle",
|
||||||
"libraries/stdlib/js/build",
|
"libraries/stdlib/js/build",
|
||||||
"libraries/reflect/build",
|
"libraries/reflect/build",
|
||||||
"libraries/reflect/api/src/java9/java/kotlin/reflect/jvm/internal/impl",
|
"libraries/reflect/api/src/java9/java/kotlin/reflect/jvm/internal/impl",
|
||||||
"libraries/tools/binary-compatibility-validator/src/main/kotlin/org.jetbrains.kotlin.tools",
|
"libraries/tools/binary-compatibility-validator/src/main/kotlin/org.jetbrains.kotlin.tools",
|
||||||
"dependencies",
|
"dependencies",
|
||||||
"js/js.translator/qunit/qunit.js",
|
"js/js.translator/qunit/qunit.js",
|
||||||
"libraries/tools/kotlin-js-tests/src/test/web/qunit.js",
|
"libraries/tools/kotlin-js-tests/src/test/web/qunit.js",
|
||||||
"out",
|
"out",
|
||||||
"dist",
|
"dist",
|
||||||
"libraries/tools/kotlin-gradle-plugin-core/gradle_api_jar/build/tmp",
|
"libraries/tools/kotlin-gradle-plugin-core/gradle_api_jar/build/tmp",
|
||||||
"libraries/tools/kotlin-maven-plugin/target",
|
"libraries/tools/kotlin-maven-plugin/target",
|
||||||
"libraries/tools/kotlinp/src",
|
"libraries/tools/kotlinp/src",
|
||||||
"libraries/tools/kotlin-test-nodejs-runner/node_modules",
|
"libraries/tools/kotlin-test-nodejs-runner/node_modules",
|
||||||
"libraries/tools/kotlin-test-nodejs-runner/.gradle",
|
"libraries/tools/kotlin-test-nodejs-runner/.gradle",
|
||||||
"compiler/testData/psi/kdoc",
|
"compiler/testData/psi/kdoc",
|
||||||
"compiler/tests/org/jetbrains/kotlin/code/CodeConformanceTest.kt",
|
"compiler/tests/org/jetbrains/kotlin/code/CodeConformanceTest.kt",
|
||||||
"compiler/util/src/org/jetbrains/kotlin/config/MavenComparableVersion.java",
|
"compiler/util/src/org/jetbrains/kotlin/config/MavenComparableVersion.java",
|
||||||
"dependencies/protobuf/protobuf-relocated/build"
|
"dependencies/protobuf/protobuf-relocated/build"
|
||||||
).map(::File)
|
).map(::File)
|
||||||
|
|
||||||
private val COPYRIGHT_EXCLUDED_FILES_AND_DIRS = listOf(
|
private val COPYRIGHT_EXCLUDED_FILES_AND_DIRS = listOf(
|
||||||
@@ -99,49 +99,49 @@ class CodeConformanceTest : TestCase() {
|
|||||||
val atAuthorPattern = Pattern.compile("/\\*.+@author.+\\*/", Pattern.DOTALL)
|
val atAuthorPattern = Pattern.compile("/\\*.+@author.+\\*/", Pattern.DOTALL)
|
||||||
|
|
||||||
val tests = listOf(
|
val tests = listOf(
|
||||||
TestData(
|
TestData(
|
||||||
"%d source files contain @author javadoc tag.\nPlease remove them or exclude in this test:\n%s",
|
"%d source files contain @author javadoc tag.\nPlease remove them or exclude in this test:\n%s",
|
||||||
{ source ->
|
{ source ->
|
||||||
// substring check is an optimization
|
// substring check is an optimization
|
||||||
"@author" in source && atAuthorPattern.matcher(source).find() &&
|
"@author" in source && atAuthorPattern.matcher(source).find() &&
|
||||||
"ASM: a very small and fast Java bytecode manipulation framework" !in source
|
"ASM: a very small and fast Java bytecode manipulation framework" !in source
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
TestData(
|
TestData(
|
||||||
"%d source files use something from com.beust.jcommander.internal package.\n" +
|
"%d source files use something from com.beust.jcommander.internal package.\n" +
|
||||||
"This code won't work when there's no TestNG in the classpath of our IDEA plugin, " +
|
"This code won't work when there's no TestNG in the classpath of our IDEA plugin, " +
|
||||||
"because there's only an optional dependency on testng.jar.\n" +
|
"because there's only an optional dependency on testng.jar.\n" +
|
||||||
"Most probably you meant to use Guava's Lists, Maps or Sets instead. " +
|
"Most probably you meant to use Guava's Lists, Maps or Sets instead. " +
|
||||||
"Please change references in these files to com.google.common.collect:\n%s",
|
"Please change references in these files to com.google.common.collect:\n%s",
|
||||||
{ source ->
|
{ source ->
|
||||||
"com.beust.jcommander.internal" in source
|
"com.beust.jcommander.internal" in source
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
TestData(
|
TestData(
|
||||||
"%d source files contain references to package org.jetbrains.jet.\n" +
|
"%d source files contain references to package org.jetbrains.jet.\n" +
|
||||||
"Package org.jetbrains.jet is deprecated now in favor of org.jetbrains.kotlin. " +
|
"Package org.jetbrains.jet is deprecated now in favor of org.jetbrains.kotlin. " +
|
||||||
"Please consider changing the package in these files:\n%s",
|
"Please consider changing the package in these files:\n%s",
|
||||||
{ source ->
|
{ source ->
|
||||||
"org.jetbrains.jet" in source
|
"org.jetbrains.jet" in source
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
TestData(
|
TestData(
|
||||||
"%d source files contain references to package kotlin.reflect.jvm.internal.impl.\n" +
|
"%d source files contain references to package kotlin.reflect.jvm.internal.impl.\n" +
|
||||||
"This package contains internal reflection implementation and is a result of a " +
|
"This package contains internal reflection implementation and is a result of a " +
|
||||||
"post-processing of kotlin-reflect.jar by jarjar.\n" +
|
"post-processing of kotlin-reflect.jar by jarjar.\n" +
|
||||||
"Most probably you meant to use classes from org.jetbrains.kotlin.**.\n" +
|
"Most probably you meant to use classes from org.jetbrains.kotlin.**.\n" +
|
||||||
"Please change references in these files or exclude them in this test:\n%s",
|
"Please change references in these files or exclude them in this test:\n%s",
|
||||||
{ source ->
|
{ source ->
|
||||||
"kotlin.reflect.jvm.internal.impl" in source
|
"kotlin.reflect.jvm.internal.impl" in source
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
TestData(
|
TestData(
|
||||||
"%d source files contain references to package org.objectweb.asm.\n" +
|
"%d source files contain references to package org.objectweb.asm.\n" +
|
||||||
"Package org.jetbrains.org.objectweb.asm should be used instead to avoid troubles with different asm versions in classpath. " +
|
"Package org.jetbrains.org.objectweb.asm should be used instead to avoid troubles with different asm versions in classpath. " +
|
||||||
"Please consider changing the package in these files:\n%s",
|
"Please consider changing the package in these files:\n%s",
|
||||||
{ source ->
|
{ source ->
|
||||||
" org.objectweb.asm" in source
|
" org.objectweb.asm" in source
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
for (sourceFile in FileUtil.findFilesByMask(SOURCES_FILE_PATTERN, File("."))) {
|
for (sourceFile in FileUtil.findFilesByMask(SOURCES_FILE_PATTERN, File("."))) {
|
||||||
@@ -174,7 +174,7 @@ class CodeConformanceTest : TestCase() {
|
|||||||
for (sourceFile in FileUtil.findFilesByMask(SOURCES_FILE_PATTERN, root)) {
|
for (sourceFile in FileUtil.findFilesByMask(SOURCES_FILE_PATTERN, root)) {
|
||||||
val relativePath = FileUtil.toSystemIndependentName(sourceFile.toRelativeString(root))
|
val relativePath = FileUtil.toSystemIndependentName(sourceFile.toRelativeString(root))
|
||||||
if (COPYRIGHT_EXCLUDED_FILES_AND_DIRS.any { relativePath.startsWith(it) } ||
|
if (COPYRIGHT_EXCLUDED_FILES_AND_DIRS.any { relativePath.startsWith(it) } ||
|
||||||
knownThirdPartyCode.any { relativePath.startsWith(it)}) continue
|
knownThirdPartyCode.any { relativePath.startsWith(it) }) continue
|
||||||
|
|
||||||
sourceFile.useLines { lineSequence ->
|
sourceFile.useLines { lineSequence ->
|
||||||
for (line in lineSequence) {
|
for (line in lineSequence) {
|
||||||
@@ -185,21 +185,23 @@ class CodeConformanceTest : TestCase() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (filesWithUnlistedCopyrights.isNotEmpty()) {
|
if (filesWithUnlistedCopyrights.isNotEmpty()) {
|
||||||
fail("The following files contain third-party copyrights and no license information. " +
|
fail(
|
||||||
"Please update license/README.md accordingly:\n${filesWithUnlistedCopyrights.joinToString("\n")}")
|
"The following files contain third-party copyrights and no license information. " +
|
||||||
|
"Please update license/README.md accordingly:\n${filesWithUnlistedCopyrights.joinToString("\n")}"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadKnownThirdPartyCodeList(): List<String> {
|
private fun loadKnownThirdPartyCodeList(): List<String> {
|
||||||
File("license/README.md").useLines { lineSequence ->
|
File("license/README.md").useLines { lineSequence ->
|
||||||
return lineSequence
|
return lineSequence
|
||||||
.filter { it.startsWith(" - Path: ") }
|
.filter { it.startsWith(" - Path: ") }
|
||||||
.map { it.removePrefix(" - Path: ").trim().ensureFileOrEndsWithSlash() }
|
.map { it.removePrefix(" - Path: ").trim().ensureFileOrEndsWithSlash() }
|
||||||
.toList()
|
.toList()
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun String.ensureFileOrEndsWithSlash() =
|
private fun String.ensureFileOrEndsWithSlash() =
|
||||||
if (endsWith("/") || "." in substringAfterLast('/')) this else this + "/"
|
if (endsWith("/") || "." in substringAfterLast('/')) this else this + "/"
|
||||||
|
|||||||
Reference in New Issue
Block a user