This is an automated email from the ASF dual-hosted git repository.

Claudenw pushed a commit to branch RAT-541_create-testhelper_data-package
in repository https://gitbox.apache.org/repos/asf/creadur-rat.git


The following commit(s) were added to 
refs/heads/RAT-541_create-testhelper_data-package by this push:
     new f1ca3c40 fix spotbugs issues
f1ca3c40 is described below

commit f1ca3c40c1ce48d72af6c1910286515a7667be3f
Author: Claude Warren <[email protected]>
AuthorDate: Mon Jun 1 14:28:20 2026 +0100

    fix spotbugs issues
---
 apache-rat-core/src/main/java/org/apache/rat/Reporter.java         | 6 +++++-
 .../org/apache/rat/analysis/license/SimplePatternBasedLicense.java | 2 ++
 .../java/org/apache/rat/analysis/matchers/SimpleTextMatcher.java   | 7 +++++--
 .../main/java/org/apache/rat/config/parameters/Description.java    | 2 +-
 .../java/org/apache/rat/configuration/XMLConfigurationReader.java  | 3 +++
 .../java/org/apache/rat/configuration/XMLConfigurationWriter.java  | 6 ++++--
 .../apache/rat/configuration/builders/ChildContainerBuilder.java   | 2 +-
 .../org/apache/rat/configuration/builders/MatcherRefBuilder.java   | 4 ++++
 .../src/main/java/org/apache/rat/header/HeaderMatcher.java         | 2 ++
 apache-rat-core/src/main/java/org/apache/rat/help/Licenses.java    | 3 +++
 .../src/main/java/org/apache/rat/tools/xsd/XsdGenerator.java       | 3 +--
 apache-rat/pom.xml                                                 | 7 +++++++
 apache-rat/spotbugs-ignore.xml                                     | 4 ++++
 13 files changed, 42 insertions(+), 9 deletions(-)

diff --git a/apache-rat-core/src/main/java/org/apache/rat/Reporter.java 
b/apache-rat-core/src/main/java/org/apache/rat/Reporter.java
index 3159c926..0bc6d6d8 100644
--- a/apache-rat-core/src/main/java/org/apache/rat/Reporter.java
+++ b/apache-rat-core/src/main/java/org/apache/rat/Reporter.java
@@ -52,6 +52,8 @@ import org.w3c.dom.Document;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
 /**
  * Class that executes the report as defined in a {@link ReportConfiguration} 
and stores
  * the result for later handling.
@@ -194,6 +196,7 @@ public class Reporter {
          * @param output the output stream to write to.
          * @throws RatException on error.
          */
+        @SuppressFBWarnings({"MALICIOUS_XSLT", "XXE_DTD_TRANSFORM_FACTORY", " 
XXE_XSLT_TRANSFORM_FACTORY"})
         public void format(final IOSupplier<InputStream> stylesheet, final 
IOSupplier<OutputStream> output) throws RatException {
             TransformerFactory tf = TransformerFactory.newInstance();
             Transformer transformer;
@@ -226,6 +229,7 @@ public class Reporter {
             }
         }
 
+        @SuppressFBWarnings("EI_EXPOSE_REP2")
         public static final class Builder {
             /** The document that was generated */
             private Document document;
@@ -243,7 +247,7 @@ public class Reporter {
                 this.document = document;
                 return this;
             }
-
+            @SuppressFBWarnings("XXE_DOCUMENT")
             public Builder document(final String fileName, final DocumentName 
workingDirectory) {
                 DocumentBuilder builder;
                 try {
diff --git 
a/apache-rat-core/src/main/java/org/apache/rat/analysis/license/SimplePatternBasedLicense.java
 
b/apache-rat-core/src/main/java/org/apache/rat/analysis/license/SimplePatternBasedLicense.java
index 21a3230e..4032d01f 100644
--- 
a/apache-rat-core/src/main/java/org/apache/rat/analysis/license/SimplePatternBasedLicense.java
+++ 
b/apache-rat-core/src/main/java/org/apache/rat/analysis/license/SimplePatternBasedLicense.java
@@ -20,6 +20,7 @@ package org.apache.rat.analysis.license;
 
 import java.util.Arrays;
 
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import org.apache.rat.DeprecationReporter;
 import org.apache.rat.configuration.builders.AbstractBuilder;
 import org.apache.rat.configuration.builders.AnyBuilder;
@@ -31,6 +32,7 @@ import org.apache.rat.license.ILicense;
  * @since Rat 0.8
  * @deprecated Use new configuration options
  */
+@SuppressFBWarnings("EI_EXPOSE_REP2")
 @Deprecated // Since 0.16
 @DeprecationReporter.Info(since = "0.16", forRemoval = true, use = "new 
configuration options")
 public class SimplePatternBasedLicense  extends BaseLicense {
diff --git 
a/apache-rat-core/src/main/java/org/apache/rat/analysis/matchers/SimpleTextMatcher.java
 
b/apache-rat-core/src/main/java/org/apache/rat/analysis/matchers/SimpleTextMatcher.java
index c77ddf09..2a5d46b5 100644
--- 
a/apache-rat-core/src/main/java/org/apache/rat/analysis/matchers/SimpleTextMatcher.java
+++ 
b/apache-rat-core/src/main/java/org/apache/rat/analysis/matchers/SimpleTextMatcher.java
@@ -23,6 +23,8 @@ import org.apache.rat.analysis.IHeaders;
 import org.apache.rat.config.parameters.ComponentType;
 import org.apache.rat.config.parameters.ConfigComponent;
 
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
 /**
  * A simple text matching IHeaderMatcher implementation.
  */
@@ -44,11 +46,12 @@ public class SimpleTextMatcher extends 
AbstractHeaderMatcher {
         this(null, simpleText);
     }
 
+    // no sonar and supress FI_USELESS because this is how we ensure that the 
finalize bug does not bite us
+    @SuppressFBWarnings("FI_USELESS")
     @Override
     protected final void finalize() throws Throwable { // NOSONAR
-        // no sonar because this is how we ensure that the finalize bug does 
not bite us
+        // finalizer attack remediation.
         super.finalize(); // NOSONAR
-      // finalizer attack remediation.
     }
 
     /**
diff --git 
a/apache-rat-core/src/main/java/org/apache/rat/config/parameters/Description.java
 
b/apache-rat-core/src/main/java/org/apache/rat/config/parameters/Description.java
index 6aa20bd3..a4e579da 100644
--- 
a/apache-rat-core/src/main/java/org/apache/rat/config/parameters/Description.java
+++ 
b/apache-rat-core/src/main/java/org/apache/rat/config/parameters/Description.java
@@ -37,7 +37,7 @@ import static java.lang.String.format;
 /**
  * A description of a component.
  */
-public class Description {
+public final class Description {
     /** The type of component this describes */
     private final ComponentType type;
     /**
diff --git 
a/apache-rat-core/src/main/java/org/apache/rat/configuration/XMLConfigurationReader.java
 
b/apache-rat-core/src/main/java/org/apache/rat/configuration/XMLConfigurationReader.java
index 51ef1c1a..63055800 100644
--- 
a/apache-rat-core/src/main/java/org/apache/rat/configuration/XMLConfigurationReader.java
+++ 
b/apache-rat-core/src/main/java/org/apache/rat/configuration/XMLConfigurationReader.java
@@ -63,6 +63,8 @@ import org.w3c.dom.NodeList;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
 /**
  * A class that reads the XML configuration file format.
  */
@@ -624,6 +626,7 @@ public final class XMLConfigurationReader implements 
LicenseReader, MatcherReade
         nodeListConsumer(document.getElementsByTagName(XMLConfig.MATCHER), 
this::parseMatcherBuilder);
     }
 
+    @SuppressFBWarnings("URLCONNECTION_SSRF_FD")
     @Override
     public void addMatchers(final URI uri) {
         read(uri);
diff --git 
a/apache-rat-core/src/main/java/org/apache/rat/configuration/XMLConfigurationWriter.java
 
b/apache-rat-core/src/main/java/org/apache/rat/configuration/XMLConfigurationWriter.java
index 79e7da99..fb9ec018 100644
--- 
a/apache-rat-core/src/main/java/org/apache/rat/configuration/XMLConfigurationWriter.java
+++ 
b/apache-rat-core/src/main/java/org/apache/rat/configuration/XMLConfigurationWriter.java
@@ -44,6 +44,8 @@ import org.apache.rat.license.LicenseSetFactory.LicenseFilter;
 import org.apache.rat.report.xml.writer.IXmlWriter;
 import org.apache.rat.report.xml.writer.XmlWriter;
 
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
 /**
  * Writes the XML configuration file format.
  */
@@ -59,6 +61,7 @@ public class XMLConfigurationWriter {
      * Constructor
      * @param configuration the configuration information to write.
      */
+    @SuppressFBWarnings("EI_EXPOSE_REP2")
     public XMLConfigurationWriter(final ReportConfiguration configuration) {
         this.configuration = configuration;
         this.matchers = new HashSet<>();
@@ -126,9 +129,8 @@ public class XMLConfigurationWriter {
                 writer.closeElement(); // APPROVED
 
                 // matchers section
-                MatcherBuilderTracker tracker = 
MatcherBuilderTracker.instance();
                 writer.openElement(XMLConfig.MATCHERS);
-                for (Class<?> clazz : tracker.getClasses()) {
+                for (Class<?> clazz : 
MatcherBuilderTracker.instance().getClasses()) {
                     
writer.openElement(XMLConfig.MATCHER).attribute(XMLConfig.ATT_CLASS_NAME, 
clazz.getCanonicalName())
                             .closeElement();
                 }
diff --git 
a/apache-rat-core/src/main/java/org/apache/rat/configuration/builders/ChildContainerBuilder.java
 
b/apache-rat-core/src/main/java/org/apache/rat/configuration/builders/ChildContainerBuilder.java
index d40a657d..172314fb 100644
--- 
a/apache-rat-core/src/main/java/org/apache/rat/configuration/builders/ChildContainerBuilder.java
+++ 
b/apache-rat-core/src/main/java/org/apache/rat/configuration/builders/ChildContainerBuilder.java
@@ -59,7 +59,7 @@ public abstract class ChildContainerBuilder extends 
AbstractBuilder {
      */
     public AbstractBuilder setResource(final String resourceName) {
         // this method is called by reflection
-        URL url = this.getClass().getResource(resourceName);
+        URL url = AbstractBuilder.class.getResource(resourceName);
         if (url == null) {
             throw new ConfigurationException("Unable to read matching text 
file: " + resourceName);
         }
diff --git 
a/apache-rat-core/src/main/java/org/apache/rat/configuration/builders/MatcherRefBuilder.java
 
b/apache-rat-core/src/main/java/org/apache/rat/configuration/builders/MatcherRefBuilder.java
index 68598d4c..1662220f 100644
--- 
a/apache-rat-core/src/main/java/org/apache/rat/configuration/builders/MatcherRefBuilder.java
+++ 
b/apache-rat-core/src/main/java/org/apache/rat/configuration/builders/MatcherRefBuilder.java
@@ -27,6 +27,8 @@ import org.apache.rat.config.parameters.ComponentType;
 import org.apache.rat.config.parameters.ConfigComponent;
 import org.apache.rat.config.parameters.MatcherBuilder;
 
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
 /**
  * A reference matching Matcher builder.
  * <p>
@@ -62,6 +64,7 @@ public class MatcherRefBuilder extends AbstractBuilder {
      * @param matchers the Map of ids to instances.
      * @return this builder for chaining.
      */
+    @SuppressFBWarnings(value = "EI_EXPOSE_REP2", justification = "Expected 
external update of matchers.")
     public MatcherRefBuilder setMatcherMap(final Map<String, IHeaderMatcher> 
matchers) {
         // this method is called by reflection
         this.matchers = matchers;
@@ -109,6 +112,7 @@ public class MatcherRefBuilder extends AbstractBuilder {
          * @param proxyId the id of the matcher to find.
          * @param matchers a mapping of matchers that have been found.
          */
+        @SuppressFBWarnings(value = "EI_EXPOSE_REP2", justification = 
"Expected external update of matchers.")
         public IHeaderMatcherProxy(final String proxyId, final Map<String, 
IHeaderMatcher> matchers) {
             this.proxyId = proxyId;
             this.matchers = matchers;
diff --git 
a/apache-rat-core/src/main/java/org/apache/rat/header/HeaderMatcher.java 
b/apache-rat-core/src/main/java/org/apache/rat/header/HeaderMatcher.java
index 89b71b0a..7f05afa3 100644
--- a/apache-rat-core/src/main/java/org/apache/rat/header/HeaderMatcher.java
+++ b/apache-rat-core/src/main/java/org/apache/rat/header/HeaderMatcher.java
@@ -18,6 +18,7 @@
  */ 
 package org.apache.rat.header;
 
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import org.apache.rat.DeprecationReporter;
 
 import java.io.IOException;
@@ -35,6 +36,7 @@ import java.util.regex.Pattern;
  * <p><strong>Note:</strong> use only from a single thread.</p>
  *
  */
+@SuppressFBWarnings("EI_EXPOSE_REP2")
 @Deprecated // since 0.17
 @DeprecationReporter.Info(since = "0.17", forRemoval = true)
 public class HeaderMatcher {
diff --git a/apache-rat-core/src/main/java/org/apache/rat/help/Licenses.java 
b/apache-rat-core/src/main/java/org/apache/rat/help/Licenses.java
index 0277186b..bac55af5 100644
--- a/apache-rat-core/src/main/java/org/apache/rat/help/Licenses.java
+++ b/apache-rat-core/src/main/java/org/apache/rat/help/Licenses.java
@@ -43,6 +43,8 @@ import org.apache.rat.license.ILicense;
 import org.apache.rat.license.ILicenseFamily;
 import org.apache.rat.license.LicenseSetFactory.LicenseFilter;
 
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
 import static java.lang.String.format;
 
 /**
@@ -64,6 +66,7 @@ public final class Licenses extends AbstractHelp {
      * @param config The configuration that contains the license information.
      * @param writer the writer to write the report to.
      */
+    @SuppressFBWarnings("EI_EXPOSE_REP2")
     public Licenses(final ReportConfiguration config, final Writer writer) {
         this.config = config;
         this.licenses = config.getLicenses(LicenseFilter.ALL);
diff --git 
a/apache-rat-tools/src/main/java/org/apache/rat/tools/xsd/XsdGenerator.java 
b/apache-rat-tools/src/main/java/org/apache/rat/tools/xsd/XsdGenerator.java
index 68437fed..5f466cb0 100644
--- a/apache-rat-tools/src/main/java/org/apache/rat/tools/xsd/XsdGenerator.java
+++ b/apache-rat-tools/src/main/java/org/apache/rat/tools/xsd/XsdGenerator.java
@@ -179,11 +179,10 @@ public class XsdGenerator {
     }
 
     private void writeMatcherElements() throws IOException {
-        MatcherBuilderTracker tracker = MatcherBuilderTracker.instance();
         writer.open(Type.ELEMENT, "name", XMLConfig.MATCHER, "abstract", 
"true").close(Type.ELEMENT);
 
         // matchers
-        for (Class<?> clazz : tracker.getClasses()) {
+        for (Class<?> clazz : MatcherBuilderTracker.instance().getClasses()) {
             Description desc = DescriptionBuilder.buildMap(clazz);
             if (desc != null) {
                 boolean hasResourceAttr = false;
diff --git a/apache-rat/pom.xml b/apache-rat/pom.xml
index f915d7b0..8b4ea0f6 100644
--- a/apache-rat/pom.xml
+++ b/apache-rat/pom.xml
@@ -48,6 +48,13 @@
   </dependencies>
   <build>
     <plugins>
+      <plugin>
+        <groupId>com.github.spotbugs</groupId>
+        <artifactId>spotbugs-maven-plugin</artifactId>
+        <configuration>
+          <excludeFilterFile>spotbugs-ignore.xml</excludeFilterFile>
+        </configuration>
+      </plugin>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-source-plugin</artifactId>
diff --git a/apache-rat/spotbugs-ignore.xml b/apache-rat/spotbugs-ignore.xml
index 085293a2..b0a2af2a 100644
--- a/apache-rat/spotbugs-ignore.xml
+++ b/apache-rat/spotbugs-ignore.xml
@@ -24,6 +24,10 @@
     <Bug pattern='EI_EXPOSE_REP'/>
   </Match>
 
+  <Match>
+    <Bug pattern='EI_EXPOSE_REP2'/>
+  </Match>q
+
   <Match>
     <Class name="org.apache.rat.configuration.XMLConfigurationReader"/>
     <Bug pattern='XXE_DOCUMENT'/>

Reply via email to