Skip to content

Commit

Permalink
Quick fixes to issues reported by IDE
Browse files Browse the repository at this point in the history
  • Loading branch information
slachiewicz committed Sep 27, 2020
1 parent 80c759b commit 2103e93
Show file tree
Hide file tree
Showing 42 changed files with 295 additions and 301 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
* </p>
*
* @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
* @version $Id$
*/
public abstract class AbstractStrictPatternArtifactFilter implements ArtifactFilter
{
Expand Down Expand Up @@ -157,9 +156,7 @@ else if ( pattern.startsWith( "*" ) && pattern.endsWith( "*" ) )
// support leading wildcard
else if ( pattern.startsWith( "*" ) )
{
String suffix = pattern.substring( 1, pattern.length() );

matches = token.endsWith( suffix );
matches = token.endsWith( pattern.substring( 1 ) );
}
// support trailing wildcard
else if ( pattern.endsWith( "*" ) )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ public class PatternIncludesArtifactFilter

private final boolean actTransitively;

private final Set<String> patternsTriggered = new HashSet<String>();
private final Set<String> patternsTriggered = new HashSet<>();

private final List<String> filteredArtifactIds = new ArrayList<String>();
private final List<String> filteredArtifactIds = new ArrayList<>();

/**
* @param patterns The pattern to be used.
Expand All @@ -67,8 +67,8 @@ public PatternIncludesArtifactFilter( final Collection<String> patterns )
public PatternIncludesArtifactFilter( final Collection<String> patterns, final boolean actTransitively )
{
this.actTransitively = actTransitively;
final List<String> pos = new ArrayList<String>();
final List<String> neg = new ArrayList<String>();
final List<String> pos = new ArrayList<>();
final List<String> neg = new ArrayList<>();
if ( patterns != null && !patterns.isEmpty() )
{
for ( String pattern : patterns )
Expand Down Expand Up @@ -272,7 +272,7 @@ else if ( pattern.startsWith( "*" ) && pattern.endsWith( "*" ) )
// support leading wildcard
else if ( pattern.startsWith( "*" ) )
{
final String suffix = pattern.substring( 1, pattern.length() );
final String suffix = pattern.substring( 1 );

matches = token.endsWith( suffix );
}
Expand Down Expand Up @@ -336,7 +336,7 @@ public void reportMissedCriteria( final Logger logger )
// if there are no patterns, there is nothing to report.
if ( !positivePatterns.isEmpty() || !negativePatterns.isEmpty() )
{
final List<String> missed = new ArrayList<String>();
final List<String> missed = new ArrayList<>();
missed.addAll( positivePatterns );
missed.addAll( negativePatterns );

Expand All @@ -352,7 +352,7 @@ public void reportMissedCriteria( final Logger logger )

for ( String pattern : missed )
{
buffer.append( "\no \'" ).append( pattern ).append( "\'" );
buffer.append( "\no '" ).append( pattern ).append( "'" );
}

buffer.append( "\n" );
Expand All @@ -376,7 +376,7 @@ protected String getPatternsAsString()
final StringBuilder buffer = new StringBuilder();
for ( String pattern : positivePatterns )
{
buffer.append( "\no \'" ).append( pattern ).append( "\'" );
buffer.append( "\no '" ).append( pattern ).append( "'" );
}

return buffer.toString();
Expand Down Expand Up @@ -413,7 +413,7 @@ public boolean hasMissedCriteria()
// if there are no patterns, there is nothing to report.
if ( !positivePatterns.isEmpty() || !negativePatterns.isEmpty() )
{
final List<String> missed = new ArrayList<String>();
final List<String> missed = new ArrayList<>();
missed.addAll( positivePatterns );
missed.addAll( negativePatterns );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class ScopeArtifactFilter

private boolean systemScopeHit = false;

private List<String> filteredArtifactIds = new ArrayList<String>();
private final List<String> filteredArtifactIds = new ArrayList<>();

/**
* Constructor that is meant to be used with fine-grained manipulation to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
* artifact pattern syntax.
*
* @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
* @version $Id$
* @see AbstractStrictPatternArtifactFilter
* @see PatternExcludesArtifactFilter
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
* artifact pattern syntax.
*
* @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
* @version $Id$
* @see AbstractStrictPatternArtifactFilter
* @see PatternIncludesArtifactFilter
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;

import org.apache.maven.artifact.Artifact;
Expand All @@ -31,7 +32,6 @@
* This is the common base class of ClassifierFilter and TypeFilter
*
* @author <a href="richardv@mxtelecom.com">Richard van der Hoff</a>
* @version $Id$
*/
public abstract class AbstractArtifactFeatureFilter
extends AbstractArtifactsFilter
Expand Down Expand Up @@ -86,7 +86,7 @@ public Set<Artifact> filter( Set<Artifact> artifacts )
*/
private Set<Artifact> filterIncludes( Set<Artifact> artifacts, List<String> theIncludes )
{
Set<Artifact> result = new LinkedHashSet<Artifact>();
Set<Artifact> result = new LinkedHashSet<>();

for ( String include : theIncludes )
{
Expand All @@ -108,13 +108,13 @@ private Set<Artifact> filterIncludes( Set<Artifact> artifacts, List<String> theI
/**
* Processes the dependencies list and excludes the dependencies that match a filter in the list.
*
* @param depends List of dependencies.
* @param excludes List of types or classifiers to exclude.
* @param artifacts List of dependencies.
* @param theExcludes List of types or classifiers to exclude.
* @return a set of filtered artifacts.
*/
private Set<Artifact> filterExcludes( Set<Artifact> artifacts, List<String> theExcludes )
{
Set<Artifact> result = new LinkedHashSet<Artifact>();
Set<Artifact> result = new LinkedHashSet<>();

for ( Artifact artifact : artifacts )
{
Expand Down Expand Up @@ -190,14 +190,13 @@ public List<String> getIncludes()

/**
* Allows Feature comparison to be customized
*
*
* @param lhs String artifact's feature
* @param rhs String feature from exclude or include list
* @return boolean true if features match
*/
protected boolean compareFeatures( String lhs, String rhs )
{
// If lhs is null, check that rhs is null. Otherwise check if strings are equal.
return ( lhs == null ? rhs == null : lhs.equals( rhs ) );
return ( Objects.equals( lhs, rhs ) );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

/**
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
* @version $Id$
*/
public abstract class AbstractArtifactsFilter
implements ArtifactsFilter
Expand All @@ -39,7 +38,7 @@ public abstract class AbstractArtifactsFilter
public boolean isArtifactIncluded( Artifact artifact )
throws ArtifactFilterException
{
Set<Artifact> set = new LinkedHashSet<Artifact>();
Set<Artifact> set = new LinkedHashSet<>();
set.add( artifact );

set = filter( set );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
*
* @author clove
* @since 2.0-alpha-2
* @version $Id$
*/
public class ArtifactIdFilter
extends AbstractArtifactFeatureFilter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
* This filter will exclude everything that is not a dependency of the selected artifact.
*
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
* @version $Id$
*/
public class ArtifactTransitivityFilter
extends AbstractArtifactsFilter
Expand Down Expand Up @@ -98,17 +97,7 @@ public ArtifactTransitivityFilter( Artifact artifact, ProjectBuildingRequest bui
transitiveArtifacts.add( mavenArtifact.getDependencyConflictId() );
}
}
catch ( IllegalAccessException e )
{
// don't want to pollute method signature with ReflectionExceptions
throw new RuntimeException( e.getMessage(), e );
}
catch ( InvocationTargetException e )
{
// don't want to pollute method signature with ReflectionExceptions
throw new RuntimeException( e.getMessage(), e );
}
catch ( NoSuchMethodException e )
catch ( IllegalAccessException | InvocationTargetException | NoSuchMethodException e )
{
// don't want to pollute method signature with ReflectionExceptions
throw new RuntimeException( e.getMessage(), e );
Expand All @@ -132,17 +121,7 @@ public ArtifactTransitivityFilter( Artifact artifact, ProjectBuildingRequest bui
transitiveArtifacts.add( mavenArtifact.getDependencyConflictId() );
}
}
catch ( IllegalAccessException e )
{
// don't want to pollute method signature with ReflectionExceptions
throw new RuntimeException( e.getMessage(), e );
}
catch ( InvocationTargetException e )
{
// don't want to pollute method signature with ReflectionExceptions
throw new RuntimeException( e.getMessage(), e );
}
catch ( NoSuchMethodException e )
catch ( IllegalAccessException | InvocationTargetException | NoSuchMethodException e )
{
// don't want to pollute method signature with ReflectionExceptions
throw new RuntimeException( e.getMessage(), e );
Expand Down Expand Up @@ -179,7 +158,7 @@ private static boolean canFindCoreClass( String className )
public Set<Artifact> filter( Set<Artifact> artifacts )
{

Set<Artifact> result = new LinkedHashSet<Artifact>();
Set<Artifact> result = new LinkedHashSet<>();
for ( Artifact artifact : artifacts )
{
if ( artifactIsATransitiveDependency( artifact ) )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,12 @@
* under the License.
*/

/**
*
*/

import java.util.Set;

import org.apache.maven.artifact.Artifact;

/**
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
* @version $Id$
*/
public interface ArtifactsFilter
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@

/**
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
* @version $Id$
*
*/
public class ClassifierFilter
extends AbstractArtifactFeatureFilter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
* under the License.
*/

/**
*
*/

import java.util.ArrayList;
import java.util.List;
import java.util.Set;
Expand All @@ -31,7 +27,6 @@

/**
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
* @version $Id$
*/
public class FilterArtifacts
{
Expand All @@ -42,7 +37,7 @@ public class FilterArtifacts
*/
public FilterArtifacts()
{
filters = new ArrayList<ArtifactsFilter>();
filters = new ArrayList<>();
}

/**
Expand Down Expand Up @@ -101,7 +96,6 @@ public Set<Artifact> filter( Set<Artifact> artifacts )
catch ( NullPointerException e )
{
// don't do anything, just skip this.
continue;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
*
* @author clove
* @since 2.0
* @version $Id$
*/
public class GroupIdFilter
extends AbstractArtifactFeatureFilter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@

/**
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
* @version $Id$
*/
public class ProjectTransitivityFilter
extends AbstractArtifactsFilter
{

private boolean excludeTransitive;

private Set<Artifact> directDependencies;
private final Set<Artifact> directDependencies;

/**
* @param directDependencies set of direct dependencies.
Expand All @@ -57,7 +56,7 @@ public Set<Artifact> filter( Set<Artifact> artifacts )

if ( excludeTransitive )
{
result = new LinkedHashSet<Artifact>();
result = new LinkedHashSet<>();
for ( Artifact artifact : artifacts )
{
if ( artifactIsADirectDependency( artifact ) )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

/**
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
* @version $Id$
*/
public class ScopeFilter
extends AbstractArtifactsFilter
Expand Down Expand Up @@ -73,7 +72,7 @@ public Set<Artifact> filter( Set<Artifact> artifacts )
throw new ArtifactFilterException( "Invalid Scope in includeScope: " + includeScope );
}

results = new LinkedHashSet<Artifact>();
results = new LinkedHashSet<>();

if ( Artifact.SCOPE_PROVIDED.equals( includeScope ) || Artifact.SCOPE_SYSTEM.equals( includeScope ) )
{
Expand All @@ -100,7 +99,7 @@ else if ( StringUtils.isNotEmpty( excludeScope ) )
{
throw new ArtifactFilterException( "Invalid Scope in excludeScope: " + excludeScope );
}
results = new LinkedHashSet<Artifact>();
results = new LinkedHashSet<>();
// plexus ScopeArtifactFilter doesn't handle the provided scope so
// we
// need special handling for it.
Expand Down Expand Up @@ -131,7 +130,7 @@ else if ( !Artifact.SCOPE_PROVIDED.equals( excludeScope ) && !Artifact.SCOPE_SYS

private Set<Artifact> includeSingleScope( Set<Artifact> artifacts, String scope )
{
Set<Artifact> results = new LinkedHashSet<Artifact>();
Set<Artifact> results = new LinkedHashSet<>();
for ( Artifact artifact : artifacts )
{
if ( scope.equals( artifact.getScope() ) )
Expand All @@ -144,7 +143,7 @@ private Set<Artifact> includeSingleScope( Set<Artifact> artifacts, String scope

private Set<Artifact> excludeSingleScope( Set<Artifact> artifacts, String scope )
{
Set<Artifact> results = new LinkedHashSet<Artifact>();
Set<Artifact> results = new LinkedHashSet<>();
for ( Artifact artifact : artifacts )
{
if ( !scope.equals( artifact.getScope() ) )
Expand Down

0 comments on commit 2103e93

Please sign in to comment.