You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@creadur.apache.org by po...@apache.org on 2024/04/26 13:19:35 UTC
(creadur-rat) 02/02: RAT-369: Add exclusions and fix TYPO in enum
This is an automated email from the ASF dual-hosted git repository.
pottlinger pushed a commit to branch feature/RAT-369
in repository https://gitbox.apache.org/repos/asf/creadur-rat.git
commit 99cc9a02adc4785925346a5ae9ce1f35882ecf04
Author: P. Ottlinger <po...@apache.org>
AuthorDate: Fri Apr 26 15:19:22 2024 +0200
RAT-369: Add exclusions and fix TYPO in enum
---
apache-rat-core/spotbugs_ignore.xml | 18 ++++++++++++++++++
.../java/org/apache/rat/ImplementationException.java | 2 +-
.../src/main/java/org/apache/rat/Reporter.java | 3 ++-
.../apache/rat/config/parameters/ComponentType.java | 4 ++--
.../org/apache/rat/config/parameters/Description.java | 4 ++--
.../rat/configuration/XMLConfigurationReader.java | 8 ++++----
.../rat/configuration/XMLConfigurationWriter.java | 2 +-
.../rat/configuration/builders/MatcherRefBuilder.java | 2 +-
.../java/org/apache/rat/license/SimpleLicense.java | 2 +-
apache-rat-plugin/spotbugs_ignore.xml | 9 ++++-----
.../apache/rat/mp/util/ignore/GlobIgnoreMatcher.java | 9 ++-------
apache-rat-tasks/spotbugs_ignore.xml | 9 ++++-----
.../src/main/java/org/apache/rat/anttasks/Report.java | 4 +---
13 files changed, 43 insertions(+), 33 deletions(-)
diff --git a/apache-rat-core/spotbugs_ignore.xml b/apache-rat-core/spotbugs_ignore.xml
index 3b8f1d20..abb5478d 100644
--- a/apache-rat-core/spotbugs_ignore.xml
+++ b/apache-rat-core/spotbugs_ignore.xml
@@ -23,4 +23,22 @@
<Class name="org.apache.rat.Report"/>
<Bug pattern="DM_DEFAULT_ENCODING"/>
</Match>
+ <Match>
+ <!--
+ Convenience constructors that allow setting a charset are not available in Java8 for FileWriter.
+ -->
+ <Class name="org.apache.rat.annotation.AbstractLicenseAppender"/>
+ <Bug pattern="DM_DEFAULT_ENCODING"/>
+ </Match>
+ <Match>
+ <!--
+ Convenience constructors that allow setting a charset are not available in Java8 for FileReader.
+ -->
+ <Class name="org.apache.rat.document.impl.FileDocument"/>
+ <Bug pattern="DM_DEFAULT_ENCODING"/>
+ </Match>
+ <Match>
+ <Class name="org.apache.rat.document.impl.MonolithicFileDocument"/>
+ <Bug pattern="DM_DEFAULT_ENCODING"/>
+ </Match>
</FindBugsFilter>
diff --git a/apache-rat-core/src/main/java/org/apache/rat/ImplementationException.java b/apache-rat-core/src/main/java/org/apache/rat/ImplementationException.java
index ed8deaf6..c4439383 100644
--- a/apache-rat-core/src/main/java/org/apache/rat/ImplementationException.java
+++ b/apache-rat-core/src/main/java/org/apache/rat/ImplementationException.java
@@ -19,7 +19,7 @@
package org.apache.rat;
/**
- * An exception thrown when there is an issue with the Configuration.
+ * An exception thrown when there is an issue with the configuration.
*/
public class ImplementationException extends RuntimeException {
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 69d93bb5..cd42e463 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
@@ -26,6 +26,7 @@ import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Writer;
+import java.nio.charset.StandardCharsets;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.OutputKeys;
@@ -76,7 +77,7 @@ public class Reporter {
try {
if (configuration.getReportable() != null) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- Writer outputWriter = new OutputStreamWriter(outputStream);
+ Writer outputWriter = new OutputStreamWriter(outputStream, StandardCharsets.UTF_8);
try (IXmlWriter writer = new XmlWriter(outputWriter)) {
statistic = new ClaimStatistic();
RatReport report = XmlReportFactory.createStandardReport(writer, statistic, configuration);
diff --git a/apache-rat-core/src/main/java/org/apache/rat/config/parameters/ComponentType.java b/apache-rat-core/src/main/java/org/apache/rat/config/parameters/ComponentType.java
index bdddbb57..a619e6e0 100644
--- a/apache-rat-core/src/main/java/org/apache/rat/config/parameters/ComponentType.java
+++ b/apache-rat-core/src/main/java/org/apache/rat/config/parameters/ComponentType.java
@@ -28,6 +28,6 @@ public enum ComponentType {
MATCHER,
/** A Parameter for example the "id" parameter found in every component */
PARAMETER,
- /** A parameter that is supplied by the environment. Currently systems using builders have to handle seting this. For example the list of matchers for the "MatcherRefBuilder" */
- BULID_PARAMETER
+ /** A parameter that is supplied by the environment. Currently systems using builders have to handle setting this. For example the list of matchers for the "MatcherRefBuilder" */
+ BUILD_PARAMETER
}
\ No newline at end of file
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 bbf01f3f..0e2affeb 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
@@ -80,7 +80,7 @@ public class Description {
this.desc = desc;
this.isCollection = isCollection;
this.required = required;
- if (type == ComponentType.BULID_PARAMETER) {
+ if (type == ComponentType.BUILD_PARAMETER) {
Method m;
try {
m = BuilderParams.class.getMethod(name);
@@ -275,7 +275,7 @@ public class Description {
case PARAMETER:
return clazz.getMethod(methodName,
IHeaderMatcher.class.isAssignableFrom(childClass) ? IHeaderMatcher.Builder.class : childClass);
- case BULID_PARAMETER:
+ case BUILD_PARAMETER:
return clazz.getMethod(methodName, childClass);
}
// should not happen
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 fdacc1a6..728f8587 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
@@ -231,12 +231,12 @@ public class XMLConfigurationReader implements LicenseReader, MatcherReader {
}
private void processBuilderParams(Description description, IHeaderMatcher.Builder builder) {
- for (Description desc : description.childrenOfType(ComponentType.BULID_PARAMETER)) {
+ for (Description desc : description.childrenOfType(ComponentType.BUILD_PARAMETER)) {
Method m = builderParams.get(desc.getCommonName());
try {
callSetter(desc, builder, m.invoke(builderParams));
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- ImplementationException.makeInstance(e);
+ throw ImplementationException.makeInstance(e);
}
}
}
@@ -270,7 +270,7 @@ public class XMLConfigurationReader implements LicenseReader, MatcherReader {
return (child, childDescription) -> {
switch (childDescription.getType()) {
case LICENSE:
- case BULID_PARAMETER:
+ case BUILD_PARAMETER:
throw new ConfigurationException(String.format(
"%s may not be used as an enclosed matcher. %s '%s' found in '%s'", childDescription.getType(),
childDescription.getType(), childDescription.getCommonName(), description.getCommonName()));
@@ -411,7 +411,7 @@ public class XMLConfigurationReader implements LicenseReader, MatcherReader {
throw new ConfigurationException(String.format(
"%s may not be enclosed in another license. %s '%s' found in '%s'", childDescription.getType(),
childDescription.getType(), childDescription.getCommonName(), description.getCommonName()));
- case BULID_PARAMETER:
+ case BUILD_PARAMETER:
break;
case MATCHER:
AbstractBuilder b = parseMatcher(child);
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 1beb45f6..c049dc98 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
@@ -285,7 +285,7 @@ public class XMLConfigurationWriter {
}
}
break;
- case BULID_PARAMETER:
+ case BUILD_PARAMETER:
// ignore;
break;
}
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 06624ffb..291c6f9c 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
@@ -98,7 +98,7 @@ public class MatcherRefBuilder extends AbstractBuilder {
private final String proxyId;
private IHeaderMatcher wrapped;
- @ConfigComponent(type = ComponentType.BULID_PARAMETER, name = "matcherMap", desc = "Map of matcher names to matcher instances")
+ @ConfigComponent(type = ComponentType.BUILD_PARAMETER, name = "matcherMap", desc = "Map of matcher names to matcher instances")
private Map<String, IHeaderMatcher> matchers;
/**
diff --git a/apache-rat-core/src/main/java/org/apache/rat/license/SimpleLicense.java b/apache-rat-core/src/main/java/org/apache/rat/license/SimpleLicense.java
index f8a3c7b7..a956074f 100644
--- a/apache-rat-core/src/main/java/org/apache/rat/license/SimpleLicense.java
+++ b/apache-rat-core/src/main/java/org/apache/rat/license/SimpleLicense.java
@@ -39,7 +39,7 @@ import org.apache.rat.config.parameters.DescriptionBuilder;
@ConfigComponent(type = ComponentType.LICENSE)
public class SimpleLicense implements ILicense {
- @ConfigComponent(type = ComponentType.BULID_PARAMETER, desc = "The defined license families.", name = "licenseFamilies")
+ @ConfigComponent(type = ComponentType.BUILD_PARAMETER, desc = "The defined license families.", name = "licenseFamilies")
private ILicenseFamily family;
@ConfigComponent(type = ComponentType.PARAMETER, desc = "The matcher for this license.", required = true)
diff --git a/apache-rat-plugin/spotbugs_ignore.xml b/apache-rat-plugin/spotbugs_ignore.xml
index f6a55af9..d2345cde 100644
--- a/apache-rat-plugin/spotbugs_ignore.xml
+++ b/apache-rat-plugin/spotbugs_ignore.xml
@@ -17,11 +17,10 @@
-->
<FindBugsFilter>
<Match>
- <!-- Uses tryWithResources, thus closes resource properly:
- [ERROR] Medium: org.apache.rat.configuration.builders.ChildContainerBuilder.setResource(String) may fail to close stream
- [org.apache.rat.configuration.builders.ChildContainerBuilder] At ChildContainerBuilder.java:[line 62] OS_OPEN_STREAM
+ <!--
+ Convenience constructors that allow setting a charset are not available in Java8 for FileReader.
-->
- <Class name="org.apache.rat.configuration.builders.ChildContainerBuilder"/>
- <Bug pattern="OS_OPEN_STREAM"/>
+ <Class name="org.apache.rat.mp.util.ignore.GlobIgnoreMatcher"/>
+ <Bug pattern="DM_DEFAULT_ENCODING"/>
</Match>
</FindBugsFilter>
diff --git a/apache-rat-plugin/src/main/java/org/apache/rat/mp/util/ignore/GlobIgnoreMatcher.java b/apache-rat-plugin/src/main/java/org/apache/rat/mp/util/ignore/GlobIgnoreMatcher.java
index 19ecc436..76321343 100644
--- a/apache-rat-plugin/src/main/java/org/apache/rat/mp/util/ignore/GlobIgnoreMatcher.java
+++ b/apache-rat-plugin/src/main/java/org/apache/rat/mp/util/ignore/GlobIgnoreMatcher.java
@@ -25,12 +25,7 @@ import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import java.util.Optional;
+import java.util.*;
public class GlobIgnoreMatcher implements IgnoreMatcher {
@@ -116,7 +111,7 @@ public class GlobIgnoreMatcher implements IgnoreMatcher {
}
public List<String> getExclusionLines() {
- return exclusionLines;
+ return Collections.unmodifiableList(exclusionLines);
}
@Override
diff --git a/apache-rat-tasks/spotbugs_ignore.xml b/apache-rat-tasks/spotbugs_ignore.xml
index f6a55af9..971c02aa 100644
--- a/apache-rat-tasks/spotbugs_ignore.xml
+++ b/apache-rat-tasks/spotbugs_ignore.xml
@@ -17,11 +17,10 @@
-->
<FindBugsFilter>
<Match>
- <!-- Uses tryWithResources, thus closes resource properly:
- [ERROR] Medium: org.apache.rat.configuration.builders.ChildContainerBuilder.setResource(String) may fail to close stream
- [org.apache.rat.configuration.builders.ChildContainerBuilder] At ChildContainerBuilder.java:[line 62] OS_OPEN_STREAM
+ <!--
+ Convenience constructors that allow setting a charset are not available in Java8 for PrintStream.
-->
- <Class name="org.apache.rat.configuration.builders.ChildContainerBuilder"/>
- <Bug pattern="OS_OPEN_STREAM"/>
+ <Class name="org.apache.rat.anttasks.Report"/>
+ <Bug pattern="DM_DEFAULT_ENCODING"/>
</Match>
</FindBugsFilter>
diff --git a/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Report.java b/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Report.java
index 359bc523..c3e580d5 100644
--- a/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Report.java
+++ b/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Report.java
@@ -18,9 +18,7 @@
*/
package org.apache.rat.anttasks;
-import java.io.File;
-import java.io.FilenameFilter;
-import java.io.PrintWriter;
+import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.StandardCharsets;