Add Konsist test to check that files do not have double license header.
It seems that sometimes Android Studio is doing this mistake.
This commit is contained in:
parent
7810bf49fd
commit
1fe15e7b23
1 changed files with 26 additions and 0 deletions
|
|
@ -68,4 +68,30 @@ class KonsistLicenseTest {
|
||||||
enterpriseLicense.containsMatchIn(it.text)
|
enterpriseLicense.containsMatchIn(it.text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `assert that files do not have double license header`() {
|
||||||
|
Konsist
|
||||||
|
.scopeFromProject()
|
||||||
|
.files
|
||||||
|
.filter {
|
||||||
|
it.nameWithExtension != "locales.kt" &&
|
||||||
|
it.nameWithExtension != "KonsistLicenseTest.kt" &&
|
||||||
|
it.name.startsWith("Template ").not()
|
||||||
|
}
|
||||||
|
.assertTrue { it ->
|
||||||
|
it.text.count("New Vector") == 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun String.count(subString: String): Int {
|
||||||
|
var count = 0
|
||||||
|
var index = 0
|
||||||
|
while (true) {
|
||||||
|
index = indexOf(subString, index)
|
||||||
|
if (index == -1) return count
|
||||||
|
count++
|
||||||
|
index += subString.length
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue