Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions breeze
Submodule breeze added at beeafc
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.2</version>
<configuration>
<argLine>${argLine} --add-modules jdk.incubator.vector</argLine>
<argLine>--add-modules jdk.incubator.vector</argLine>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot May 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Be careful with the modified argLine configuration

The removal of ${argLine} from the Surefire plugin configuration might break code coverage reporting. When tools like JaCoCo are used, they typically inject their Java agent through the argLine property.


🏁 Script executed:

#!/bin/bash
# Check if JaCoCo is used and if it affects the Maven builds

# Look for JaCoCo executions in the POM
echo "Checking for JaCoCo configuration in POM..."
grep -A 20 "jacoco-maven-plugin" pom.xml

# Check if the coverage profile uses the argLine
echo -e "\nVerify if coverage profile is used in CI/CD pipeline..."
find .github -type f -name "*.yml" -exec grep -l "coverage" {} \; | xargs grep -l "mvn"

# Run a test with the coverage profile to see if it fails
echo -e "\nTrying a test run with coverage profile..."
mvn clean test -Pcoverage -DskipTests || echo "Test with coverage profile failed"

Length of output: 1688


Ensure JaCoCo agent remains in Surefire’s argLine

The current Surefire configuration in pom.xml (around line 99) fully replaces the default ${argLine}:

<argLine>--add-modules jdk.incubator.vector</argLine>

JaCoCo’s prepare-agent goal injects its -javaagent via ${argLine}, so dropping it will break your code-coverage reports. To fix this, prepend the existing ${argLine} when adding modules:

<argLine>${argLine} --add-modules jdk.incubator.vector</argLine>

– File: pom.xml (Surefire plugin configuration)
– Location: since you have a jacoco-maven-plugin prepare-agent execution and a CI profile that uses it, be sure the ${argLine} placeholder is preserved.

🤖 Prompt for AI Agents
In pom.xml at line 99, the Surefire plugin's argLine configuration currently
replaces the entire argLine with "--add-modules jdk.incubator.vector", which
removes the existing ${argLine} placeholder. To fix this and preserve JaCoCo's
Java agent injection, modify the argLine to prepend the new modules while
including the existing ${argLine} by setting it to "--add-modules
jdk.incubator.vector ${argLine}".

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file shouldn't need to be altered?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kappsegla You're right to question this. The pom.xml file doesn't need to be modified for adding the TextUtils functionality. The change to remove ${argLine} from the Surefire configuration is unrelated to the new utility class and its tests.

In fact, removing ${argLine} could break code coverage reporting as JaCoCo injects its Java agent through this property. I recommend keeping the original configuration:

<argLine>${argLine} --add-modules jdk.incubator.vector</argLine>

Unless there's a specific reason for changing the build configuration, it's best to focus PR changes only on what's needed for the new feature.

</configuration>
</plugin>
<plugin>
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/utils/TextUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package utils;


public class TextUtils {
public static int countWords(String text) {
if (text == null || text.isBlank()) return 0;
return text.trim().split("\\s+").length;
}
}
34 changes: 34 additions & 0 deletions src/test/java/utils/TextUtilsTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package utils;

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;

public class TextUtilsTest {

@Test
public void testCountWords_NormalSentence() {
String text = "Det här är en mening.";
int result = TextUtils.countWords(text);
assertEquals(5, result);
}

@Test
public void testCountWords_EmptyString() {
String text = "";
int result = TextUtils.countWords(text);
assertEquals(0, result);
}

@Test
public void testCountWords_Null() {
int result = TextUtils.countWords(null);
assertEquals(0, result);
}

@Test
public void testCountWords_ExtraSpaces() {
String text = " En mening med mellanrum ";
int result = TextUtils.countWords(text);
assertEquals(4, result);
}
}