mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-04 20:01:55 +00:00
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:
@@ -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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user