Apache Nutch is an extensible and scalable web crawler
NUTCH-3191 Fix SonarCloud PR analysis: missing JaCoCo XML, test binaries path, and source encoding warnings (#943)
Lewis John McGibbney790694141756
diff --git a/.github/workflows/junit-report.yml b/.github/workflows/junit-report.ymlindex 8eae9f5f2..08fb180be 100644--- a/.github/workflows/junit-report.yml+++ b/.github/workflows/junit-report.yml@@ -55,13 +55,15 @@ jobs:echo "::error::Download path $root is missing."exit 1fi- files=("$root"/build/**/TEST-*.xml)+ # upload-artifact strips the common 'build/' prefix from the uploaded+ # paths, so reports land as $root/test/... and $root/<plugin>/test/...+ files=("$root"/**/TEST-*.xml)if [ ${#files[@]} -eq 0 ] || [ ! -e "${files[0]}" ]; then- echo "::error::No TEST-*.xml under $root/build/ (artifact missing, wrong layout, or download failed)."+ echo "::error::No TEST-*.xml under $root/ (artifact missing, wrong layout, or download failed)."find "$root" -maxdepth 5 -type d -print 2>/dev/null | head -80 || trueexit 1fi- echo "Found ${#files[@]} JUnit report file(s) under $root/build/."+ echo "Found ${#files[@]} JUnit report file(s) under $root/."- name: Resolve PR numberid: prrun: |@@ -82,7 +84,7 @@ jobs:- name: Publish Test Reportuses: mikepenz/action-junit-report@v6with:- report_paths: ./junit-ubuntu-jdk17/build/**/TEST-*.xml+ report_paths: ./junit-ubuntu-jdk17/**/TEST-*.xmlcheck_name: JUnit Test Reportcommit: ${{ github.event.workflow_run.head_sha }}fail_on_failure: falsediff --git a/.github/workflows/master-build.yml b/.github/workflows/master-build.ymlindex 5e6b0302a..74072f591 100644--- a/.github/workflows/master-build.yml+++ b/.github/workflows/master-build.yml@@ -280,6 +280,8 @@ jobs:./build/classes/**/*.class# plugin and test class files./build/**/classes/**/*.class+ # plugin test class files (compiled into build/<plugin>/test/)+ ./build/*/test/**/*.class# dependencies./build/lib/*.jar./build/test/lib/*.jar@@ -298,6 +300,8 @@ jobs:if: always() && matrix.os == 'ubuntu-latest'with:name: coverage-data-ubuntu-jdk${{ matrix.java }}- path: ./build/coverage/*.exec+ path: |+ ./build/coverage/*.exec+ ./build/coverage/jacoco.xmlretention-days: 1if-no-files-found: ignorediff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.ymlindex ed51d67a8..b68976fd5 100644--- a/.github/workflows/sonarcloud.yml+++ b/.github/workflows/sonarcloud.yml@@ -79,9 +79,9 @@ jobs:name: junit-test-results-ubuntu-latest-jdk17workflow: master-build.ymlrun_id: ${{ github.event.workflow_run.id }}- path: |- ./build/test/TEST-*.xml- ./build/**/test/TEST-*.xml+ # Artifact has build/ stripped (upload-artifact LCA); re-root under build/+ # so paths match build/test/... and build/<plugin>/test/...+ path: ./build/continue-on-error: true- name: Flatten test reports (JDK 17 only)diff --git a/sonar-project.properties b/sonar-project.propertiesindex c8d7c8024..16e049ca8 100644--- a/sonar-project.properties+++ b/sonar-project.properties@@ -27,7 +27,7 @@ sonar.links.ci=https://github.com/apache/nutch/actionssonar.sources=src/java,src/pluginsonar.tests=src/test,src/pluginsonar.test.inclusions=**/src/test/**/*.java,**/Test*.java,**/*IT.java-sonar.exclusions=**/build.xml,**/build-ivy.xml,**/build-plugin.xml,**/ivy.xml,**/plugin.xml+sonar.exclusions=**/build.xml,**/build-ivy.xml,**/build-plugin.xml,**/ivy.xml,**/plugin.xml,**/sample/**,**/data/**,**/logs/**sonar.source.encoding=UTF-8sonar.java.source=17diff --git a/src/java/org/apache/nutch/util/StringUtil.java b/src/java/org/apache/nutch/util/StringUtil.javaindex 70e8b13b5..c8a84c298 100644--- a/src/java/org/apache/nutch/util/StringUtil.java+++ b/src/java/org/apache/nutch/util/StringUtil.java@@ -151,12 +151,12 @@ public class StringUtil {}/**- * Simple character substitution which cleans/removes all � chars from a given String.+ * Simple character substitution which cleans/removes all \uFFFD chars from a given String.* @param value the String to clean* @return substituted cleaned string*/public static String cleanField(String value) {- return value.replaceAll("�", "");+ return value.replaceAll("\uFFFD", "");}/**diff --git a/src/java/org/apache/nutch/util/TableUtil.java b/src/java/org/apache/nutch/util/TableUtil.javaindex aab01543c..bd3c5c75a 100644--- a/src/java/org/apache/nutch/util/TableUtil.java+++ b/src/java/org/apache/nutch/util/TableUtil.java@@ -146,7 +146,7 @@ public class TableUtil {}/**- * Convert given Utf8 instance to String and and cleans out any offending "�"+ * Convert given Utf8 instance to String and and cleans out any offending "\uFFFD"* from the String.**