Skip to content

[RSPEC-S1068] Remove unused private fields #2317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
package org.apache.maven.api;

import java.nio.file.Path;
import java.nio.file.PathMatcher;
import java.util.Collection;
import java.util.List;
import java.util.Optional;

Expand All @@ -45,30 +47,47 @@ default Path directory() {
}

/**
* {@return the list of pattern matchers for the files to include}.
* {@return the list of patterns for the files to include}.
* The path separator is {@code /} on all platforms, including Windows.
* The patterns are used to match paths relative to the {@code directory}.
* The prefix before the {@code :} character, if present, is the syntax.
* If no syntax is specified, the default is a Maven-specific variation
* of the {@code "glob"} pattern.
* The prefix before the {@code :} character, if present and longer than 1 character, is the syntax.
* If no syntax is specified, or if its length is 1 character (interpreted as a Windows drive),
* the default is a Maven-specific variation of the {@code "glob"} pattern.
*
* <p>
* The default implementation returns an empty list, which means to apply a language-dependent pattern.
* For example, for the Java language, the pattern includes all files with the {@code .java} suffix.
*
* @see java.nio.file.FileSystem#getPathMatcher(String)
*/
default List<String> includes() {
return List.of();
}

/**
* {@return the list of pattern matchers for the files to exclude}.
* {@return the list of patterns for the files to exclude}.
* The exclusions are applied after the inclusions.
* The default implementation returns an empty list.
*/
default List<String> excludes() {
return List.of();
}

/**
* {@return a matcher combining the include and exclude patterns}.
* If the user did not specify any includes, the given {@code defaultIncludes} are used.
* These defaults depend on the plugin.
* For example, the default include of the Java compiler plugin is <code>"**&sol;*.java"</code>.
*
* <p>If the user did not specify any excludes, the default is often files generated
* by Source Code Management (<abbr>SCM</abbr>) software or by the operating system.
* Examples: <code>"**&sol;.gitignore"</code>, <code>"**&sol;.DS_Store"</code>.</p>
*
* @param defaultIncludes the default includes if unspecified by the user
* @param useDefaultExcludes whether to add the default set of patterns to exclude,
* mostly Source Code Management (<abbr>SCM</abbr>) files
*/
PathMatcher matcher(Collection<String> defaultIncludes, boolean useDefaultExcludes);

/**
* {@return in which context the source files will be used}.
* Not to be confused with dependency scope.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,6 @@ public class Os {
*/
private static final String DARWIN = "darwin";

/**
* The path separator.
*/
private static final String PATH_SEP = System.getProperty("path.separator");

static {
// Those two public constants are initialized here, as they need all the private constants
// above to be initialized first, but the code style imposes the public constants to be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,6 @@
*
*/
public final class CLIReportingUtils {
// CHECKSTYLE_OFF: MagicNumber
public static final long MB = 1024 * 1024;

private static final long ONE_SECOND = 1000L;

private static final long ONE_MINUTE = 60 * ONE_SECOND;

private static final long ONE_HOUR = 60 * ONE_MINUTE;
Copy link
Contributor Author

@Pankraz76 Pankraz76 May 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


private static final long ONE_DAY = 24 * ONE_HOUR;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this might be API but seems unused

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Want to investigate, what its actually used for.

// CHECKSTYLE_ON: MagicNumber

public static final String BUILD_VERSION_PROPERTY = "version";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
package org.apache.maven.impl;

import java.nio.file.Path;
import java.nio.file.PathMatcher;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
Expand Down Expand Up @@ -140,9 +142,9 @@ public DefaultSourceRoot(final ProjectScope scope, final Language language, fina
* @param scope scope of source code (main or test)
* @param language language of the source code
* @param directory directory of the source code
* @param includes list of patterns for the files to include, or {@code null} if unspecified
* @param excludes list of patterns for the files to exclude, or {@code null} if unspecified
* */
* @param includes patterns for the files to include, or {@code null} or empty if unspecified
* @param excludes patterns for the files to exclude, or {@code null} or empty if nothing to exclude
*/
public DefaultSourceRoot(
final ProjectScope scope,
final Language language,
Expand Down Expand Up @@ -183,7 +185,7 @@ public Path directory() {
}

/**
* {@return the list of pattern matchers for the files to include}.
* {@return the patterns for the files to include}.
*/
@Override
@SuppressWarnings("ReturnOfCollectionOrArrayField") // Safe because unmodifiable
Expand All @@ -192,14 +194,30 @@ public List<String> includes() {
}

/**
* {@return the list of pattern matchers for the files to exclude}.
* {@return the patterns for the files to exclude}.
*/
@Override
@SuppressWarnings("ReturnOfCollectionOrArrayField") // Safe because unmodifiable
public List<String> excludes() {
return excludes;
}

/**
* {@return a matcher combining the include and exclude patterns}.
*
* @param defaultIncludes the default includes if unspecified by the user
* @param useDefaultExcludes whether to add the default set of patterns to exclude,
* mostly Source Code Management (<abbr>SCM</abbr>) files
*/
@Override
public PathMatcher matcher(Collection<String> defaultIncludes, boolean useDefaultExcludes) {
Collection<String> actual = includes();
if (actual == null || actual.isEmpty()) {
actual = defaultIncludes;
}
return new PathSelector(directory(), actual, excludes(), useDefaultExcludes).simplify();
}

/**
* {@return in which context the source files will be used}.
*/
Expand Down
Loading