From 853da52fd5112839ee3413fb7aa382a876796ae5 Mon Sep 17 00:00:00 2001 From: Nic McPhee Date: Fri, 12 Jan 2024 17:55:36 -0600 Subject: [PATCH] Adding a bogus test to check SonarQube on loops DeepSource (correctly) complained about our use of raw `for` loops, where SonarQube has remained silent on this. I've added a bogus test that uses a (new) raw `for` loop to see if that causes SonarQube to say something. --- src/test/java/hellos/HellosTest.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/test/java/hellos/HellosTest.java b/src/test/java/hellos/HellosTest.java index f49ff6d..f3f3607 100644 --- a/src/test/java/hellos/HellosTest.java +++ b/src/test/java/hellos/HellosTest.java @@ -20,16 +20,27 @@ void setUp() { lines = output.split("\n"); } + @Test + void sillyTest() { + int numLines = 0; + + for (int i = 0; i < lines.length; ++i) { + ++numLines; + } + + assertEquals(lines.length, numLines, "Number of lines in output doesn't match"); + } + @Test void testLineStructure() { // This regex supports unicode letters spaces, apostrophes, and hyphens // Taken from // https://stackoverflow.com/questions/15805555/java-regex-to-validate-full-name-allow-only-spaces-and-letters // The pattern needs to include - // - some name, - // - the "says", - // - and the single quotes, and - // - they must speak with emphasis as noted by the required "!" + // - some name, + // - the "says", + // - and the single quotes, and + // - they must speak with emphasis as noted by the required "!" String linePattern = "[\\p{L} .'-]+ says '+[\\p{L} .'-]+!'"; for (int i = 0; i < lines.length; ++i) {