diff --git a/.asf.yaml b/.asf.yaml index bed161dbf..5d096ba6f 100644 --- a/.asf.yaml +++ b/.asf.yaml @@ -13,5 +13,6 @@ github: - RAT - WHISKER - TENTACLES + notifications: - commits: commits@creadur.apache.org + commits: commits@creadur.apache.org diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 593c3afa0..b5f7b2ddf 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -24,7 +24,7 @@ on: pull_request: env: - DEVELOCITY_ACCESS_KEY: ${{ secrets.GE_ACCESS_TOKEN }} + DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }} jobs: build: diff --git a/.mvn/develocity.xml b/.mvn/develocity.xml index 207fab6bc..219142c94 100644 --- a/.mvn/develocity.xml +++ b/.mvn/develocity.xml @@ -3,8 +3,9 @@ + creadur-rat - https://ge.apache.org + https://develocity.apache.org false diff --git a/.mvn/extensions.xml b/.mvn/extensions.xml index fefea687c..feb10816a 100644 --- a/.mvn/extensions.xml +++ b/.mvn/extensions.xml @@ -3,7 +3,7 @@ com.gradle develocity-maven-extension - 1.23 + 1.23.1 com.gradle diff --git a/README.md b/README.md index 7cee811db..7b7029c63 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ASF Jenkins: [![ASF Jenkins Build Status](https://ci-builds.apache.org/buildStat GA: [![Github Action master branch status](https://github.com/apache/creadur-rat/actions/workflows/maven.yml/badge.svg?branch=master)](https://github.com/apache/creadur-rat/actions) -[![Revved up by Develocity](https://img.shields.io/badge/Revved%20up%20by-Develocity-06A0CE?logo=Gradle&labelColor=02303A)](https://ge.apache.org/scans?list.sortColumn=buildDuration&list.sortOrder=asc&search.buildToolType=maven&search.names=not:CI%20stage&search.rootProjectNames=Apache%20Creadur%20Rat&search.tasks=install&search.timeZoneId=Europe%2FBerlin&search.values=Build%20Parent-pom) +[![Revved up by Develocity](https://img.shields.io/badge/Revved%20up%20by-Develocity-06A0CE?logo=Gradle&labelColor=02303A)](https://develocity.apache.org/scans?list.sortColumn=buildDuration&list.sortOrder=asc&search.buildToolType=maven&search.names=not:CI%20stage&search.rootProjectNames=Apache%20Creadur%20Rat&search.tasks=install&search.timeZoneId=Europe%2FBerlin&search.values=Build%20Parent-pom) ## What is RAT? diff --git a/apache-rat-core/src/main/java/org/apache/rat/api/Document.java b/apache-rat-core/src/main/java/org/apache/rat/api/Document.java index 3e29eb350..0dbfa10cf 100644 --- a/apache-rat-core/src/main/java/org/apache/rat/api/Document.java +++ b/apache-rat-core/src/main/java/org/apache/rat/api/Document.java @@ -52,7 +52,7 @@ public enum Type { } /** The path matcher used by this document */ - protected final DocumentNameMatcher nameExcluder; + protected final DocumentNameMatcher nameMatcher; /** The metadata for this document */ private final MetaData metaData; /** The fully qualified name of this document */ @@ -61,11 +61,11 @@ public enum Type { /** * Creates an instance. * @param name the native NameSet of the resource. - * @param nameExcluder the document name matcher to filter directories/files. + * @param nameMatcher the document name matcher to filter directories/files. */ - protected Document(final DocumentName name, final DocumentNameMatcher nameExcluder) { + protected Document(final DocumentName name, final DocumentNameMatcher nameMatcher) { this.name = name; - this.nameExcluder = nameExcluder; + this.nameMatcher = nameMatcher; this.metaData = new MetaData(); } @@ -81,8 +81,8 @@ public final DocumentName getName() { * Gets the file filter this document was created with. * @return the file filter this document was created with. */ - public final DocumentNameMatcher getNameExcluder() { - return nameExcluder; + public final DocumentNameMatcher getNameMatcher() { + return nameMatcher; } @Override diff --git a/apache-rat-core/src/main/java/org/apache/rat/commandline/ArgumentContext.java b/apache-rat-core/src/main/java/org/apache/rat/commandline/ArgumentContext.java index b69c5b7f8..ea672bc8d 100644 --- a/apache-rat-core/src/main/java/org/apache/rat/commandline/ArgumentContext.java +++ b/apache-rat-core/src/main/java/org/apache/rat/commandline/ArgumentContext.java @@ -87,7 +87,7 @@ public CommandLine getCommandLine() { /** * Gets the directory name from which relative file names will be resolved. - * @return The directory name from which releative file names will be resolved. + * @return The directory name from which relative file names will be resolved. */ public DocumentName getWorkingDirectory() { return workingDirectory; diff --git a/apache-rat-core/src/main/java/org/apache/rat/config/exclusion/ExclusionUtils.java b/apache-rat-core/src/main/java/org/apache/rat/config/exclusion/ExclusionUtils.java index 3f082336a..7932db4f6 100644 --- a/apache-rat-core/src/main/java/org/apache/rat/config/exclusion/ExclusionUtils.java +++ b/apache-rat-core/src/main/java/org/apache/rat/config/exclusion/ExclusionUtils.java @@ -62,7 +62,7 @@ private ExclusionUtils() { * Creates predicate that filters out comment and blank lines. Leading spaces are removed and * if the line then starts with a commentPrefix string it is considered a comment and will be removed * - * @param commentPrefixes the list of comment prefixes + * @param commentPrefixes the list of comment prefixes. * @return the Predicate that returns false for lines that start with commentPrefixes or are empty. */ public static Predicate commentFilter(final Iterable commentPrefixes) { @@ -108,7 +108,7 @@ public static Predicate commentFilter(final String commentPrefix) { /** * Create a FileFilter from a PathMatcher. * @param parent the document name for the parent of the file to be filtered. - * @param nameMatcher the path matcher to convert + * @param nameMatcher the path matcher to convert. * @return a FileFilter. */ public static FileFilter asFileFilter(final DocumentName parent, final DocumentNameMatcher nameMatcher) { @@ -119,7 +119,7 @@ public static FileFilter asFileFilter(final DocumentName parent, final DocumentN * Creates an iterator of Strings from a file of patterns. * Removes comment lines. * @param patternFile the file to read. - * @param commentFilters A predicate return true for non-comment lines + * @param commentFilters A predicate returning {@code true} for non-comment lines. * @return the iterable of Strings from the file. */ public static ExtendedIterator asIterator(final File patternFile, final Predicate commentFilters) { @@ -147,7 +147,7 @@ public static Iterable asIterable(final File patternFile, final String c * Creates an iterable of Strings from a file of patterns. * Removes comment lines. * @param patternFile the file to read. - * @param commentFilters A predicate returning true for non-comment lines + * @param commentFilters A predicate returning {@code true} for non-comment lines. * @return the iterable of Strings from the file. */ public static Iterable asIterable(final File patternFile, final Predicate commentFilters) { @@ -171,9 +171,9 @@ protected boolean isValidLine(final String line) { } /** - * Returns {@code true} if the file name represents a hidden file + * Returns {@code true} if the file name represents a hidden file. * @param f the file to check. - * @return true if it is the name of a hidden file. + * @return {@code true} if it is the name of a hidden file. */ public static boolean isHidden(final File f) { String s = f.getName(); @@ -188,7 +188,7 @@ private static void verifyFile(final File file) { /** * Tokenizes the string based on the directory separator. - * @param source the source to tokenize + * @param source the source to tokenize. * @param from the directory separator for the source. * @param to the directory separator for the result. * @return the source string with the separators converted. diff --git a/apache-rat-core/src/main/java/org/apache/rat/config/exclusion/plexus/MatchPattern.java b/apache-rat-core/src/main/java/org/apache/rat/config/exclusion/plexus/MatchPattern.java index 08732de7e..11b71445d 100644 --- a/apache-rat-core/src/main/java/org/apache/rat/config/exclusion/plexus/MatchPattern.java +++ b/apache-rat-core/src/main/java/org/apache/rat/config/exclusion/plexus/MatchPattern.java @@ -85,7 +85,7 @@ boolean matchPath(final String str, final char[][] strDirs, final boolean isCase result = SelectorUtils.matchAntPathPattern(getTokenizedPathChars(), strDirs, isCaseSensitive); } if (result && DefaultLog.getInstance().isEnabled(Log.Level.DEBUG)) { - DefaultLog.getInstance().debug(format("%s match %s -> %s", this, str, result)); + DefaultLog.getInstance().debug(format("%s match %s -> true", this, str)); } return result; } @@ -141,5 +141,4 @@ static char[][] tokenizePathToCharArray(final String path, final String separato } return tokenizedNameChar; } - } diff --git a/apache-rat-core/src/main/java/org/apache/rat/config/exclusion/plexus/MatchPatterns.java b/apache-rat-core/src/main/java/org/apache/rat/config/exclusion/plexus/MatchPatterns.java index 9a6d443e4..06c4672d6 100644 --- a/apache-rat-core/src/main/java/org/apache/rat/config/exclusion/plexus/MatchPatterns.java +++ b/apache-rat-core/src/main/java/org/apache/rat/config/exclusion/plexus/MatchPatterns.java @@ -59,7 +59,7 @@ public Iterable patterns() { *

