From e54ee55320b0ccb2e444791802b4a505a816515a Mon Sep 17 00:00:00 2001 From: Mark Allen <3417310+maallen@users.noreply.github.com> Date: Wed, 23 Oct 2024 14:02:23 +0100 Subject: [PATCH] Fix being removed from checker failure errors (#169) * Fixes issue where markdown on Github is dropping * Update tests --- .../checks/AbstractPlaceholderDescriptionCheck.java | 8 ++++++-- ...oubleBracesPlaceholderDescriptionCheckerTest.java | 12 ++++++------ .../checks/PlaceholderCommentCheckerTest.java | 8 ++++---- ...ariableTypePlaceholderDescriptionCheckerTest.java | 8 ++++---- ...SimpleRegexPlaceholderDescriptionCheckerTest.java | 10 +++++----- ...ingleBracesPlaceholderDescriptionCheckerTest.java | 10 +++++----- 6 files changed, 30 insertions(+), 26 deletions(-) diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/checks/AbstractPlaceholderDescriptionCheck.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/checks/AbstractPlaceholderDescriptionCheck.java index 47a8378487..65e945380b 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/checks/AbstractPlaceholderDescriptionCheck.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/checks/AbstractPlaceholderDescriptionCheck.java @@ -20,8 +20,10 @@ public Optional getFailureText(String placeholder) { + placeholder + QUOTE_MARKER + " in comment. Please add a description in the string comment in the form " + + QUOTE_MARKER + placeholder - + ":"; + + ":" + + QUOTE_MARKER; } else if (!placeholder.trim().isEmpty()) { failureText = "Missing description for placeholder with name " @@ -29,8 +31,10 @@ public Optional getFailureText(String placeholder) { + placeholder + QUOTE_MARKER + " in comment. Please add a description in the string comment in the form " + + QUOTE_MARKER + placeholder - + ":"; + + ":" + + QUOTE_MARKER; } return Optional.ofNullable(failureText); } diff --git a/cli/src/test/java/com/box/l10n/mojito/cli/command/checks/DoubleBracesPlaceholderDescriptionCheckerTest.java b/cli/src/test/java/com/box/l10n/mojito/cli/command/checks/DoubleBracesPlaceholderDescriptionCheckerTest.java index 08b5beb53a..0010edd93f 100644 --- a/cli/src/test/java/com/box/l10n/mojito/cli/command/checks/DoubleBracesPlaceholderDescriptionCheckerTest.java +++ b/cli/src/test/java/com/box/l10n/mojito/cli/command/checks/DoubleBracesPlaceholderDescriptionCheckerTest.java @@ -37,7 +37,7 @@ public void testMissingPlaceholderDescriptionInComment() { + QUOTE_MARKER + "placeholder" + QUOTE_MARKER - + " in comment. Please add a description in the string comment in the form placeholder:")); + + " in comment. Please add a description in the string comment in the form `placeholder:`")); } @Test @@ -52,7 +52,7 @@ public void testNullComment() { + QUOTE_MARKER + "placeholder" + QUOTE_MARKER - + " in comment. Please add a description in the string comment in the form placeholder:")); + + " in comment. Please add a description in the string comment in the form `placeholder:`")); } @Test @@ -60,7 +60,7 @@ public void testMultiplePlaceholderDescriptionsInComment() { Set failures = doubleBracesPlaceholderCommentChecker.checkCommentForDescriptions( "A source string with a single {{placeholder}} and {another} and so {more}.", - "Test comment placeholder:description 1,another: description 2,more: description 3"); + "Test comment `placeholder:description 1`,`another: description 2`,`more: description 3`"); Assert.assertTrue(failures.isEmpty()); } @@ -77,7 +77,7 @@ public void testOneOfMultiplePlaceholderDescriptionsMissingInComment() { + QUOTE_MARKER + "another" + QUOTE_MARKER - + " in comment. Please add a description in the string comment in the form another:")); + + " in comment. Please add a description in the string comment in the form `another:`")); } @Test @@ -93,7 +93,7 @@ public void testPluralPlaceholderMissingDescription() { + QUOTE_MARKER + "numFiles" + QUOTE_MARKER - + " in comment. Please add a description in the string comment in the form numFiles:")); + + " in comment. Please add a description in the string comment in the form `numFiles:`")); } @Test @@ -109,6 +109,6 @@ public void testNumberedPlaceholder() { + QUOTE_MARKER + "0" + QUOTE_MARKER - + " in comment. Please add a description in the string comment in the form 0:")); + + " in comment. Please add a description in the string comment in the form `0:`")); } } diff --git a/cli/src/test/java/com/box/l10n/mojito/cli/command/checks/PlaceholderCommentCheckerTest.java b/cli/src/test/java/com/box/l10n/mojito/cli/command/checks/PlaceholderCommentCheckerTest.java index 3d4ad45793..42e2b18911 100644 --- a/cli/src/test/java/com/box/l10n/mojito/cli/command/checks/PlaceholderCommentCheckerTest.java +++ b/cli/src/test/java/com/box/l10n/mojito/cli/command/checks/PlaceholderCommentCheckerTest.java @@ -146,7 +146,7 @@ public void testOneOfMultiplePlaceholderDescriptionsMissingInComment() { + QUOTE_MARKER + "another" + QUOTE_MARKER - + " in comment. Please add a description in the string comment in the form another:", + + " in comment. Please add a description in the string comment in the form `another:`", result.getNotificationText()); } @@ -270,17 +270,17 @@ public void testMultipleIOSPlaceholderTypesFails() { result .getNotificationText() .contains( - "Please add a description in the string comment in the form %1$@:")); + "Please add a description in the string comment in the form `%1$@:`")); Assert.assertTrue( result .getNotificationText() .contains( - "Please add a description in the string comment in the form %@:")); + "Please add a description in the string comment in the form `%@:`")); Assert.assertTrue( result .getNotificationText() .contains( - "Please add a description in the string comment in the form %2$@ld:")); + "Please add a description in the string comment in the form `%2$@ld:`")); } @Test diff --git a/cli/src/test/java/com/box/l10n/mojito/cli/command/checks/PrintfLikeVariableTypePlaceholderDescriptionCheckerTest.java b/cli/src/test/java/com/box/l10n/mojito/cli/command/checks/PrintfLikeVariableTypePlaceholderDescriptionCheckerTest.java index 5303037507..7131cc515e 100644 --- a/cli/src/test/java/com/box/l10n/mojito/cli/command/checks/PrintfLikeVariableTypePlaceholderDescriptionCheckerTest.java +++ b/cli/src/test/java/com/box/l10n/mojito/cli/command/checks/PrintfLikeVariableTypePlaceholderDescriptionCheckerTest.java @@ -52,7 +52,7 @@ public void testFailure() { + QUOTE_MARKER + "count" + QUOTE_MARKER - + " in comment. Please add a description in the string comment in the form count:")); + + " in comment. Please add a description in the string comment in the form `count:`")); } @Test @@ -69,7 +69,7 @@ public void testFailureWithBraces() { + QUOTE_MARKER + "count" + QUOTE_MARKER - + " in comment. Please add a description in the string comment in the form count:")); + + " in comment. Please add a description in the string comment in the form `count:`")); } @Test @@ -86,7 +86,7 @@ public void testNullComment() { + QUOTE_MARKER + "count" + QUOTE_MARKER - + " in comment. Please add a description in the string comment in the form count:")); + + " in comment. Please add a description in the string comment in the form `count:`")); } @Test @@ -103,7 +103,7 @@ public void testFailureWithMultiplePlaceholders() { + QUOTE_MARKER + "shelf_count" + QUOTE_MARKER - + " in comment. Please add a description in the string comment in the form shelf_count:")); + + " in comment. Please add a description in the string comment in the form `shelf_count:`")); } @Test diff --git a/cli/src/test/java/com/box/l10n/mojito/cli/command/checks/SimpleRegexPlaceholderDescriptionCheckerTest.java b/cli/src/test/java/com/box/l10n/mojito/cli/command/checks/SimpleRegexPlaceholderDescriptionCheckerTest.java index eaa953f658..eb1c6635a5 100644 --- a/cli/src/test/java/com/box/l10n/mojito/cli/command/checks/SimpleRegexPlaceholderDescriptionCheckerTest.java +++ b/cli/src/test/java/com/box/l10n/mojito/cli/command/checks/SimpleRegexPlaceholderDescriptionCheckerTest.java @@ -42,7 +42,7 @@ public void testFailure() { + QUOTE_MARKER + "%1" + QUOTE_MARKER - + " in comment. Please add a description in the string comment in the form %1:")); + + " in comment. Please add a description in the string comment in the form `%1:`")); } @Test @@ -58,7 +58,7 @@ public void testNullComment() { + QUOTE_MARKER + "%1" + QUOTE_MARKER - + " in comment. Please add a description in the string comment in the form %1:")); + + " in comment. Please add a description in the string comment in the form `%1:`")); } @Test @@ -74,7 +74,7 @@ public void testFailureWithMultiplePlaceholders() { + QUOTE_MARKER + "%2" + QUOTE_MARKER - + " in comment. Please add a description in the string comment in the form %2:")); + + " in comment. Please add a description in the string comment in the form `%2:`")); } @Test @@ -103,7 +103,7 @@ public void testNoSpecifierRegexFailure() { + QUOTE_MARKER + "%d" + QUOTE_MARKER - + " in comment. Please add a description in the string comment in the form %d:")); + + " in comment. Please add a description in the string comment in the form `%d:`")); } @Test @@ -121,6 +121,6 @@ public void testNoSpecifierRegexFailureWithMultiplePlaceholders() { + QUOTE_MARKER + "%s" + QUOTE_MARKER - + " in comment. Please add a description in the string comment in the form %s:")); + + " in comment. Please add a description in the string comment in the form `%s:`")); } } diff --git a/cli/src/test/java/com/box/l10n/mojito/cli/command/checks/SingleBracesPlaceholderDescriptionCheckerTest.java b/cli/src/test/java/com/box/l10n/mojito/cli/command/checks/SingleBracesPlaceholderDescriptionCheckerTest.java index 77ca8ff5f8..c0f5286855 100644 --- a/cli/src/test/java/com/box/l10n/mojito/cli/command/checks/SingleBracesPlaceholderDescriptionCheckerTest.java +++ b/cli/src/test/java/com/box/l10n/mojito/cli/command/checks/SingleBracesPlaceholderDescriptionCheckerTest.java @@ -37,7 +37,7 @@ public void testMissingPlaceholderDescriptionInComment() { + QUOTE_MARKER + "placeholder" + QUOTE_MARKER - + " in comment. Please add a description in the string comment in the form placeholder:")); + + " in comment. Please add a description in the string comment in the form `placeholder:`")); } @Test @@ -52,7 +52,7 @@ public void testNullComment() { + QUOTE_MARKER + "placeholder" + QUOTE_MARKER - + " in comment. Please add a description in the string comment in the form placeholder:")); + + " in comment. Please add a description in the string comment in the form `placeholder:`")); } @Test @@ -77,7 +77,7 @@ public void testOneOfMultiplePlaceholderDescriptionsMissingInComment() { + QUOTE_MARKER + "another" + QUOTE_MARKER - + " in comment. Please add a description in the string comment in the form another:")); + + " in comment. Please add a description in the string comment in the form `another:`")); } @Test @@ -93,7 +93,7 @@ public void testPluralPlaceholderMissingDescription() { + QUOTE_MARKER + "numFiles" + QUOTE_MARKER - + " in comment. Please add a description in the string comment in the form numFiles:")); + + " in comment. Please add a description in the string comment in the form `numFiles:`")); } @Test @@ -110,7 +110,7 @@ public void testNumberedPlaceholder() { + QUOTE_MARKER + "0" + QUOTE_MARKER - + " in comment. Please add a description in the string comment in the form 0:")); + + " in comment. Please add a description in the string comment in the form `0:`")); } @Test