RAT-369: Add exclusions and fix TYPO in enum
diff --git a/apache-rat-core/spotbugs_ignore.xml b/apache-rat-core/spotbugs_ignore.xml
index 3b8f1d2..abb5478 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 ed8deaf..c443938 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 69d93bb..cd42e46 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.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 @@
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 bdddbb5..a619e6e 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 @@
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 bbf01f3..0e2affe 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 @@
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 @@
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 fdacc1a..728f858 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 @@
}
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 @@
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 @@
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 1beb45f..c049dc9 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 @@
}
}
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 06624ff..291c6f9 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 @@
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 f8a3c7b..a956074 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 @@
@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 f6a55af..d2345cd 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 19ecc43..7632134 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.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 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 f6a55af..971c02a 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 359bc52..c3e580d 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;