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:
parent
bded66d073
commit
482b49c47f
@ -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")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user