0
0
mirror of https://github.com/ankidroid/Anki-Android.git synced 2024-09-19 19:42:17 +02:00

chore: lint empty strings

This moves a vandalism check from a review to CI

Prompted by PR 15931
This commit is contained in:
David Allison 2024-03-19 07:29:12 +00:00 committed by Brayan Oliveira
parent bded66d073
commit 482b49c47f
2 changed files with 23 additions and 0 deletions

View File

@ -92,5 +92,10 @@ class TranslationTypo : ResourceXmlDetector(), XmlScanner {
if (element.textContent.lowercase().contains("javascript") && !element.textContent.contains("JavaScript")) {
context.report(ISSUE, context.getElementLocation(element), "should be 'JavaScript'")
}
// remove empty strings
if (element.textContent.isEmpty() && element.getAttribute("name") != "empty_string") {
context.report(ISSUE, context.getElementLocation(element), "should not be empty")
}
}
}

View File

@ -51,4 +51,22 @@ class TranslationTypoTest {
TranslationTypo.ISSUE.assertXmlStringsHasError(invalidLowerCase, "should be 'JavaScript'")
}
@Test
fun `vandalism fails`() {
val stringRemoved = """<resources>
<string name="hello"></string>
</resources>"""
TranslationTypo.ISSUE.assertXmlStringsHasError(stringRemoved, "should not be empty")
}
@Test
fun `vandalism passes with empty_string key`() {
val stringRemoved = """<resources>
<string name="empty_string"></string>
</resources>"""
TranslationTypo.ISSUE.assertXmlStringsNoIssues(stringRemoved)
}
}