Uses far less string tokenization than any of the alternatives.

* * @param name The name to look for - * @param isCaseSensitive If the comparison is case sensitive + * @param isCaseSensitive If the comparison is case-sensitive * @return true if any of the supplied patterns match */ public boolean matches(final String name, final boolean isCaseSensitive) { diff --git a/apache-rat-core/src/main/java/org/apache/rat/document/ArchiveEntryName.java b/apache-rat-core/src/main/java/org/apache/rat/document/ArchiveEntryName.java index 889a7b165..99bdcc451 100644 --- a/apache-rat-core/src/main/java/org/apache/rat/document/ArchiveEntryName.java +++ b/apache-rat-core/src/main/java/org/apache/rat/document/ArchiveEntryName.java @@ -24,7 +24,7 @@ import java.util.Collections; public class ArchiveEntryName extends DocumentName { - /** Then name of the document that contains this entry */ + /** The name of the document that contains this entry. */ private final DocumentName archiveFileName; private static DocumentName.Builder prepareBuilder(final DocumentName archiveFileName, final String archiveEntryName) { diff --git a/apache-rat-core/src/main/java/org/apache/rat/document/DocumentName.java b/apache-rat-core/src/main/java/org/apache/rat/document/DocumentName.java index 9b0c6a0d9..d5cc1126c 100644 --- a/apache-rat-core/src/main/java/org/apache/rat/document/DocumentName.java +++ b/apache-rat-core/src/main/java/org/apache/rat/document/DocumentName.java @@ -43,11 +43,11 @@ * The name for a document. The {@code DocumentName} is an immutable structure that handles all the intricacies of file * naming on various operating systems. DocumentNames have several components: *
    - *
  • {@code root} - Where in the file system the name starts (e.g C: on windows). May be empty but not null.
  • + *
  • {@code root} - where in the file system the name starts (e.g C: on windows). May be empty but not null.
  • *
  • {@code dirSeparator} - the separator between name segments (e.g. "\\" on windows, "/" on linux). May not be * empty or null.
  • - *
  • {@code name} - The name of the file relative to the {@code root}. May not be null. Does NOT begin with a {@code dirSeparator}
  • - *
  • {@code baseName} - The name of a directory or file from which this file is reported. A DocumentName with a + *
  • {@code name} - the name of the file relative to the {@code root}. May not be null. Does NOT begin with a {@code dirSeparator}
  • + *
  • {@code baseName} - the name of a directory or file from which this file is reported. A DocumentName with a * {@code name} of "foo/bar/baz.txt" and a {@code baseName} of "foo" will be reported as "bar/baz.txt". May not be null.
  • *
  • {@code isCaseSensitive} - identifies if the underlying file system is case-sensitive.
  • *
@@ -60,7 +60,6 @@ public class DocumentName implements Comparable { /** The full name for the document. */ private final String name; /** The name of the base directory for the document. */ - //private final String baseName; private final DocumentName baseName; /** The file system info for this document. */ private final FSInfo fsInfo; @@ -133,7 +132,7 @@ public static Builder builder(final FileSystem fileSystem) { } /** - * Creates a builder from a File. The {@link #baseName} is set to the file name if it is a directory otherwise + * Creates a builder from a File. The {@link #baseName} is set to the file name if it is a directory otherwise * it is set to the directory containing the file. * @param file The file to set defaults from. * @return the Builder. @@ -172,15 +171,15 @@ public File asFile() { /** * Creates a path from the document name. - * @return an new Path object. + * @return a new Path object. */ public Path asPath() { return Paths.get(name); } /** - * Creates a new DocumentName by adding the child to the current name. Resulting documentName will - * have the same base name. + * Creates a new DocumentName by adding the child to the current name. + * Resulting documentName will have the same base name. * @param child the child to add (must use directory separator from this document name). * @return the new document name with the same {@link #baseName}, directory sensitivity and case sensitivity as * this one. @@ -242,10 +241,10 @@ public String getDirectorySeparator() { /** * Determines if the candidate starts with the root or separator strings. - * @param candidate the candidate ot check. If blank method will return false. + * @param candidate the candidate ot check. If blank method will return {@code false}. * @param root the root to check. If blank the root check is skipped. * @param separator the separator to check. If blank the check is skipped. - * @return true if either the root or separator check returned true. + * @return true if either the root or separator check returned {@code true}. */ boolean startsWithRootOrSeparator(final String candidate, final String root, final String separator) { if (StringUtils.isBlank(candidate)) { @@ -338,16 +337,16 @@ public int hashCode() { } /** - * The File system information needed to process document names. + * The file system information needed to process document names. */ public static class FSInfo implements Comparable { - /** The common name for the file system this Info represents */ + /** The common name for the file system this Info represents. */ private final String name; - /** The separator between directory names */ + /** The separator between directory names. */ private final String separator; /** The case-sensitivity flag. */ private final boolean isCaseSensitive; - /** The list of roots for the file system */ + /** The list of roots for the file system. */ private final List roots; public static FSInfo getDefault() { @@ -384,8 +383,9 @@ public FSInfo(final String name, final FileSystem fileSystem) { public String toString() { return name; } + /** - * Constructor for virtual/abstract file systems for example the entry names within an an archive. + * Constructor for virtual/abstract file systems for example the entry names within an archive. * @param separator the separator string to use. * @param isCaseSensitive the case-sensitivity flag. * @param roots the roots for the file system. @@ -429,7 +429,7 @@ public Optional rootFor(final String name) { /** * Tokenizes the string based on the directory separator of this DocumentName. - * @param source the source to tokenize + * @param source the source to tokenize. * @return the array of tokenized strings. */ public String[] tokenize(final String source) { @@ -437,7 +437,7 @@ public String[] tokenize(final String source) { } /** - * Removes "." and ".." from filenames names. + * Removes {@code .} and {@code ..} from filenames. * @param pattern the file name pattern * @return the normalized file name. */ @@ -450,7 +450,7 @@ public String normalize(final String pattern) { String part = parts.get(i); if (part.equals("..")) { if (i == 0) { - throw new IllegalStateException("can not creat path before root"); + throw new IllegalStateException("Unable to create path before root"); } parts.set(i - 1, null); parts.set(i, null); @@ -481,15 +481,15 @@ public int hashCode() { * The Builder for a DocumentName. */ public static final class Builder { - /** The name for the document */ + /** The name for the document. */ private String name; - /** The base name for the document */ + /** The base name for the document. */ private DocumentName baseName; - /** The file system info */ + /** The file system info. */ private final FSInfo fsInfo; - /** The file system root */ + /** The file system root. */ private String root; - /** A flag for baseName same as this */ + /** A flag for baseName same as this. */ private boolean sameNameFlag; /** @@ -517,9 +517,9 @@ private Builder(final File file) { } /** - * Used in testing + * Used in testing. * @param fsInfo the FSInfo for the file. - * @param file the file to process + * @param file the file to process. */ Builder(final FSInfo fsInfo, final File file) { this(fsInfo); @@ -549,12 +549,12 @@ public String directorySeparator() { * Verify that the builder will build a proper DocumentName. */ private void verify() { - Objects.requireNonNull(name, "Name cannot be null"); + Objects.requireNonNull(name, "Name must not be null"); if (name.startsWith(fsInfo.dirSeparator())) { name = name.substring(fsInfo.dirSeparator().length()); } if (!sameNameFlag) { - Objects.requireNonNull(baseName, "Basename cannot be null"); + Objects.requireNonNull(baseName, "Basename must not be null"); } } @@ -569,13 +569,13 @@ public Builder setRoot(final String root) { } /** - * Sets the name for this DocumentName relative to the baseName. If the {@code name} is null - * an empty string is used. + * Sets the name for this DocumentName relative to the baseName. + * If the {@code name} is {@code null} an empty string is used. *

* To correctly parse the string it must use the directory separator specified by * this Document. *

- * @param name the name for this Document name. Will be made relative to the baseName + * @param name the name for this Document name. Will be made relative to the baseName. * @return this */ public Builder setName(final String name) { @@ -629,7 +629,7 @@ private void setEmptyRoot(final String root) { } /** - * Sets the properties from the file. Will reset the baseName appropraitly. + * Sets the properties from the file. Will reset the baseName appropriately. * @param file the file to set the properties from. * @return this. */ diff --git a/apache-rat-core/src/main/java/org/apache/rat/document/DocumentNameMatcher.java b/apache-rat-core/src/main/java/org/apache/rat/document/DocumentNameMatcher.java index 0e66b19f7..6b3c31bd0 100644 --- a/apache-rat-core/src/main/java/org/apache/rat/document/DocumentNameMatcher.java +++ b/apache-rat-core/src/main/java/org/apache/rat/document/DocumentNameMatcher.java @@ -45,7 +45,7 @@ public final class DocumentNameMatcher { private final Predicate predicate; /** The name of this matcher. */ private final String name; - /** {@code true} this this matcher is a collection of matchers */ + /** {@code true} if this matcher is a collection of matchers. */ private final boolean isCollection; /** @@ -90,8 +90,8 @@ public DocumentNameMatcher(final String name, final MatchPatterns patterns, fina /** * Tokenizes name for faster Matcher processing. - * @param name the name to tokenize - * @param dirSeparator the directory separator + * @param name the name to tokenize. + * @param dirSeparator the directory separator. * @return the tokenized name. */ private static char[][] tokenize(final String name, final String dirSeparator) { @@ -161,7 +161,7 @@ public String toString() { /** * Decomposes the matcher execution against the candidate. - * @param candidate the candiate to check. + * @param candidate the candidate to check. * @return a list of {@link DecomposeData} for each evaluation in the matcher. */ public List decompose(final DocumentName candidate) { @@ -315,15 +315,13 @@ public static DocumentNameMatcher and(final DocumentNameMatcher... matchers) { return and(Arrays.asList(matchers)); } - - /** - * A DocumentName predicate that uses MatchPatterns. + * A DocumentName predicate that uses {@link MatchPatterns}. */ public static final class MatchPatternsPredicate implements Predicate { - /** The base diirectory for the pattern matches */ + /** The base directory for the pattern matches. */ private final DocumentName basedir; - /** The patter matchers */ + /** The pattern matchers. */ private final MatchPatterns patterns; private MatchPatternsPredicate(final DocumentName basedir, final MatchPatterns patterns) { @@ -345,7 +343,7 @@ public String toString() { } /** - * A DocumentName predicate reverses another DocumentNameMatcher + * A DocumentName predicate that reverses another DocumentNameMatcher. */ public static final class NotPredicate implements Predicate { /** The document name matcher to reverse */ @@ -367,10 +365,10 @@ public String toString() { } /** - * A DocumentName predicate that uses FileFilter. + * A DocumentName predicate that uses {@link FileFilter}. */ public static final class FileFilterPredicate implements Predicate { - /** The file filter */ + /** The file filter. */ private final FileFilter fileFilter; private FileFilterPredicate(final FileFilter fileFilter) { @@ -388,19 +386,23 @@ public String toString() { } } + /** + * A marker interface to indicate this predicate contains a collection of matchers. + */ interface CollectionPredicate extends Predicate { Iterable getMatchers(); } + /** - * A marker interface to indicate this predicate contains a collection of matchers. + * A marker class to indicate this predicate contains a collection of matchers. */ abstract static class CollectionPredicateImpl implements CollectionPredicate { /** The collection for matchers that make up this predicate */ private final Iterable matchers; /** - * Constructs a collecton predicate from the collection of matchers - * @param matchers the colleciton of matchers to use. + * Constructs a collection predicate from the collection of matchers. + * @param matchers the collection of matchers to use. */ protected CollectionPredicateImpl(final Iterable matchers) { this.matchers = matchers; @@ -414,6 +416,7 @@ public Iterable getMatchers() { return matchers; } + @Override public String toString() { StringBuilder builder = new StringBuilder(this.getClass().getName()).append(": ").append(System.lineSeparator()); for (DocumentNameMatcher matcher : matchers) { @@ -480,10 +483,7 @@ public boolean test(final DocumentName documentName) { return true; } // excluded - if (iter.next().matches(documentName)) { - return false; - } - return true; + return !iter.next().matches(documentName); } } @@ -491,13 +491,13 @@ public boolean test(final DocumentName documentName) { * Data from a {@link DocumentNameMatcher#decompose(DocumentName)} call. */ public static final class DecomposeData { - /** the level this data was generated at */ + /** The level this data was generated at. */ private final int level; - /** The name of the DocumentNameMatcher that created this result */ + /** The name of the DocumentNameMatcher that created this result. */ private final DocumentNameMatcher matcher; /** The result of the check. */ private final boolean result; - /** The candidate */ + /** The actual candidate. */ private final DocumentName candidate; private DecomposeData(final int level, final DocumentNameMatcher matcher, final DocumentName candidate, final boolean result) { diff --git a/apache-rat-core/src/main/java/org/apache/rat/document/FileDocument.java b/apache-rat-core/src/main/java/org/apache/rat/document/FileDocument.java index 3e7dec89b..d7596a3ef 100644 --- a/apache-rat-core/src/main/java/org/apache/rat/document/FileDocument.java +++ b/apache-rat-core/src/main/java/org/apache/rat/document/FileDocument.java @@ -42,20 +42,20 @@ public class FileDocument extends Document { * Creates a File document. * @param basedir the base directory for this document. * @param file the file to wrap. - * @param nameExcluder the path matcher to filter files/directories with. + * @param nameMatcher the path matcher to filter files/directories with. */ - public FileDocument(final DocumentName basedir, final File file, final DocumentNameMatcher nameExcluder) { - super(DocumentName.builder(file).setBaseName(basedir.getBaseName()).build(), nameExcluder); + public FileDocument(final DocumentName basedir, final File file, final DocumentNameMatcher nameMatcher) { + super(DocumentName.builder(file).setBaseName(basedir.getBaseName()).build(), nameMatcher); this.file = file; } /** * Creates a File document where the baseDir is the root directory. * @param file the file to wrap. - * @param nameExcluder the path matcher to filter files/directories with. + * @param nameMatcher the path matcher to filter files/directories with. */ - public FileDocument(final File file, final DocumentNameMatcher nameExcluder) { - super(DocumentName.builder(file).setBaseName(File.separator).build(), nameExcluder); + public FileDocument(final File file, final DocumentNameMatcher nameMatcher) { + super(DocumentName.builder(file).setBaseName(File.separator).build(), nameMatcher); this.file = file; } @@ -70,12 +70,12 @@ public SortedSet listChildren() { SortedSet result = new TreeSet<>(); File[] files = file.listFiles(); if (files != null) { - FileFilter fileFilter = ExclusionUtils.asFileFilter(name, nameExcluder); + FileFilter fileFilter = ExclusionUtils.asFileFilter(name, nameMatcher); for (File child : files) { if (fileFilter.accept(child)) { - result.add(new FileDocument(name, child, nameExcluder)); + result.add(new FileDocument(name, child, nameMatcher)); } else { - result.add(new IgnoredDocument(name, child, nameExcluder)); + result.add(new IgnoredDocument(name, child, nameMatcher)); } } } diff --git a/apache-rat-core/src/main/java/org/apache/rat/report/RatReport.java b/apache-rat-core/src/main/java/org/apache/rat/report/RatReport.java index e6bebf9bc..4a0c41cbd 100644 --- a/apache-rat-core/src/main/java/org/apache/rat/report/RatReport.java +++ b/apache-rat-core/src/main/java/org/apache/rat/report/RatReport.java @@ -44,7 +44,7 @@ default void startReport() throws RatException { * @throws RatException on error. */ default void report(Document document) throws RatException { - }; + } /** * Signals the end of execution for the report. Will be called after the {@code report()} method diff --git a/apache-rat-core/src/main/java/org/apache/rat/walker/ArchiveWalker.java b/apache-rat-core/src/main/java/org/apache/rat/walker/ArchiveWalker.java index e2cc470e6..a50aa5ef8 100644 --- a/apache-rat-core/src/main/java/org/apache/rat/walker/ArchiveWalker.java +++ b/apache-rat-core/src/main/java/org/apache/rat/walker/ArchiveWalker.java @@ -43,7 +43,7 @@ import static java.lang.String.format; /** - * Walks various kinds of archives files + * Walks various kinds of archives files. */ public class ArchiveWalker extends Walker { @@ -69,7 +69,7 @@ public void run(final RatReport report) throws RatException { } /** - * Creates an input stream from the Directory being walked. + * Creates an input stream from the directory being walked. * @return A buffered input stream reading the archive data. * @throws IOException on error */ @@ -83,18 +83,17 @@ private InputStream createInputStream() throws IOException { */ public Collection getDocuments() throws RatException { List result = new ArrayList<>(); - //DocumentName.FSInfo archiveInfo = new DocumentName.FSInfo(true, Arrays.asList("/"), "/"); try (ArchiveInputStream input = new ArchiveStreamFactory().createArchiveInputStream(createInputStream())) { ArchiveEntry entry; while ((entry = input.getNextEntry()) != null) { if (!entry.isDirectory() && input.canReadEntryData(entry)) { DocumentName innerName = DocumentName.builder().setName(entry.getName()) .setBaseName(".").build(); - if (this.getDocument().getNameExcluder().matches(innerName)) { + if (this.getDocument().getNameMatcher().matches(innerName)) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); IOUtils.copy(input, baos); ArchiveEntryName entryName = new ArchiveEntryName(getDocument().getName(), entry.getName()); - result.add(new ArchiveEntryDocument(entryName, baos.toByteArray(), getDocument().getNameExcluder())); + result.add(new ArchiveEntryDocument(entryName, baos.toByteArray(), getDocument().getNameMatcher())); } } } diff --git a/apache-rat-core/src/main/java/org/apache/rat/walker/FileListWalker.java b/apache-rat-core/src/main/java/org/apache/rat/walker/FileListWalker.java index 5aa48852d..056090858 100644 --- a/apache-rat-core/src/main/java/org/apache/rat/walker/FileListWalker.java +++ b/apache-rat-core/src/main/java/org/apache/rat/walker/FileListWalker.java @@ -38,11 +38,11 @@ * internally. */ public class FileListWalker implements IReportable { - /** The source document name */ + /** The source document name. */ private final FileDocument source; - /** The root document name */ + /** The root document name. */ private final DocumentName rootDoc; - /** the base directory for the source document */ + /** The base directory for the source document. */ private final DocumentName baseDoc; /** diff --git a/apache-rat-core/src/test/java/org/apache/rat/OptionCollectionTest.java b/apache-rat-core/src/test/java/org/apache/rat/OptionCollectionTest.java index 5ff584a7f..c0d45c08a 100644 --- a/apache-rat-core/src/test/java/org/apache/rat/OptionCollectionTest.java +++ b/apache-rat-core/src/test/java/org/apache/rat/OptionCollectionTest.java @@ -51,6 +51,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import static java.lang.String.format; + import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.fail; diff --git a/apache-rat-core/src/test/java/org/apache/rat/ReporterTest.java b/apache-rat-core/src/test/java/org/apache/rat/ReporterTest.java index 5e64a6b62..4d6b5ab3b 100644 --- a/apache-rat-core/src/test/java/org/apache/rat/ReporterTest.java +++ b/apache-rat-core/src/test/java/org/apache/rat/ReporterTest.java @@ -18,11 +18,9 @@ */ package org.apache.rat; - import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Fail.fail; - import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; diff --git a/apache-rat-core/src/test/java/org/apache/rat/config/exclusion/fileProcessors/CVSFileProcessorTest.java b/apache-rat-core/src/test/java/org/apache/rat/config/exclusion/fileProcessors/CVSFileProcessorTest.java index 57d0d35fe..7900fd7e7 100644 --- a/apache-rat-core/src/test/java/org/apache/rat/config/exclusion/fileProcessors/CVSFileProcessorTest.java +++ b/apache-rat-core/src/test/java/org/apache/rat/config/exclusion/fileProcessors/CVSFileProcessorTest.java @@ -19,7 +19,7 @@ package org.apache.rat.config.exclusion.fileProcessors; import java.util.ArrayList; -import org.apache.rat.utils.DefaultLog; + import org.apache.rat.utils.ExtendedIterator; import org.junit.jupiter.api.Test; diff --git a/apache-rat-core/src/test/java/org/apache/rat/config/parameters/DescriptionBuilderTest.java b/apache-rat-core/src/test/java/org/apache/rat/config/parameters/DescriptionBuilderTest.java index 24187c5e9..a4ef65ca6 100644 --- a/apache-rat-core/src/test/java/org/apache/rat/config/parameters/DescriptionBuilderTest.java +++ b/apache-rat-core/src/test/java/org/apache/rat/config/parameters/DescriptionBuilderTest.java @@ -99,7 +99,7 @@ public void textConfigParameters(Class clazz, Description desc) { /** Class to build a list of documents that are class files. */ private static class DocumentProcessor implements Consumer { - SortedSet documents = new TreeSet<>(); + final SortedSet documents = new TreeSet<>(); @Override public void accept(Document document) { if (document.isDirectory()) { diff --git a/apache-rat-core/src/test/java/org/apache/rat/document/DocumentNameTest.java b/apache-rat-core/src/test/java/org/apache/rat/document/DocumentNameTest.java index 31693e030..beeeeca94 100644 --- a/apache-rat-core/src/test/java/org/apache/rat/document/DocumentNameTest.java +++ b/apache-rat-core/src/test/java/org/apache/rat/document/DocumentNameTest.java @@ -18,13 +18,10 @@ */ package org.apache.rat.document; -import com.google.common.jimfs.Configuration; -import com.google.common.jimfs.Jimfs; import java.io.File; import java.io.FileFilter; import java.io.FilenameFilter; import java.io.IOException; -import java.nio.file.FileSystem; import java.nio.file.FileSystems; import java.nio.file.Path; import java.util.ArrayList; @@ -56,7 +53,7 @@ public class DocumentNameTest { - public static DocumentName mkName(Path tempDir, FSInfo fsInfo) throws IOException { + public static DocumentName mkName(Path tempDir, FSInfo fsInfo) { File docFile = mkFile(tempDir.toFile(), fsInfo); DocumentName result = DocumentName.builder(fsInfo).setName(docFile).build(); DocumentName mocked = Mockito.spy(result); @@ -131,7 +128,6 @@ public static DocumentName mkName(Path tempDir, DocumentName baseDir, String pth return mocked; } - @ParameterizedTest(name = "{index} {0} {2}") @MethodSource("resolveTestData") void resolveTest(String testName, DocumentName base, String toResolve, DocumentName expected) { @@ -196,7 +192,6 @@ private static Stream resolveTestData() { lst.add(Arguments.of("osx", base, "..\\up\\and\\down", expected)); return lst.stream(); - } @Test @@ -215,7 +210,6 @@ void localizeTest() { .setBaseName("/a").build(); assertThat(documentName.localized()).isEqualTo("/b/c"); assertThat(documentName.localized("-")).isEqualTo("-b-c"); - } @ParameterizedTest(name = "{index} {0}") @@ -228,7 +222,7 @@ void validBuilderTest(String testName, DocumentName.Builder builder, String root assertThat(underTest.getBaseName()).as(testName).isEqualTo(root + dirSeparator + baseName); } - private static Stream validBuilderData() throws IOException { + private static Stream validBuilderData() { List lst = new ArrayList<>(); File f = Files.newTemporaryFile(); @@ -283,7 +277,7 @@ private static Stream validBuilderData() throws IOException { } @Test - void splitRootsTest() throws IOException { + void splitRootsTest() { Pair result = DocumentName.builder(WINDOWS).splitRoot("C:\\My\\path\\to\\a\\file.txt"); assertThat(result.getLeft()).isEqualTo("C:"); assertThat(result.getRight()).isEqualTo("My\\path\\to\\a\\file.txt"); @@ -295,11 +289,10 @@ void splitRootsTest() throws IOException { result = DocumentName.builder(OSX).splitRoot("/My/path/to/a/file.txt"); assertThat(result.getLeft()).isEqualTo(""); assertThat(result.getRight()).isEqualTo("My/path/to/a/file.txt"); - } @Test - void archiveEntryNameTest() throws IOException { + void archiveEntryNameTest() { String entryName = "./anArchiveEntry.txt"; DocumentName archiveName = DocumentName.builder(WINDOWS) .setName("C:\\archives\\anArchive.zip").setBaseName("C:\\archives").build(); @@ -310,7 +303,6 @@ void archiveEntryNameTest() throws IOException { assertThat(archiveName.getName()).isEqualTo("C:\\archives\\anArchive.zip"); assertThat(archiveName.localized()).isEqualTo("\\anArchive.zip"); - ArchiveEntryName archiveEntryName = new ArchiveEntryName(archiveName, entryName); assertThat(archiveEntryName.getRoot()).isEqualTo(archiveName.getName()+"#"); diff --git a/apache-rat-core/src/test/java/org/apache/rat/document/FSInfoTest.java b/apache-rat-core/src/test/java/org/apache/rat/document/FSInfoTest.java index db2f91ea2..ced9d8c62 100644 --- a/apache-rat-core/src/test/java/org/apache/rat/document/FSInfoTest.java +++ b/apache-rat-core/src/test/java/org/apache/rat/document/FSInfoTest.java @@ -23,9 +23,7 @@ import java.io.IOException; import java.nio.file.FileSystem; import java.nio.file.FileSystems; -import java.util.ArrayList; import java.util.Arrays; -import java.util.List; import java.util.stream.Stream; import org.junit.jupiter.params.provider.Arguments; @@ -51,7 +49,7 @@ public class FSInfoTest { public static final DocumentName.FSInfo[] TEST_SUITE = {UNIX, WINDOWS, OSX}; /** - * Provided arguments for parameterized tests that only require the fsInfo. + * Provides arguments for parameterized tests that only require the fsInfo. * @return a stream of TEST_SUITE based Arguments. */ public static Stream fsInfoArgs() { diff --git a/apache-rat-core/src/test/java/org/apache/rat/test/AbstractOptionsProvider.java b/apache-rat-core/src/test/java/org/apache/rat/test/AbstractOptionsProvider.java index d508e39f8..8a34245e9 100644 --- a/apache-rat-core/src/test/java/org/apache/rat/test/AbstractOptionsProvider.java +++ b/apache-rat-core/src/test/java/org/apache/rat/test/AbstractOptionsProvider.java @@ -244,10 +244,10 @@ protected DocumentName mkDocName(String name) { return DocumentName.builder(new File(baseDir, name)).build(); } - /* tests to be implemented */ + /* Tests to be implemented */ protected abstract void helpTest(); - /** Displayd the option and value under test */ + /* Display the option and value under test */ private String displayArgAndName(Option option, String fname) { return String.format("%s %s", option.getLongOpt(), fname); } @@ -344,6 +344,12 @@ protected void inputExcludeParsedScmTest() { try { ReportConfiguration config = generateConfig(ImmutablePair.of(option, args)); DocumentNameMatcher excluder = config.getDocumentExcluder(baseName()); + for (String fname : notExcluded) { + final DocumentName docName = mkDocName(fname); + assertThat(excluder.matches(docName)) + .as(() -> String.format("option: %s name: %s%n%s", option.getKey(), fname, excluder.decompose(docName))) + .isTrue(); + } for (String fname : excluded) { DocumentName docName = mkDocName(fname); assertThat(excluder.matches(docName)).as(() -> dump(option, fname, excluder, docName)).isFalse(); @@ -392,6 +398,12 @@ private void execIncludeTest(Option option, String[] args) { ReportConfiguration config = generateConfig(ImmutablePair.of(option, args), ImmutablePair.of(excludeOption, EXCLUDE_ARGS)); DocumentNameMatcher excluder = config.getDocumentExcluder(baseName()); + for (String fname : notExcluded) { + final DocumentName docName = mkDocName(fname); + assertThat(excluder.matches(docName)) + .as(() -> String.format("option: %s name: %s%n%s", option.getKey(), fname, excluder.decompose(docName))) + .isTrue(); + } for (String fname : excluded) { DocumentName docName = mkDocName(fname); assertThat(excluder.matches(docName)).as(() -> dump(option, fname, excluder, docName)).isFalse(); diff --git a/apache-rat-core/src/test/java/org/apache/rat/test/utils/Resources.java b/apache-rat-core/src/test/java/org/apache/rat/test/utils/Resources.java index 67a96afd9..8f52f2879 100644 --- a/apache-rat-core/src/test/java/org/apache/rat/test/utils/Resources.java +++ b/apache-rat-core/src/test/java/org/apache/rat/test/utils/Resources.java @@ -47,7 +47,7 @@ private Resources() { private static final File RESOURCE_BASE_PATH = new File(SRC_MAIN_RESOURCES); /** - * Locates a test resource file in the class path. + * Locates a test resource file in the classpath. */ public static File getResourceFile(String pResource) throws IOException { File f = getResourceFromBase(TEST_RESOURCE_BASE_PATH, pResource); @@ -58,17 +58,16 @@ public static File getResourceFile(String pResource) throws IOException { } /** - * Locates a test resource directory in the class path. + * Locates a test resource directory in the classpath. */ public static File getResourceDirectory(String pResource) throws IOException { File f = getResourceFromBase(TEST_RESOURCE_BASE_PATH, pResource); if (!f.isDirectory()) { - throw new FileNotFoundException("Unable to locate resource file: " + pResource); + throw new FileNotFoundException("Unable to locate resource directory: " + pResource); } return f; } - /** * Locates a file in the unpacked example data archive. * @param pResource the name of the resource to find. @@ -81,7 +80,7 @@ public static File getExampleResource(String pResource) { } /** - * Try to load the given file from baseDir, in case of errors try to add + * Try to load the given file from baseDir. In case of errors try to add * module names to fix behaviour from within IntelliJ. */ private static File getResourceFromBase(File baseDir, String pResource) throws IOException { @@ -103,21 +102,21 @@ public static File[] getResourceFiles(String pResource) throws IOException { } /** - * Locates a resource file in the class path and returns an {@link InputStream}. + * Locates a resource file in the classpath and returns an {@link InputStream}. */ public static InputStream getResourceStream(String pResource) throws IOException { return Files.newInputStream(getResourceFile(pResource).toPath()); } /** - * Locates a resource file in the class path and returns a {@link Reader}. + * Locates a resource file in the classpath and returns a {@link Reader}. */ public static Reader getResourceReader(String pResource) throws IOException { return new InputStreamReader(getResourceStream(pResource), StandardCharsets.UTF_8); } /** - * Locates a resource file in the class path and returns a + * Locates a resource file in the classpath and returns a * {@link BufferedReader}. */ public static BufferedReader getBufferedReader(File file) throws IOException { diff --git a/apache-rat-core/src/test/java/org/apache/rat/testhelpers/XmlUtils.java b/apache-rat-core/src/test/java/org/apache/rat/testhelpers/XmlUtils.java index 69b2b00b0..e2a1bbe3f 100644 --- a/apache-rat-core/src/test/java/org/apache/rat/testhelpers/XmlUtils.java +++ b/apache-rat-core/src/test/java/org/apache/rat/testhelpers/XmlUtils.java @@ -175,13 +175,13 @@ public static String getAttribute(Object source, XPath xPath, String xpath, Stri Node node = XmlUtils.getNode(source, xPath, xpath); NamedNodeMap attr = node.getAttributes(); node = attr.getNamedItem(attribute); - assertThat(node).as(attribute+" was not found").isNotNull(); + assertThat(node).as(attribute + " was not found").isNotNull(); return node.getNodeValue(); } public static Map mapOf(String... parts) { Map map = new HashMap<>(); - for (int i=0; i org.assertj assertj-core - 3.27.1 + 3.27.3 test @@ -385,7 +385,7 @@ agnostic home for software distribution comprehension and audit tools. spotbugs-maven-plugin 4.8.6.6 - + 98 true @@ -495,7 +495,7 @@ agnostic home for software distribution comprehension and audit tools. org.apache.maven.plugins maven-remote-resources-plugin - 3.2.0 + 3.3.0 org.apache.maven.plugins diff --git a/src/changes/changes.xml b/src/changes/changes.xml index d7e43924b..186d9c9b9 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -72,6 +72,9 @@ The type attribute can be one of: --> + + Integrate Creadur RAT into the updated develocity.apache.org instance. + Verify that projects that configure valid other licenses than the defaults, report correctly as well.