From b404d02d2cdd33192e84a3cb100a165176626a48 Mon Sep 17 00:00:00 2001 From: "P. Ottlinger" Date: Tue, 16 Apr 2024 22:50:57 +0200 Subject: [PATCH 01/20] RAT-369: Add spotbugs to build and generate a report --- pom.xml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/pom.xml b/pom.xml index 6090e7600..6eaf501ae 100644 --- a/pom.xml +++ b/pom.xml @@ -285,6 +285,10 @@ agnostic home for software distribution comprehension and audit tools. org.apache.rat apache-rat-plugin + + com.github.spotbugs + spotbugs-maven-plugin + @@ -297,6 +301,22 @@ agnostic home for software distribution comprehension and audit tools. if ours is different. --> + + com.github.spotbugs + spotbugs-maven-plugin + 4.8.4.0 + + + + + com.h3xstream.findsecbugs + findsecbugs-plugin + 1.13.0 + + + + org.apache.maven.plugins maven-antrun-plugin @@ -440,6 +460,10 @@ agnostic home for software distribution comprehension and audit tools. + + com.github.spotbugs + spotbugs-maven-plugin + org.apache.maven.plugins maven-antrun-plugin From b23aac3e2e5ec0666eb577ba1f30ef0de6e7b77c Mon Sep 17 00:00:00 2001 From: "P. Ottlinger" Date: Tue, 16 Apr 2024 23:02:40 +0200 Subject: [PATCH 02/20] RAT-369: Fail the build if there are any bugs --- pom.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pom.xml b/pom.xml index 6eaf501ae..d41e37681 100644 --- a/pom.xml +++ b/pom.xml @@ -316,6 +316,13 @@ agnostic home for software distribution comprehension and audit tools. + + + + check + + + org.apache.maven.plugins From 7fee5e229ccae9c1e4b7a47d099865908744e273 Mon Sep 17 00:00:00 2001 From: "P. Ottlinger" Date: Sun, 21 Apr 2024 22:20:02 +0200 Subject: [PATCH 03/20] RAT-369: Fix reliance on default encoding in some JDK8-compliant settings --- apache-rat-core/src/main/java/org/apache/rat/Report.java | 5 ++--- .../org/apache/rat/annotation/AbstractLicenseAppender.java | 3 ++- .../org/apache/rat/document/impl/ArchiveEntryDocument.java | 3 ++- .../main/java/org/apache/rat/document/impl/FileDocument.java | 4 +++- .../org/apache/rat/document/impl/MonolithicFileDocument.java | 3 ++- .../org/apache/rat/mp/util/ignore/GlobIgnoreMatcher.java | 3 ++- .../src/main/java/org/apache/rat/anttasks/Report.java | 4 ++-- .../org/apache/rat/anttasks/ResourceCollectionContainer.java | 3 ++- 8 files changed, 17 insertions(+), 11 deletions(-) diff --git a/apache-rat-core/src/main/java/org/apache/rat/Report.java b/apache-rat-core/src/main/java/org/apache/rat/Report.java index 68129735d..624c06dfe 100644 --- a/apache-rat-core/src/main/java/org/apache/rat/Report.java +++ b/apache-rat-core/src/main/java/org/apache/rat/Report.java @@ -232,7 +232,7 @@ static ReportConfiguration createConfiguration(String baseDirectory, CommandLine if (url == null) { ioSupplier = () -> Files.newInputStream(Paths.get(style[0])); } else { - ioSupplier = () -> url.openStream(); + ioSupplier = url::openStream; } configuration.setStyleSheet(ioSupplier); } @@ -285,8 +285,7 @@ static FilenameFilter parseExclusions(List excludes) { } static Options buildOptions() { - String licFilterValues = String.join(", ", - Arrays.stream(LicenseFilter.values()).map(LicenseFilter::name).collect(Collectors.toList())); + String licFilterValues = Arrays.stream(LicenseFilter.values()).map(LicenseFilter::name).collect(Collectors.joining(", ")); Options opts = new Options() diff --git a/apache-rat-core/src/main/java/org/apache/rat/annotation/AbstractLicenseAppender.java b/apache-rat-core/src/main/java/org/apache/rat/annotation/AbstractLicenseAppender.java index c1c7af9a2..0d21264dd 100644 --- a/apache-rat-core/src/main/java/org/apache/rat/annotation/AbstractLicenseAppender.java +++ b/apache-rat-core/src/main/java/org/apache/rat/annotation/AbstractLicenseAppender.java @@ -30,6 +30,7 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.Writer; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.InvalidPathException; import java.nio.file.Path; @@ -287,7 +288,7 @@ private boolean attachLicense(Writer writer, File document, BufferedReader br = null; try { fis = new FileInputStream(document); - br = new BufferedReader(new InputStreamReader(new BOMInputStream(fis))); + br = new BufferedReader(new InputStreamReader(new BOMInputStream(fis), StandardCharsets.UTF_8)); if (!expectsHashPling && !expectsAtEcho diff --git a/apache-rat-core/src/main/java/org/apache/rat/document/impl/ArchiveEntryDocument.java b/apache-rat-core/src/main/java/org/apache/rat/document/impl/ArchiveEntryDocument.java index f316fe6ee..f9b7f1743 100644 --- a/apache-rat-core/src/main/java/org/apache/rat/document/impl/ArchiveEntryDocument.java +++ b/apache-rat-core/src/main/java/org/apache/rat/document/impl/ArchiveEntryDocument.java @@ -25,6 +25,7 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; +import java.nio.charset.StandardCharsets; import org.apache.rat.api.Document; import org.apache.rat.api.MetaData; @@ -60,7 +61,7 @@ public boolean isComposite() { } public Reader reader() throws IOException { - return new InputStreamReader(new ByteArrayInputStream(contents)); + return new InputStreamReader(new ByteArrayInputStream(contents), StandardCharsets.UTF_8); } diff --git a/apache-rat-core/src/main/java/org/apache/rat/document/impl/FileDocument.java b/apache-rat-core/src/main/java/org/apache/rat/document/impl/FileDocument.java index d8d32322a..d6509bcd2 100644 --- a/apache-rat-core/src/main/java/org/apache/rat/document/impl/FileDocument.java +++ b/apache-rat-core/src/main/java/org/apache/rat/document/impl/FileDocument.java @@ -24,6 +24,8 @@ import java.io.IOException; import java.io.InputStream; import java.io.Reader; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; import org.apache.rat.api.Document; import org.apache.rat.api.MetaData; @@ -61,7 +63,7 @@ public MetaData getMetaData() { } public InputStream inputStream() throws IOException { - return new FileInputStream(file); + return Files.newInputStream(file.toPath()); } /** diff --git a/apache-rat-core/src/main/java/org/apache/rat/document/impl/MonolithicFileDocument.java b/apache-rat-core/src/main/java/org/apache/rat/document/impl/MonolithicFileDocument.java index dca7a53ef..e19c50932 100644 --- a/apache-rat-core/src/main/java/org/apache/rat/document/impl/MonolithicFileDocument.java +++ b/apache-rat-core/src/main/java/org/apache/rat/document/impl/MonolithicFileDocument.java @@ -27,6 +27,7 @@ import java.io.Reader; import java.net.URL; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; import org.apache.rat.api.Document; @@ -67,6 +68,6 @@ public Reader reader() throws IOException { } public InputStream inputStream() throws IOException { - return new FileInputStream(file); + return Files.newInputStream(file.toPath()); } } 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 de9061bd8..91ea88462 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,6 +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; @@ -77,7 +78,7 @@ public void loadFile(final Log log, final File scmIgnore) { if (scmIgnore != null && scmIgnore.exists() && scmIgnore.isFile()) { log.debug("Parsing exclusions from " + scmIgnore); - try (BufferedReader reader = new BufferedReader(new FileReader(scmIgnore))) { + try (BufferedReader reader = new BufferedReader(new FileReader(scmIgnore, StandardCharsets.UTF_8))) { String line; while ((line = reader.readLine()) != null) { if (!isComment(line)) { 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 691d9d6a3..fd2bedb02 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 @@ -23,6 +23,7 @@ import java.io.PrintWriter; import java.net.MalformedURLException; import java.net.URL; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -296,7 +297,7 @@ public LicenseSetFactory.LicenseFilter internalFilter() { private class Logger implements Log { private void write(int level, String msg) { - try (PrintWriter pw = new PrintWriter(new LogOutputStream(Report.this, level))) + try (PrintWriter pw = new PrintWriter(new LogOutputStream(Report.this, level), false, StandardCharsets.UTF_8)) { pw.write(msg); } @@ -318,7 +319,6 @@ public void log(Level level, String msg) { write(Project.MSG_ERR, msg); break; case OFF: - break; default: break; } diff --git a/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/ResourceCollectionContainer.java b/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/ResourceCollectionContainer.java index 3b24fc739..24b4012f5 100644 --- a/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/ResourceCollectionContainer.java +++ b/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/ResourceCollectionContainer.java @@ -23,6 +23,7 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; +import java.nio.charset.StandardCharsets; import org.apache.rat.api.Document; import org.apache.rat.api.MetaData; @@ -69,7 +70,7 @@ private void setResource(Resource resource) { @Override public Reader reader() throws IOException { final InputStream in = resource.getInputStream(); - return new InputStreamReader(in); + return new InputStreamReader(in, StandardCharsets.UTF_8); } @Override From 191b119bb0edc37d79ad806d0f29cc614520b9e8 Mon Sep 17 00:00:00 2001 From: "P. Ottlinger" Date: Sun, 21 Apr 2024 22:29:24 +0200 Subject: [PATCH 04/20] RAT-369: Issue errors but do not fail the build in order to work incrementally --- .../java/org/apache/rat/mp/util/ignore/GlobIgnoreMatcher.java | 2 +- .../src/main/java/org/apache/rat/anttasks/Report.java | 2 +- pom.xml | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) 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 91ea88462..19ecc436c 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 @@ -78,7 +78,7 @@ public void loadFile(final Log log, final File scmIgnore) { if (scmIgnore != null && scmIgnore.exists() && scmIgnore.isFile()) { log.debug("Parsing exclusions from " + scmIgnore); - try (BufferedReader reader = new BufferedReader(new FileReader(scmIgnore, StandardCharsets.UTF_8))) { + try (BufferedReader reader = new BufferedReader(new FileReader(scmIgnore))) { String line; while ((line = reader.readLine()) != null) { if (!isComment(line)) { 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 fd2bedb02..10414a858 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 @@ -297,7 +297,7 @@ public LicenseSetFactory.LicenseFilter internalFilter() { private class Logger implements Log { private void write(int level, String msg) { - try (PrintWriter pw = new PrintWriter(new LogOutputStream(Report.this, level), false, StandardCharsets.UTF_8)) + try (PrintWriter pw = new PrintWriter(new LogOutputStream(Report.this, level))) { pw.write(msg); } diff --git a/pom.xml b/pom.xml index d41e37681..923bb837d 100644 --- a/pom.xml +++ b/pom.xml @@ -306,6 +306,8 @@ agnostic home for software distribution comprehension and audit tools. spotbugs-maven-plugin 4.8.4.0 + + false From a9169510d667f5c9e2bcf70115fdcc2451b92091 Mon Sep 17 00:00:00 2001 From: "P. Ottlinger" Date: Sun, 21 Apr 2024 22:51:57 +0200 Subject: [PATCH 05/20] RAT-369: Ignore false positive --- pom.xml | 3 +-- spotbugs_ignore.xml | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 spotbugs_ignore.xml diff --git a/pom.xml b/pom.xml index 923bb837d..471ec421e 100644 --- a/pom.xml +++ b/pom.xml @@ -308,8 +308,7 @@ agnostic home for software distribution comprehension and audit tools. false - + spotbugs-ignore.xml com.h3xstream.findsecbugs diff --git a/spotbugs_ignore.xml b/spotbugs_ignore.xml new file mode 100644 index 000000000..f6a55af97 --- /dev/null +++ b/spotbugs_ignore.xml @@ -0,0 +1,27 @@ + + + + + + + + + From d929953b559e7fbd0a89295066d1d0228854ab58 Mon Sep 17 00:00:00 2001 From: "P. Ottlinger" Date: Sun, 21 Apr 2024 23:09:55 +0200 Subject: [PATCH 06/20] RAT-369: Fix spotbugs warning --- .../src/main/java/org/apache/rat/api/ContentType.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apache-rat-core/src/main/java/org/apache/rat/api/ContentType.java b/apache-rat-core/src/main/java/org/apache/rat/api/ContentType.java index d5a2a0ccb..d0e899112 100644 --- a/apache-rat-core/src/main/java/org/apache/rat/api/ContentType.java +++ b/apache-rat-core/src/main/java/org/apache/rat/api/ContentType.java @@ -18,6 +18,7 @@ */ package org.apache.rat.api; +import java.util.Collections; import java.util.HashMap; import java.util.Locale; import java.util.Map; @@ -72,6 +73,6 @@ public String getSubType() { * @return not null */ public Map getParameters() { - return parameters; + return Collections.unmodifiableMap(parameters); } } From 39cb8b14b63abd4a11981fc0242638d7d99d199c Mon Sep 17 00:00:00 2001 From: "P. Ottlinger" Date: Sun, 21 Apr 2024 23:10:36 +0200 Subject: [PATCH 07/20] RAT-369: Tweak config and add exclusion files in submodules --- apache-rat-core/spotbugs_ignore.xml | 27 +++++++++++++++++++++++++++ apache-rat-plugin/spotbugs_ignore.xml | 27 +++++++++++++++++++++++++++ apache-rat-tasks/spotbugs_ignore.xml | 27 +++++++++++++++++++++++++++ pom.xml | 4 +++- 4 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 apache-rat-core/spotbugs_ignore.xml create mode 100644 apache-rat-plugin/spotbugs_ignore.xml create mode 100644 apache-rat-tasks/spotbugs_ignore.xml diff --git a/apache-rat-core/spotbugs_ignore.xml b/apache-rat-core/spotbugs_ignore.xml new file mode 100644 index 000000000..f6a55af97 --- /dev/null +++ b/apache-rat-core/spotbugs_ignore.xml @@ -0,0 +1,27 @@ + + + + + + + + + diff --git a/apache-rat-plugin/spotbugs_ignore.xml b/apache-rat-plugin/spotbugs_ignore.xml new file mode 100644 index 000000000..f6a55af97 --- /dev/null +++ b/apache-rat-plugin/spotbugs_ignore.xml @@ -0,0 +1,27 @@ + + + + + + + + + diff --git a/apache-rat-tasks/spotbugs_ignore.xml b/apache-rat-tasks/spotbugs_ignore.xml new file mode 100644 index 000000000..f6a55af97 --- /dev/null +++ b/apache-rat-tasks/spotbugs_ignore.xml @@ -0,0 +1,27 @@ + + + + + + + + + diff --git a/pom.xml b/pom.xml index 471ec421e..597961d5f 100644 --- a/pom.xml +++ b/pom.xml @@ -308,7 +308,9 @@ agnostic home for software distribution comprehension and audit tools. false - spotbugs-ignore.xml + + org.apache.rat.* + ${basedir}/spotbugs_ignore.xml com.h3xstream.findsecbugs From 706732f4f51be9f66c94c727a5c5004e1bae4809 Mon Sep 17 00:00:00 2001 From: "P. Ottlinger" Date: Mon, 22 Apr 2024 00:21:53 +0200 Subject: [PATCH 08/20] RAT-369: Add tweak info about subpackage syntax --- apache-rat/spotbugs_ignore.xml | 27 +++++++++++++++++++++++++++ pom.xml | 4 ++-- 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 apache-rat/spotbugs_ignore.xml diff --git a/apache-rat/spotbugs_ignore.xml b/apache-rat/spotbugs_ignore.xml new file mode 100644 index 000000000..f6a55af97 --- /dev/null +++ b/apache-rat/spotbugs_ignore.xml @@ -0,0 +1,27 @@ + + + + + + + + + diff --git a/pom.xml b/pom.xml index 597961d5f..37d3792cb 100644 --- a/pom.xml +++ b/pom.xml @@ -308,8 +308,8 @@ agnostic home for software distribution comprehension and audit tools. false - - org.apache.rat.* + + org.apache.rat.- ${basedir}/spotbugs_ignore.xml From ab5a1270c68e12e99a2db5547bb639fbe2ea1016 Mon Sep 17 00:00:00 2001 From: "P. Ottlinger" Date: Thu, 25 Apr 2024 20:52:54 +0200 Subject: [PATCH 09/20] RAT-369: Fix whitespaces --- .../src/main/java/org/apache/rat/anttasks/Report.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 10414a858..c55d4d9e1 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 @@ -318,9 +318,9 @@ public void log(Level level, String msg) { case ERROR: write(Project.MSG_ERR, msg); break; - case OFF: - default: - break; + case OFF: + default: + break; } } From 64b1c2188037f531c6baef25f5c8ad0eb5946ff1 Mon Sep 17 00:00:00 2001 From: "P. Ottlinger" Date: Fri, 26 Apr 2024 13:00:09 +0200 Subject: [PATCH 10/20] RAT-369: Add exclusion file to fix the build in new tools submodule --- apache-rat-tools/spotbugs_ignore.xml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 apache-rat-tools/spotbugs_ignore.xml diff --git a/apache-rat-tools/spotbugs_ignore.xml b/apache-rat-tools/spotbugs_ignore.xml new file mode 100644 index 000000000..f6a55af97 --- /dev/null +++ b/apache-rat-tools/spotbugs_ignore.xml @@ -0,0 +1,27 @@ + + + + + + + + + From 10f925aec56e9e6dd295606921fa8b6acb853cdd Mon Sep 17 00:00:00 2001 From: "P. Ottlinger" Date: Fri, 26 Apr 2024 14:26:02 +0200 Subject: [PATCH 11/20] RAT-369: Add exclusion for charsets that cannot be set with Java8 --- apache-rat-core/spotbugs_ignore.xml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/apache-rat-core/spotbugs_ignore.xml b/apache-rat-core/spotbugs_ignore.xml index f6a55af97..3b8f1d208 100644 --- a/apache-rat-core/spotbugs_ignore.xml +++ b/apache-rat-core/spotbugs_ignore.xml @@ -17,11 +17,10 @@ --> - - - + + From 99cc9a02adc4785925346a5ae9ce1f35882ecf04 Mon Sep 17 00:00:00 2001 From: "P. Ottlinger" Date: Fri, 26 Apr 2024 15:19:22 +0200 Subject: [PATCH 12/20] RAT-369: Add exclusions and fix TYPO in enum --- apache-rat-core/spotbugs_ignore.xml | 18 ++++++++++++++++++ .../apache/rat/ImplementationException.java | 2 +- .../src/main/java/org/apache/rat/Reporter.java | 3 ++- .../rat/config/parameters/ComponentType.java | 4 ++-- .../rat/config/parameters/Description.java | 4 ++-- .../configuration/XMLConfigurationReader.java | 8 ++++---- .../configuration/XMLConfigurationWriter.java | 2 +- .../builders/MatcherRefBuilder.java | 2 +- .../org/apache/rat/license/SimpleLicense.java | 2 +- apache-rat-plugin/spotbugs_ignore.xml | 9 ++++----- .../rat/mp/util/ignore/GlobIgnoreMatcher.java | 9 ++------- apache-rat-tasks/spotbugs_ignore.xml | 9 ++++----- .../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 3b8f1d208..abb5478d2 100644 --- a/apache-rat-core/spotbugs_ignore.xml +++ b/apache-rat-core/spotbugs_ignore.xml @@ -23,4 +23,22 @@ + + + + + + + + + + + + + + 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 ed8deaf69..c44393830 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 69d93bb55..cd42e4639 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 @@ 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); 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 bdddbb576..a619e6e00 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 bbf01f3f1..0e2affebe 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 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); @@ -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 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 fdacc1a6f..728f8587f 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 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); } } } @@ -270,7 +270,7 @@ private BiPredicate 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())); @@ -411,7 +411,7 @@ private BiPredicate 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); 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 1beb45f6d..c049dc987 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 @@ void writeDescription(IXmlWriter writer, Description description, IHeaderMatcher } } 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 06624ffb3..291c6f9c5 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 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 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 f8a3c7b7e..a956074f0 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 f6a55af97..d2345cdef 100644 --- a/apache-rat-plugin/spotbugs_ignore.xml +++ b/apache-rat-plugin/spotbugs_ignore.xml @@ -17,11 +17,10 @@ --> - - - + + 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 19ecc436c..763213430 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 static boolean isComment(final String line) { } public List 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 f6a55af97..971c02aa9 100644 --- a/apache-rat-tasks/spotbugs_ignore.xml +++ b/apache-rat-tasks/spotbugs_ignore.xml @@ -17,11 +17,10 @@ --> - - - + + 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 359bc5237..c3e580d5b 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; From a0e9fa0d1f20883bcfbb9663d6be8f396ec15ed1 Mon Sep 17 00:00:00 2001 From: "P. Ottlinger" Date: Fri, 26 Apr 2024 15:22:10 +0200 Subject: [PATCH 13/20] RAT-369: Fix rename in module as well --- .../src/main/java/org/apache/rat/Documentation.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apache-rat-tools/src/main/java/org/apache/rat/Documentation.java b/apache-rat-tools/src/main/java/org/apache/rat/Documentation.java index 320289a97..8dc5f36ba 100644 --- a/apache-rat-tools/src/main/java/org/apache/rat/Documentation.java +++ b/apache-rat-tools/src/main/java/org/apache/rat/Documentation.java @@ -103,7 +103,7 @@ private static void printChildren(int indent, Map children, writeIndent(indent, writer); switch (d.getType()) { case PARAMETER: - case BULID_PARAMETER: + case BUILD_PARAMETER: writer.write(String.format("'%s' %s (Datatype: %s%s)%n", d.getCommonName(), d.getDescription(), d.isCollection() ? "Collection of " : "", d.getChildType().getSimpleName())); break; From eaa207180ed9274f4af38fabb270d770e04b4d97 Mon Sep 17 00:00:00 2001 From: "P. Ottlinger" Date: Wed, 1 May 2024 21:45:51 +0200 Subject: [PATCH 14/20] RAT-369: Remove examples from exclusion files in submodules --- apache-rat-tools/spotbugs_ignore.xml | 3 +-- spotbugs_ignore.xml | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/apache-rat-tools/spotbugs_ignore.xml b/apache-rat-tools/spotbugs_ignore.xml index f6a55af97..8e4ed55a0 100644 --- a/apache-rat-tools/spotbugs_ignore.xml +++ b/apache-rat-tools/spotbugs_ignore.xml @@ -20,8 +20,7 @@ - + diff --git a/spotbugs_ignore.xml b/spotbugs_ignore.xml index f6a55af97..8e4ed55a0 100644 --- a/spotbugs_ignore.xml +++ b/spotbugs_ignore.xml @@ -20,8 +20,7 @@ - + From 2136362d9f4834d6f341b5e6adc7fb6d4c9eb91e Mon Sep 17 00:00:00 2001 From: "P. Ottlinger" Date: Sat, 4 May 2024 15:55:10 +0200 Subject: [PATCH 15/20] RAT-369: Revert star-import --- .../org/apache/rat/mp/util/ignore/GlobIgnoreMatcher.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 763213430..75728013f 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,7 +25,11 @@ import java.io.File; import java.io.FileReader; import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Optional; public class GlobIgnoreMatcher implements IgnoreMatcher { From 85cb1a09f9025acc96e2efea0171c3b0089ce807 Mon Sep 17 00:00:00 2001 From: "P. Ottlinger" Date: Sat, 4 May 2024 16:01:38 +0200 Subject: [PATCH 16/20] RAT-369: Fix import --- .../java/org/apache/rat/mp/util/ignore/GlobIgnoreMatcher.java | 1 + 1 file changed, 1 insertion(+) 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 75728013f..63b2caddc 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 @@ -28,6 +28,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.Optional; From 0a62cb2ca5dbe6732522c1e4fbb7a9e92159c55e Mon Sep 17 00:00:00 2001 From: "P. Ottlinger" Date: Sat, 4 May 2024 16:04:28 +0200 Subject: [PATCH 17/20] RAT-369: Add checkstyle to build and maven site --- pom.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pom.xml b/pom.xml index aa45fefa0..a3a37d456 100644 --- a/pom.xml +++ b/pom.xml @@ -200,6 +200,10 @@ agnostic home for software distribution comprehension and audit tools. + + org.apache.maven.plugins + maven-checkstyle-plugin + org.apache.maven.plugins maven-javadoc-plugin @@ -301,6 +305,11 @@ agnostic home for software distribution comprehension and audit tools. if ours is different. --> + + org.apache.maven.plugins + maven-checkstyle-plugin + 3.3.1 + com.github.spotbugs spotbugs-maven-plugin @@ -470,6 +479,10 @@ agnostic home for software distribution comprehension and audit tools. + + org.apache.maven.plugins + maven-checkstyle-plugin + com.github.spotbugs spotbugs-maven-plugin From 7081bdd920615e94c2336498667a963abe29f78b Mon Sep 17 00:00:00 2001 From: "P. Ottlinger" Date: Sat, 4 May 2024 16:10:37 +0200 Subject: [PATCH 18/20] RAT-369: Add changelog --- src/changes/changes.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index e0b77107d..6e43a1b6a 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -72,6 +72,9 @@ https://maven.apache.org/plugins/maven-changes-plugin/xsd/changes-1.0.0.xsd --> + + Integrate checkstyle and spotbugs into the build and webpage generation. Most charset-related errors cannot be fixed until we break JDK8-compliance and move to newer versions. + Removed ReportFailedRuntimeException, ReportTransformer, RatReportAnalysisResultException, MimeTyper, ToNameTransformer, UnsuitableDocumentException, ReportTransformerTest, and ToNameTransformerTest as they are no longer used in the codebase. From 959db49e06d9e1f324c1d11e460fc1325ae02af2 Mon Sep 17 00:00:00 2001 From: "P. Ottlinger" Date: Wed, 1 May 2024 22:42:37 +0200 Subject: [PATCH 19/20] INFRA-25758: try to cleanUp the workspace via another method --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index dc08c1ce3..3a9a89f61 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -63,7 +63,7 @@ pipeline { stage('Cleanup') { steps { echo 'Cleaning up the workspace' - deleteDir() + cleanWs() } } From c807a4d0aa5f21d44b7317e9ac2e83c2bcb9d861 Mon Sep 17 00:00:00 2001 From: "P. Ottlinger" Date: Sun, 5 May 2024 15:46:18 +0200 Subject: [PATCH 20/20] RAT-369: Improve docs about why we do not fail the build and have empty exclusion files --- pom.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5d69c392a..fbdcbe396 100644 --- a/pom.xml +++ b/pom.xml @@ -315,10 +315,11 @@ agnostic home for software distribution comprehension and audit tools. spotbugs-maven-plugin 4.8.4.0 - + false org.apache.rat.- + ${basedir}/spotbugs_ignore.xml