Minor: better name for file walking with excludes
This commit is contained in:
@@ -133,7 +133,7 @@ class CodeConformanceTest : TestCase() {
|
|||||||
val root = nonSourcesMatcher.root
|
val root = nonSourcesMatcher.root
|
||||||
val extensions = File(root, ".bunch").readLines().map { it.split("_") }.flatten().toSet()
|
val extensions = File(root, ".bunch").readLines().map { it.split("_") }.flatten().toSet()
|
||||||
val failBuilder = mutableListOf<String>()
|
val failBuilder = mutableListOf<String>()
|
||||||
nonSourcesMatcher.walkTopDown(sourceBunchFilePattern).forEach { sourceFile ->
|
nonSourcesMatcher.excludeWalkTopDown(sourceBunchFilePattern).forEach { sourceFile ->
|
||||||
val matches = Regex("BUNCH (\\w+)")
|
val matches = Regex("BUNCH (\\w+)")
|
||||||
.findAll(sourceFile.readText())
|
.findAll(sourceFile.readText())
|
||||||
.map { it.groupValues[1] }
|
.map { it.groupValues[1] }
|
||||||
@@ -208,7 +208,7 @@ class CodeConformanceTest : TestCase() {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
nonSourcesMatcher.walkTopDown(SOURCES_FILE_PATTERN).forEach { sourceFile ->
|
nonSourcesMatcher.excludeWalkTopDown(SOURCES_FILE_PATTERN).forEach { sourceFile ->
|
||||||
val source = sourceFile.readText()
|
val source = sourceFile.readText()
|
||||||
for (test in tests) {
|
for (test in tests) {
|
||||||
if (test.filter(sourceFile, source)) test.result.add(sourceFile)
|
if (test.filter(sourceFile, source)) test.result.add(sourceFile)
|
||||||
@@ -234,7 +234,7 @@ class CodeConformanceTest : TestCase() {
|
|||||||
val copyrightRegex = Regex("""\bCopyright\b""")
|
val copyrightRegex = Regex("""\bCopyright\b""")
|
||||||
val root = COPYRIGHT_EXCLUDED_FILES_AND_DIRS_MATCHER.root
|
val root = COPYRIGHT_EXCLUDED_FILES_AND_DIRS_MATCHER.root
|
||||||
|
|
||||||
COPYRIGHT_EXCLUDED_FILES_AND_DIRS_MATCHER.walkTopDown(SOURCES_FILE_PATTERN)
|
COPYRIGHT_EXCLUDED_FILES_AND_DIRS_MATCHER.excludeWalkTopDown(SOURCES_FILE_PATTERN)
|
||||||
.filter { sourceFile ->
|
.filter { sourceFile ->
|
||||||
val relativePath = FileUtil.toSystemIndependentName(sourceFile.toRelativeString(root))
|
val relativePath = FileUtil.toSystemIndependentName(sourceFile.toRelativeString(root))
|
||||||
!knownThirdPartyCode.any { relativePath.startsWith(it) }
|
!knownThirdPartyCode.any { relativePath.startsWith(it) }
|
||||||
@@ -274,7 +274,7 @@ class CodeConformanceTest : TestCase() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun FileMatcher.walkTopDown(filePattern: Pattern): Sequence<File> {
|
private fun FileMatcher.excludeWalkTopDown(filePattern: Pattern): Sequence<File> {
|
||||||
return root.walkTopDown()
|
return root.walkTopDown()
|
||||||
.onEnter { dir ->
|
.onEnter { dir ->
|
||||||
!matchExact(dir) // Don't enter to ignored dirs
|
!matchExact(dir) // Don't enter to ignored dirs
|
||||||
@@ -390,7 +390,7 @@ class CodeConformanceTest : TestCase() {
|
|||||||
data class RepoOccurrences(val repo: String, val files: Collection<File>)
|
data class RepoOccurrences(val repo: String, val files: Collection<File>)
|
||||||
|
|
||||||
val extensionsPattern = Pattern.compile(".+\\.(java|kt|gradle|kts|xml)(\\.\\w+)?")
|
val extensionsPattern = Pattern.compile(".+\\.(java|kt|gradle|kts|xml)(\\.\\w+)?")
|
||||||
val repoOccurrences: List<RepoOccurrences> = nonSourcesMatcher.walkTopDown(extensionsPattern)
|
val repoOccurrences: List<RepoOccurrences> = nonSourcesMatcher.excludeWalkTopDown(extensionsPattern)
|
||||||
.flatMap { file ->
|
.flatMap { file ->
|
||||||
val checkers = repoCheckers.filter { checker ->
|
val checkers = repoCheckers.filter { checker ->
|
||||||
!checker.matcher.matchWithContains(file)
|
!checker.matcher.matchWithContains(file)
|
||||||
|
|||||||
Reference in New Issue
Block a user