Skip to content

Commit

Permalink
RAT-369: Add exclusions and fix TYPO in enum
Browse files Browse the repository at this point in the history
  • Loading branch information
ottlinger committed Apr 26, 2024
1 parent 10f925a commit 99cc9a0
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 33 deletions.
18 changes: 18 additions & 0 deletions apache-rat-core/spotbugs_ignore.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
3 changes: 2 additions & 1 deletion apache-rat-core/src/main/java/org/apache/rat/Reporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -76,7 +77,7 @@ public Reporter(ReportConfiguration configuration) throws RatException {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public Description(ComponentType type, String name, String desc, boolean isColle
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);
Expand Down Expand Up @@ -275,7 +275,7 @@ public Method setter(Class<?> clazz) throws NoSuchMethodException, SecurityExcep
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,12 @@ private void callSetter(Description desc, IHeaderMatcher.Builder builder, Object
}

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);
}
}
}
Expand Down Expand Up @@ -270,7 +270,7 @@ private BiPredicate<Node, Description> matcherChildNodeProcessor(AbstractBuilder
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()));
Expand Down Expand Up @@ -411,7 +411,7 @@ private BiPredicate<Node, Description> licenseChildNodeProcessor(ILicense.Builde
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ void writeDescription(IXmlWriter writer, Description description, IHeaderMatcher
}
}
break;
case BULID_PARAMETER:
case BUILD_PARAMETER:
// ignore;
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public static class IHeaderMatcherProxy implements IHeaderMatcher {
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;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 4 additions & 5 deletions apache-rat-plugin/spotbugs_ignore.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -116,7 +111,7 @@ public static boolean isComment(final String line) {
}

public List<String> getExclusionLines() {
return exclusionLines;
return Collections.unmodifiableList(exclusionLines);
}

@Override
Expand Down
9 changes: 4 additions & 5 deletions apache-rat-tasks/spotbugs_ignore.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 99cc9a0

Please sign in to comment.