Skip to content

Commit

Permalink
Merge branch 'master' into add_file_arg_converter
Browse files Browse the repository at this point in the history
  • Loading branch information
Claudenw committed Jan 27, 2025
2 parents b66ff14 + 3529867 commit e5073ff
Show file tree
Hide file tree
Showing 32 changed files with 147 additions and 140 deletions.
3 changes: 2 additions & 1 deletion .asf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ github:
- RAT
- WHISKER
- TENTACLES

notifications:
commits: [email protected]
commits: [email protected]
2 changes: 1 addition & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ on:
pull_request:

env:
DEVELOCITY_ACCESS_KEY: ${{ secrets.GE_ACCESS_TOKEN }}
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}

jobs:
build:
Expand Down
3 changes: 2 additions & 1 deletion .mvn/develocity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
<develocity
xmlns="https://www.gradle.com/develocity-maven" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://www.gradle.com/develocity-maven https://www.gradle.com/schema/develocity-maven.xsd">
<projectId>creadur-rat</projectId>
<server>
<url>https://ge.apache.org</url>
<url>https://develocity.apache.org</url>
<allowUntrusted>false</allowUntrusted>
</server>
<buildScan>
Expand Down
2 changes: 1 addition & 1 deletion .mvn/extensions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<extension>
<groupId>com.gradle</groupId>
<artifactId>develocity-maven-extension</artifactId>
<version>1.23</version>
<version>1.23.1</version>
</extension>
<extension>
<groupId>com.gradle</groupId>
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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?

Expand Down
12 changes: 6 additions & 6 deletions apache-rat-core/src/main/java/org/apache/rat/api/Document.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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();
}

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> commentFilter(final Iterable<String> commentPrefixes) {
Expand Down Expand Up @@ -108,7 +108,7 @@ public static Predicate<String> 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) {
Expand All @@ -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<String> asIterator(final File patternFile, final Predicate<String> commentFilters) {
Expand Down Expand Up @@ -147,7 +147,7 @@ public static Iterable<String> 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<String> asIterable(final File patternFile, final Predicate<String> commentFilters) {
Expand All @@ -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();
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -141,5 +141,4 @@ static char[][] tokenizePathToCharArray(final String path, final String separato
}
return tokenizedNameChar;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public Iterable<MatchPattern> patterns() {
* <p>Uses far less string tokenization than any of the alternatives.</p>
*
* @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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
* <ul>
* <li>{@code root} - Where in the file system the name starts (e.g C: on windows). May be empty but not null.</li>
* <li>{@code root} - where in the file system the name starts (e.g C: on windows). May be empty but not null.</li>
* <li>{@code dirSeparator} - the separator between name segments (e.g. "\\" on windows, "/" on linux). May not be
* empty or null.</li>
* <li>{@code name} - The name of the file relative to the {@code root}. May not be null. Does NOT begin with a {@code dirSeparator}</li>
* <li>{@code baseName} - The name of a directory or file from which this file is reported. A DocumentName with a
* <li>{@code name} - the name of the file relative to the {@code root}. May not be null. Does NOT begin with a {@code dirSeparator}</li>
* <li>{@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.</li>
* <li>{@code isCaseSensitive} - identifies if the underlying file system is case-sensitive.</li>
* </ul>
Expand All @@ -60,7 +60,6 @@ public class DocumentName implements Comparable<DocumentName> {
/** 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;
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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<FSInfo> {
/** 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<String> roots;

public static FSInfo getDefault() {
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -429,15 +429,15 @@ public Optional<String> 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) {
return source.split("\\Q" + dirSeparator() + "\\E");
}

/**
* Removes "." and ".." from filenames names.
* Removes {@code .} and {@code ..} from filenames.
* @param pattern the file name pattern
* @return the normalized file name.
*/
Expand All @@ -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);
Expand Down Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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");
}
}

Expand All @@ -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.
* <p>
* To correctly parse the string it must use the directory separator specified by
* this Document.
* </p>
* @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) {
Expand Down Expand Up @@ -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.
*/
Expand Down
Loading

0 comments on commit e5073ff

Please sign in to comment.