Skip to content

Miscellaneous linting & cleanups #64

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 21 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 @@ -93,13 +93,11 @@ public CompilerOutputStyle getCompilerOutputStyle()
}

public String getInputFileEnding( CompilerConfiguration configuration )
throws CompilerException
{
return inputFileEnding;
}

public String getOutputFileEnding( CompilerConfiguration configuration )
throws CompilerException
{
if ( compilerOutputStyle != CompilerOutputStyle.ONE_OUTPUT_FILE_PER_INPUT_FILE )
{
Expand All @@ -121,7 +119,6 @@ public String getOutputFile( CompilerConfiguration configuration )
}

public boolean canUpdateTarget( CompilerConfiguration configuration )
throws CompilerException
{
return true;
}
Expand Down Expand Up @@ -152,7 +149,7 @@ protected static Set<String> getSourceFilesForSourceRoot( CompilerConfiguration

if ( includes != null && !includes.isEmpty() )
{
String[] inclStrs = includes.toArray( new String[includes.size()] );
String[] inclStrs = includes.toArray( new String[0] );
scanner.setIncludes( inclStrs );
}
else
Expand All @@ -164,7 +161,7 @@ protected static Set<String> getSourceFilesForSourceRoot( CompilerConfiguration

if ( excludes != null && !excludes.isEmpty() )
{
String[] exclStrs = excludes.toArray( new String[excludes.size()] );
String[] exclStrs = excludes.toArray( new String[0] );
scanner.setExcludes( exclStrs );
}

Expand Down Expand Up @@ -213,7 +210,7 @@ protected static String[] getSourceFiles( CompilerConfiguration config )
}
else
{
result = sources.toArray( new String[sources.size()] );
result = sources.toArray( new String[0] );
}

return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,14 @@ public interface Compiler

CompilerOutputStyle getCompilerOutputStyle();

String getInputFileEnding( CompilerConfiguration configuration )
throws CompilerException;
String getInputFileEnding( CompilerConfiguration configuration );

String getOutputFileEnding( CompilerConfiguration configuration )
throws CompilerException;
String getOutputFileEnding( CompilerConfiguration configuration );

String getOutputFile( CompilerConfiguration configuration )
throws CompilerException;

boolean canUpdateTarget( CompilerConfiguration configuration )
throws CompilerException;
boolean canUpdateTarget( CompilerConfiguration configuration );

/**
* Performs the compilation of the project. Clients must implement this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ public String toString()

public boolean equals( Object other )
{
if ( other == null || !( other instanceof CompilerOutputStyle ) )
if ( other instanceof CompilerOutputStyle )
{
return false;
return id.equals( ( (CompilerOutputStyle) other ).id );
}

return id.equals( ( (CompilerOutputStyle) other ).id );
return false;
}

public int hashCode()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
public abstract class AbstractSourceInclusionScanner
implements SourceInclusionScanner
{
private final List<SourceMapping> sourceMappings = new ArrayList<SourceMapping>();
private final List<SourceMapping> sourceMappings = new ArrayList<>();

public final void addSourceMapping( SourceMapping sourceMapping )
{
Expand All @@ -56,7 +56,7 @@ protected String[] scanForSources( File sourceDir, Set<String> sourceIncludes, S
}
else
{
includes = sourceIncludes.toArray( new String[sourceIncludes.size()] );
includes = sourceIncludes.toArray( new String[0] );
}

ds.setIncludes( includes );
Expand All @@ -68,7 +68,7 @@ protected String[] scanForSources( File sourceDir, Set<String> sourceIncludes, S
}
else
{
excludes = sourceExcludes.toArray( new String[sourceExcludes.size()] );
excludes = sourceExcludes.toArray( new String[0] );
}

ds.setExcludes( excludes );
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public SimpleSourceInclusionScanner( Set<String> sourceIncludes, Set<String> sou
}

public Set<File> getIncludedSources( File sourceDir, File targetDir )
throws InclusionScanException
{
List<SourceMapping> srcMappings = getSourceMappings();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ public interface SourceInclusionScanner
* @param sourceDir
* @param targetDir
* @return <code>Set</code> of <code>File</code> objects
* @throws InclusionScanException
*/
Set<File> getIncludedSources( File sourceDir, File targetDir )
throws InclusionScanException;
Set<File> getIncludedSources( File sourceDir, File targetDir );
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public StaleSourceScanner( long lastUpdatedWithinMsecs, Set<String> sourceInclud
// ----------------------------------------------------------------------

public Set<File> getIncludedSources( File sourceDir, File targetDir )
throws InclusionScanException
{
List<SourceMapping> srcMappings = getSourceMappings();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
* SOFTWARE.
*/

import org.codehaus.plexus.compiler.util.scan.InclusionScanException;

import java.util.Set;
import java.util.Collections;
import java.io.File;
Expand All @@ -50,7 +48,6 @@ public SingleTargetSourceMapping( String sourceSuffix, String outputFile )
}

public Set<File> getTargetFiles( File targetDir, String source )
throws InclusionScanException
{
if ( !source.endsWith( sourceSuffix ) )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
* limitations under the License.
*/

import org.codehaus.plexus.compiler.util.scan.InclusionScanException;

import java.io.File;
import java.util.Set;

Expand All @@ -26,6 +24,5 @@
*/
public interface SourceMapping
{
Set<File> getTargetFiles( File targetDir, String source )
throws InclusionScanException;
Set<File> getTargetFiles( File targetDir, String source );
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ public class CompilerConfigurationTest

@Override
protected void setUp()
throws Exception
{
configuration = new CompilerConfiguration();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void testGetIncludedSources()

Set<File> includedSources = scanner.getIncludedSources( base, base );

assertTrue( "no sources were included", !includedSources.isEmpty() );
assertFalse( "no sources were included", includedSources.isEmpty() );

for ( File file : includedSources )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected void setUp()
super.setUp();

includes = Collections.singleton( "*.java" );
excludes = new HashSet<String>();
excludes = new HashSet<>();
scanner = new SimpleSourceInclusionScanner( includes, excludes );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/

import junit.framework.TestCase;
import org.codehaus.plexus.compiler.util.scan.InclusionScanException;

import java.io.File;
import java.util.HashSet;
Expand All @@ -30,7 +29,6 @@ public class SuffixMappingTest
extends TestCase
{
public void testShouldReturnSingleClassFileForSingleJavaFile()
throws InclusionScanException
{
String base = "path/to/file";

Expand All @@ -46,7 +44,6 @@ public void testShouldReturnSingleClassFileForSingleJavaFile()
}

public void testShouldNotReturnClassFileWhenSourceFileHasWrongSuffix()
throws InclusionScanException
{
String base = "path/to/file";

Expand All @@ -60,13 +57,12 @@ public void testShouldNotReturnClassFileWhenSourceFileHasWrongSuffix()
}

public void testShouldReturnOneClassFileAndOneXmlFileForSingleJavaFile()
throws InclusionScanException
{
String base = "path/to/file";

File basedir = new File( "." );

Set<String> targets = new HashSet<String>();
Set<String> targets = new HashSet<>();
targets.add( ".class" );
targets.add( ".xml" );

Expand All @@ -82,13 +78,12 @@ public void testShouldReturnOneClassFileAndOneXmlFileForSingleJavaFile()
}

public void testShouldReturnNoTargetFilesWhenSourceFileHasWrongSuffix()
throws InclusionScanException
{
String base = "path/to/file";

File basedir = new File( "." );

Set<String> targets = new HashSet<String>();
Set<String> targets = new HashSet<>();
targets.add( ".class" );
targets.add( ".xml" );

Expand All @@ -100,7 +95,6 @@ public void testShouldReturnNoTargetFilesWhenSourceFileHasWrongSuffix()
}

public void testSingleTargetMapper()
throws InclusionScanException
{
String base = "path/to/file";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ public void testDeprecation()

assertFalse( error.isError() );

assertTrue( error.getMessage().indexOf( "Date" ) != -1 );
assertTrue( error.getMessage().contains( "Date" ) );

assertTrue( error.getMessage().indexOf( "deprecated" ) != -1 );
assertTrue( error.getMessage().contains( "deprecated" ) );
}

public void testWarning()
Expand Down Expand Up @@ -111,7 +111,7 @@ public void testWarning()

assertFalse( error.isError() );

assertTrue( error.getMessage().indexOf( "finally block does not complete normally" ) != -1 );
assertTrue( error.getMessage().contains( "finally block does not complete normally" ) );
}

protected List<CompilerMessage> compile( CompilerConfiguration configuration )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.StringUtils;

import javax.print.DocFlavor;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ private AjBuildConfig buildCompilerConfig( CompilerConfiguration config )
// buildConfig.setJavaOptions( javaOpts );
}

List<String> cp = new LinkedList<String>( config.getClasspathEntries() );
List<String> cp = new LinkedList<>( config.getClasspathEntries() );

File javaHomeDir = new File( System.getProperty( "java.home" ) );
File[] jars = new File( javaHomeDir, "lib" ).listFiles();
Expand All @@ -324,9 +324,9 @@ private AjBuildConfig buildCompilerConfig( CompilerConfiguration config )
}

checkForAspectJRT( cp );
if ( cp != null && !cp.isEmpty() )
if ( !cp.isEmpty() )
{
List<String> elements = new ArrayList<String>( cp.size() );
List<String> elements = new ArrayList<>( cp.size() );
for ( String path : cp )
{
elements.add( ( new File( path ) ).getAbsolutePath() );
Expand Down Expand Up @@ -404,11 +404,7 @@ private List<CompilerMessage> compileInProcess( AjBuildConfig buildConfig )
{
manager.batchBuild( buildConfig, messageHandler );
}
catch ( AbortException e )
{
throw new CompilerException( "Unknown error while compiling", e );
}
catch ( IOException e )
catch ( AbortException | IOException e )
{
throw new CompilerException( "Unknown error while compiling", e );
}
Expand All @@ -424,7 +420,7 @@ private List<CompilerMessage> compileInProcess( AjBuildConfig buildConfig )

boolean errors = messageHandler.hasAnyMessage( IMessage.ERROR, true );

List<CompilerMessage> messages = new ArrayList<CompilerMessage>();
List<CompilerMessage> messages = new ArrayList<>();
if ( errors )
{
IMessage[] errorMessages = messageHandler.getMessages( IMessage.ERROR, true );
Expand Down Expand Up @@ -485,7 +481,7 @@ private void checkForAspectJRT( List<String> cp )

private List<File> buildFileList( List<String> locations )
{
List<File> fileList = new LinkedList<File>();
List<File> fileList = new LinkedList<>();
for ( String location : locations )
{
fileList.add( new File( location ) );
Expand Down Expand Up @@ -569,7 +565,6 @@ else if ( sourceVersion == null || sourceVersion.length() <= 0 )
* @return null
*/
public String[] createCommandLine( CompilerConfiguration config )
throws CompilerException
{
return null;
}
Expand Down
Loading