Skip to content

Commit

Permalink
Enable checkstyle verification on build
Browse files Browse the repository at this point in the history
  • Loading branch information
slawekjaranowski committed Dec 3, 2022
1 parent e351720 commit 0e3741d
Show file tree
Hide file tree
Showing 34 changed files with 598 additions and 492 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public boolean equals( Object o )
{
return false;
}
return Objects.equals(parent, abstractEntry.parent);
return Objects.equals( parent, abstractEntry.parent );
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ protected Entry get( DirectoryEntry parent, String name )
Entry[] entries = listEntries( parent );
if ( entries != null )
{
for (Entry entry : entries)
for ( Entry entry : entries )
{
if (name.equals(entry.getName()))
if ( name.equals( entry.getName() ) )
{
return entry;
}
Expand Down
23 changes: 12 additions & 11 deletions mrm-api/src/main/java/org/codehaus/mojo/mrm/api/maven/Artifact.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ private Artifact( String groupId, String artifactId, String version, String clas
public Artifact( String groupId, String artifactId, String version, String classifier, String type, long timestamp,
int buildNumber )
{
this( groupId, artifactId, version, classifier, type, Long.valueOf( timestamp ), Integer.valueOf( buildNumber ) );
this( groupId, artifactId, version, classifier, type, Long.valueOf( timestamp ),
Integer.valueOf( buildNumber ) );
}

/**
Expand Down Expand Up @@ -205,8 +206,8 @@ public String getName()
{
if ( name == null )
{
name = MessageFormat.format( "{0}-{1}{2}.{3}", new Object[]{ artifactId, getTimestampVersion(),
( classifier == null ? "" : "-" + classifier ), type } );
name = MessageFormat.format( "{0}-{1}{2}.{3}", new Object[] {artifactId, getTimestampVersion(),
( classifier == null ? "" : "-" + classifier ), type} );
}
return name;
}
Expand Down Expand Up @@ -293,7 +294,7 @@ public Integer getBuildNumber()
* (may be <code>null</code>).
*
* @return the timestamp (formatted as a <code>yyyyMMdd.HHmmss</code> string) of the artifact
* (may be <code>null</code>).
* (may be <code>null</code>).
* @since 1.0
*/
public String getTimestampString()
Expand Down Expand Up @@ -331,9 +332,9 @@ public String getTimestampVersion()
assert isSnapshot();
SimpleDateFormat fmt = new SimpleDateFormat( "yyyyMMdd.HHmmss" );
fmt.setTimeZone( TimeZone.getTimeZone( "GMT" ) );
timestampVersion = MessageFormat.format( "{0}-{1}-{2}", new Object[]{
timestampVersion = MessageFormat.format( "{0}-{1}-{2}", new Object[] {
this.version.substring( 0, this.version.length() - "-SNAPSHOT".length() ),
fmt.format( new Date( timestamp.longValue() ) ), buildNumber } );
fmt.format( new Date( timestamp.longValue() ) ), buildNumber} );
}
else
{
Expand Down Expand Up @@ -386,15 +387,15 @@ public boolean equals( Object o )
{
return false;
}
if (!Objects.equals(classifier, artifact.classifier))
if ( !Objects.equals( classifier, artifact.classifier ) )
{
return false;
}
if (!Objects.equals(buildNumber, artifact.buildNumber))
if ( !Objects.equals( buildNumber, artifact.buildNumber ) )
{
return false;
}
if (!Objects.equals(timestamp, artifact.timestamp))
if ( !Objects.equals( timestamp, artifact.timestamp ) )
{
return false;
}
Expand All @@ -407,7 +408,7 @@ public boolean equals( Object o )
*
* @param artifact the artifact to compare with.
* @return <code>true</code> if this artifact is the same as the specified artifact (where timestamps are ignored
* for SNAPSHOT versions).
* for SNAPSHOT versions).
* @since 1.0
*/
public boolean equalSnapshots( Artifact artifact )
Expand All @@ -433,7 +434,7 @@ public boolean equalSnapshots( Artifact artifact )
{
return false;
}
if (!Objects.equals(classifier, artifact.classifier))
if ( !Objects.equals( classifier, artifact.classifier ) )
{
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ public interface ArtifactStore
* </p>
* If there are known to be groupIds: org.codehaus.mojo, org.apache.maven and commons-io then
* <pre>
* assertEquals(new HashSet&lt;String&gt;(Arrays.asList("commons-io","org")), getGroupIds("")); // Query root level
* assertEquals(new HashSet&lt;String&gt;(Arrays.asList("org.codehaus", "org.apache")), getGroupIds("org")); // query with a prefix
* // Query root level
* assertEquals(new HashSet&lt;String&gt;(Arrays.asList("commons-io","org")), getGroupIds(""));
*
* // query with a prefix
* assertEquals(new HashSet&lt;String&gt;(Arrays.asList("org.codehaus", "org.apache")), getGroupIds("org"));
*
* assertEquals(new HashSet&lt;String&gt;(Arrays.asList("org.codehaus.mojo")), getGroupIds("org.codehaus"));
* </pre>
* <p>
Expand All @@ -56,8 +60,8 @@ public interface ArtifactStore
*
* @param parentGroupId The prefix to query or the empty string to query the root, cannot be <code>null</code>.
* @return A set (with all elements of type {@link String}) of groupIds that are known to have
* {@code parentGroupId} as their prefix. All returned elements must start with {@code parentGroupId} and must have
* one and only one additional segment.
* {@code parentGroupId} as their prefix. All returned elements must start with {@code parentGroupId} and must have
* one and only one additional segment.
* @since 1.0
*/
Set<String> getGroupIds( String parentGroupId );
Expand All @@ -74,7 +78,7 @@ public interface ArtifactStore
*
* @param groupId The groupId to query cannot be empty or <code>null</code>.
* @return A set (with all elements of type {@link String}) of artifactIds that are known to belong to
* {@code groupId}.
* {@code groupId}.
* @since 1.0
*/
Set<String> getArtifactIds( String groupId );
Expand All @@ -92,13 +96,14 @@ public interface ArtifactStore
* @param groupId The groupId to query cannot be empty or <code>null</code>.
* @param artifactId The artifactId to query cannot be empty or <code>null</code>.
* @return A set (with all elements of type {@link String}) of versions that are known to exist for
* {@code groupId:artifactId}.
* {@code groupId:artifactId}.
* @since 1.0
*/
Set<String> getVersions( String groupId, String artifactId );

/**
* Returns the set of artifacts at the specified groupId:artifactId:version. Some implementations may be lazy caching
* Returns the set of artifacts at the specified groupId:artifactId:version. Some implementations may be lazy
* caching
* implementations, in which case it is permitted to return either the empty set, or only those entries which
* have been loaded into the cache, so consumers should not assume that a missing entry implies non-existence.
* The only way to be sure that an artifact does not exist is to call the {@link #get(Artifact)} method.
Expand All @@ -107,7 +112,7 @@ public interface ArtifactStore
* @param artifactId The artifactId to query cannot be empty or <code>null</code>.
* @param version The version to query cannot be empty or <code>null</code>.
* @return A set (with all elements of type {@link Artifact} of artifacts that are known to exist of the
* specified {@code groupId:artifactId:version}.
* specified {@code groupId:artifactId:version}.
* @since 1.0
*/
Set<Artifact> getArtifacts( String groupId, String artifactId, String version );
Expand All @@ -117,10 +122,10 @@ public interface ArtifactStore
*
* @param artifact the artifact.
* @return A <code>long</code> value representing the time the file was
* last modified, measured in milliseconds since the epoch
* (00:00:00 GMT, January 1, 1970), or <code>0L</code> if the
* artifact might not exist (where the artifact is known to not exist an
* {@link ArtifactNotFoundException} must be thrown.
* last modified, measured in milliseconds since the epoch
* (00:00:00 GMT, January 1, 1970), or <code>0L</code> if the
* artifact might not exist (where the artifact is known to not exist an
* {@link ArtifactNotFoundException} must be thrown.
* @throws IOException if an I/O error occurs.
* @throws ArtifactNotFoundException if the artifact definitely does not exist.
* @since 1.0
Expand Down Expand Up @@ -178,8 +183,8 @@ Metadata getMetadata( String path )

/**
* Create/update the specified metadata.
*
* @param path of the metadata (should not include the <code>maven-metadata.xml</code>.
*
* @param path of the metadata (should not include the <code>maven-metadata.xml</code>.
* @param content the metadata, never <code>null</code>.
* @throws IOException if an I/O error occurs.
* @since 1.1.0
Expand All @@ -191,28 +196,26 @@ Metadata getMetadata( String path )
*
* @param path of the metadata (should not include the <code>maven-metadata.xml</code>.
* @return A <code>long</code> value representing the time the file was
* last modified, measured in milliseconds since the epoch
* (00:00:00 GMT, January 1, 1970), or <code>0L</code> if the
* metadata might not exist (where the metadtat is known to not exist a
* {@link MetadataNotFoundException} must be thrown.
* last modified, measured in milliseconds since the epoch
* (00:00:00 GMT, January 1, 1970), or <code>0L</code> if the
* metadata might not exist (where the metadtat is known to not exist a
* {@link MetadataNotFoundException} must be thrown.
* @throws IOException if an I/O error occurs.
* @throws MetadataNotFoundException if the metadata definitely does not exist.
* @since 1.0
*/
long getMetadataLastModified( String path )
throws IOException, MetadataNotFoundException;

/**
*
* @return ArchetypeCatalog
* @throws IOException if an I/O error occurs.
* @throws ArchetypeCatalogNotFoundException if the archetypeCatalog does not exist.
* @since 1.0
*/
ArchetypeCatalog getArchetypeCatalog() throws IOException, ArchetypeCatalogNotFoundException;

/**
*
* @return long
* @throws IOException if an I/O error occurs.
* @throws ArchetypeCatalogNotFoundException if the archetypeCatalog does not exist.
Expand All @@ -221,9 +224,8 @@ long getMetadataLastModified( String path )
long getArchetypeCatalogLastModified() throws IOException, ArchetypeCatalogNotFoundException;

/**
*
* @param content the content
* @throws IOException if an I/O error occurs.
* @throws IOException if an I/O error occurs.
* @since 1.0
*/
void setArchetypeCatalog( InputStream content ) throws IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,24 @@ public void setArchetypeCatalog( InputStream content )
{
throw new UnsupportedOperationException( "Read-only artifact store" );
}

/**
* {@inheritDoc}
*/
public ArchetypeCatalog getArchetypeCatalog()
throws IOException, ArchetypeCatalogNotFoundException
{
throw new ArchetypeCatalogNotFoundException( "Archetype Catalog not available", new UnsupportedOperationException() );
throw new ArchetypeCatalogNotFoundException( "Archetype Catalog not available",
new UnsupportedOperationException() );
}

/**
* {@inheritDoc}
*/
public long getArchetypeCatalogLastModified()
throws IOException, ArchetypeCatalogNotFoundException
{
throw new ArchetypeCatalogNotFoundException( "Archetype Catalog not available", new UnsupportedOperationException() );
throw new ArchetypeCatalogNotFoundException( "Archetype Catalog not available",
new UnsupportedOperationException() );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ public class ProxyArtifactStore
* The {@link ArtifactResolver} provided by Maven.
*/
private final ArtifactResolver artifactResolver;


private final ArchetypeManager archetypeManager;

/**
Expand Down Expand Up @@ -118,10 +118,12 @@ public class ProxyArtifactStore
* @param artifactResolver the {@link ArtifactResolver} to use.
* @param log the {@link Log} to log to.
*/
@SuppressWarnings( "checkstyle:ParameterNumber" )
public ProxyArtifactStore( RepositoryMetadataManager repositoryMetadataManager,
List<ArtifactRepository> remoteArtifactRepositories,
List<ArtifactRepository> remotePluginRepositories, ArtifactRepository localRepository,
ArtifactFactory artifactFactory, ArtifactResolver artifactResolver, ArchetypeManager archetypeManager, Log log )
ArtifactFactory artifactFactory, ArtifactResolver artifactResolver,
ArchetypeManager archetypeManager, Log log )
{
this.repositoryMetadataManager = repositoryMetadataManager;
this.remotePluginRepositories = remotePluginRepositories;
Expand Down Expand Up @@ -153,7 +155,7 @@ private synchronized void addResolved( Artifact artifact )
{
String path =
artifact.getGroupId().replace( '.', '/' ) + '/' + artifact.getArtifactId() + "/" + artifact.getVersion();
Map<String, Artifact> artifactMapper = this.children.computeIfAbsent(path, k -> new HashMap<>());
Map<String, Artifact> artifactMapper = this.children.computeIfAbsent( path, k -> new HashMap<>() );
artifactMapper.put( artifact.getName(), artifact );
addResolved( path );
}
Expand All @@ -169,12 +171,12 @@ private synchronized void addResolved( String path )
{
String name = path.substring( index + 1 );
path = path.substring( 0, index );
Map<String, Artifact> artifactMapper = this.children.computeIfAbsent(path, k -> new HashMap<>());
Map<String, Artifact> artifactMapper = this.children.computeIfAbsent( path, k -> new HashMap<>() );
artifactMapper.put( name, null );
}
if ( !StringUtils.isEmpty( path ) )
{
Map<String, Artifact> artifactMapper = this.children.computeIfAbsent("", k -> new HashMap<>());
Map<String, Artifact> artifactMapper = this.children.computeIfAbsent( "", k -> new HashMap<>() );
artifactMapper.put( path, null );
}
}
Expand All @@ -190,9 +192,9 @@ public synchronized Set<String> getGroupIds( String parentGroupId )
{
return Collections.emptySet();
}
return artifactMapper.entrySet().stream().filter( entry -> entry.getValue() == null)
.map(Map.Entry::getKey)
.collect(Collectors.toSet());
return artifactMapper.entrySet().stream().filter( entry -> entry.getValue() == null )
.map( Map.Entry::getKey )
.collect( Collectors.toSet() );
}

/**
Expand All @@ -206,9 +208,9 @@ public synchronized Set<String> getArtifactIds( String groupId )
{
return Collections.emptySet();
}
return artifactMapper.entrySet().stream().filter(entry -> entry.getValue()==null)
.map(Map.Entry::getKey)
.collect(Collectors.toSet());
return artifactMapper.entrySet().stream().filter( entry -> entry.getValue() == null )
.map( Map.Entry::getKey )
.collect( Collectors.toSet() );
}

/**
Expand All @@ -222,9 +224,9 @@ public synchronized Set<String> getVersions( String groupId, String artifactId )
{
return Collections.emptySet();
}
return artifactMapper.entrySet().stream().filter(entry -> entry.getValue()==null)
.map(Map.Entry::getKey)
.collect(Collectors.toSet());
return artifactMapper.entrySet().stream().filter( entry -> entry.getValue() == null )
.map( Map.Entry::getKey )
.collect( Collectors.toSet() );
}

/**
Expand All @@ -238,8 +240,8 @@ public synchronized Set<Artifact> getArtifacts( String groupId, String artifactI
{
return Collections.emptySet();
}
return artifactMapper.values().stream().filter(Objects::nonNull)
.collect( Collectors.toSet() );
return artifactMapper.values().stream().filter( Objects::nonNull )
.collect( Collectors.toSet() );

}

Expand All @@ -266,7 +268,7 @@ public long getLastModified( Artifact artifact )
}
catch ( org.apache.maven.artifact.resolver.ArtifactNotFoundException e )
{
throw new ArtifactNotFoundException( artifact , e );
throw new ArtifactNotFoundException( artifact, e );
}
catch ( ArtifactResolutionException e )
{
Expand Down Expand Up @@ -371,7 +373,8 @@ public Metadata getMetadata( String path )
artifactFactory.createDependencyArtifact( groupId, artifactId,
VersionRange.createFromVersion( version ), "pom", null,
"compile" );
SnapshotArtifactRepositoryMetadata artifactRepositoryMetadata = new SnapshotArtifactRepositoryMetadata( artifact );
SnapshotArtifactRepositoryMetadata artifactRepositoryMetadata =
new SnapshotArtifactRepositoryMetadata( artifact );
try
{
repositoryMetadataManager.resolve( artifactRepositoryMetadata, remoteRepositories, localRepository );
Expand Down Expand Up @@ -508,7 +511,7 @@ public ArchetypeCatalog getArchetypeCatalog()
public long getArchetypeCatalogLastModified()
throws IOException, ArchetypeCatalogNotFoundException
{
if( archetypeManager.getDefaultLocalCatalog() != null )
if ( archetypeManager.getDefaultLocalCatalog() != null )
{
return System.currentTimeMillis();
}
Expand Down
Loading

0 comments on commit 0e3741d

Please sign in to comment.