Skip to content

Commit

Permalink
ParenPad checkstyle rule
Browse files Browse the repository at this point in the history
Add new rule, upgrade checkstyle version.
Fix violations
  • Loading branch information
MishaDemianenko committed Apr 29, 2017
1 parent 1f8d46d commit 0f9b33a
Show file tree
Hide file tree
Showing 935 changed files with 3,294 additions and 3,342 deletions.
5 changes: 5 additions & 0 deletions build/checkstyle.xml
Expand Up @@ -79,6 +79,11 @@
<property name="allowEmptyMethods" value="true"/>
</module>

<module name="ParenPad">
<property name="tokens"
value="ANNOTATION, ANNOTATION_FIELD_DEF, CTOR_CALL, CTOR_DEF, ENUM_CONSTANT_DEF, LITERAL_CATCH, LITERAL_DO, LITERAL_FOR, LITERAL_IF, LITERAL_NEW, LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_WHILE, RESOURCE_SPECIFICATION, SUPER_CTOR_CALL, LAMBDA, METHOD_DEF"/>
<property name="option" value="space"/>
</module>
</module>

</module>
Expand Up @@ -88,7 +88,7 @@ public Certificates()
random = useInsecureCertificateGeneration ? new InsecureRandom() : new SecureRandom();
}

public void createSelfSignedCertificate(File certificatePath, File privateKeyPath, String hostName)
public void createSelfSignedCertificate( File certificatePath, File privateKeyPath, String hostName )
throws GeneralSecurityException, IOException, OperatorCreationException
{
installCleanupHook(certificatePath, privateKeyPath);
Expand Down Expand Up @@ -144,7 +144,7 @@ private static void installCleanupHook( final File certificatePath, final File p
} ) );
}

public Certificate[] loadCertificates(File certFile) throws CertificateException, IOException
public Certificate[] loadCertificates( File certFile ) throws CertificateException, IOException
{
CertificateFactory certFactory = CertificateFactory.getInstance( CERTIFICATE_TYPE );
Collection<Certificate> certificates = new LinkedList<>();
Expand All @@ -170,7 +170,7 @@ public Certificate[] loadCertificates(File certFile) throws CertificateException
return certificates.toArray( new Certificate[certificates.size()] );
}

public PrivateKey loadPrivateKey(File privateKeyFile)
public PrivateKey loadPrivateKey( File privateKeyFile )
throws IOException, NoSuchAlgorithmException,
InvalidKeySpecException, NoSuchPaddingException,
InvalidKeyException, InvalidAlgorithmParameterException
Expand Down
Expand Up @@ -29,13 +29,13 @@ public class BoltIOException extends IOException implements Status.HasStatus

public BoltIOException( Status status, String message, Throwable cause )
{
super(message, cause);
super( message, cause );
this.status = status;
}

public BoltIOException( Status status, String message )
{
this(status, message, null);
this( status, message, null );
}

@Override
Expand Down
Expand Up @@ -81,7 +81,7 @@ public void onRun( String statement, Map<String,Object> params )
}

@Override
public void onExternalError( Neo4jError error)
public void onExternalError( Neo4jError error )
{
worker.enqueue( session -> session.externalError( error, defaultHandler ) );
}
Expand Down
Expand Up @@ -95,7 +95,7 @@ else if ( obj instanceof String )
{
pack( (String) obj );
}
else if (obj instanceof Character )
else if ( obj instanceof Character )
{
pack( (char) obj );
}
Expand Down Expand Up @@ -218,10 +218,10 @@ else if ( obj instanceof Path )
{
pathPacker.pack( this, (Path) obj );
}
else if ( obj instanceof Point)
else if ( obj instanceof Point )
{
error = Optional.of(new Error( Status.Request.Invalid,
"Point is not yet supported as a return type in Bolt"));
"Point is not yet supported as a return type in Bolt" ) );
packNull();

}
Expand All @@ -245,7 +245,7 @@ public void packRawMap( Map<String,Object> map ) throws IOException

public void consumeError( ) throws BoltIOException
{
if (error.isPresent())
if ( error.isPresent() )
{
Error e = error.get();
error = Optional.empty();
Expand Down
Expand Up @@ -131,11 +131,11 @@ private static MethodHandle charArrayGetter()
try
{
Field value = String.class.getDeclaredField( "value" );
if (value.getType() != char[].class)
if ( value.getType() != char[].class )
{
throw new AssertionError(
"This encoder depends being able to access raw char[] in java.lang.String, but the class is backed by a " +
value.getType().getCanonicalName());
value.getType().getCanonicalName() );
}
value.setAccessible( true );
return lookup.unreflectGetter( value );
Expand Down
Expand Up @@ -121,7 +121,7 @@ private void addIfNonZero( Map<String, Integer> map, String name, int count )

private String queryTypeCode( QueryExecutionType.QueryType queryType )
{
switch (queryType)
switch ( queryType )
{
case READ_ONLY:
return "r";
Expand Down
Expand Up @@ -48,12 +48,12 @@ private Neo4jError( Status status, String message, Throwable cause, boolean fata

private Neo4jError( Status status, String message, boolean fatal )
{
this(status, message, null, fatal );
this( status, message, null, fatal );
}

private Neo4jError( Status status, Throwable cause, boolean fatal )
{
this(status, status.code().description(), cause, fatal );
this( status, status.code().description(), cause, fatal );
}

public Status status()
Expand Down Expand Up @@ -194,17 +194,18 @@ public static Neo4jError combine( List<Neo4jError> errors )
{
assert errors.size() >= 1;

if (errors.size() == 1)
if ( errors.size() == 1 )
{
return errors.get( 0 );
}
else
{
Neo4jError first = errors.get( 0 );
Status combinedStatus = first.status;
StringBuilder combinedMessage = new StringBuilder( String.format("The following errors has occurred:%n%n" ));
StringBuilder combinedMessage =
new StringBuilder( String.format( "The following errors has occurred:%n%n" ) );
combinedMessage.append( first.message );
for (int i = 1; i < errors.size(); i++)
for ( int i = 1; i < errors.size(); i++ )
{
Neo4jError error = errors.get( i );
combinedStatus = error.status == combinedStatus ? error.status : Status.General.UnknownError;
Expand Down
Expand Up @@ -331,11 +331,11 @@ void terminateQueryAndRollbackTransaction( MutableTransactionState ctx ) throws
* This is overly careful about always closing and nulling the transaction since
* reset can cause ctx.currentTransaction to be null we store in local variable.
*/
void closeTransaction(MutableTransactionState ctx, boolean success) throws TransactionFailureException
void closeTransaction( MutableTransactionState ctx, boolean success ) throws TransactionFailureException
{
KernelTransaction tx = ctx.currentTransaction;
ctx.currentTransaction = null;
if (tx != null)
if ( tx != null )
{
try
{
Expand All @@ -347,7 +347,7 @@ void closeTransaction(MutableTransactionState ctx, boolean success) throws Trans
{
tx.failure();
}
if (tx.isOpen())
if ( tx.isOpen() )
{
tx.close();
}
Expand Down
Expand Up @@ -41,7 +41,7 @@ public String toString()
return format( BOOKMARK_TX_PREFIX + "%d", txId );
}

public static Bookmark fromString( String bookmarkString) throws BookmarkFormatException
public static Bookmark fromString( String bookmarkString ) throws BookmarkFormatException
{
if ( bookmarkString != null && bookmarkString.startsWith( BOOKMARK_TX_PREFIX ) )
{
Expand Down
Expand Up @@ -40,8 +40,8 @@ public class KeyStoreFactoryTest
public void shouldCreateKeyStoreForGivenKeyPair() throws Exception
{
// given
File certificatePath = new File(dir.getRoot(), "cert" );
File privateKeyPath = new File(dir.getRoot(), "key" );
File certificatePath = new File( dir.getRoot(), "cert" );
File privateKeyPath = new File( dir.getRoot(), "key" );

new Certificates().createSelfSignedCertificate( certificatePath, privateKeyPath, "some-hostname" );

Expand All @@ -56,8 +56,8 @@ public void shouldCreateKeyStoreForGivenKeyPair() throws Exception
public void shouldImportSingleCertificateWhenNotInAChain() throws Exception
{
// given
File certificatePath = new File(dir.getRoot(), "cert" );
File privateKeyPath = new File(dir.getRoot(),"key" );
File certificatePath = new File( dir.getRoot(), "cert" );
File privateKeyPath = new File( dir.getRoot(), "key" );

new Certificates().createSelfSignedCertificate( certificatePath, privateKeyPath, "some-hostname" );

Expand Down
Expand Up @@ -50,8 +50,8 @@ public void shouldCreateASelfSignedCertificate() throws Exception
{
// Given
Certificates sslFactory = new Certificates();
File cPath = new File(tmpDir.getRoot(), "certificate" );
File pkPath = new File(tmpDir.getRoot(), "key" );
File cPath = new File( tmpDir.getRoot(), "certificate" );
File pkPath = new File( tmpDir.getRoot(), "key" );

// When
sslFactory.createSelfSignedCertificate( cPath, pkPath, "myhost" );
Expand Down
Expand Up @@ -19,10 +19,10 @@
*/
package org.neo4j.bolt.v1.messaging.message;

import org.neo4j.bolt.v1.messaging.BoltRequestMessageHandler;

import java.util.Map;

import org.neo4j.bolt.v1.messaging.BoltRequestMessageHandler;

public class InitMessage implements RequestMessage
{
/**
Expand Down Expand Up @@ -57,9 +57,13 @@ public <E extends Exception> void dispatch( BoltRequestMessageHandler<E> consume
public boolean equals( Object o )
{
if ( this == o )
{ return true; }
{
return true;
}
if ( o == null || getClass() != o.getClass() )
{ return false; }
{
return false;
}

InitMessage that = (InitMessage) o;

Expand Down
Expand Up @@ -92,7 +92,7 @@ public void describeTo( Description description )
};
}

public static Matcher<ResponseMessage> hasNotification( Notification notification)
public static Matcher<ResponseMessage> hasNotification( Notification notification )
{
return new TypeSafeMatcher<ResponseMessage>()
{
Expand Down Expand Up @@ -247,7 +247,7 @@ public static byte[] serialize( RequestMessage... messages ) throws IOException
{
final RecordingByteChannel rawData = new RecordingByteChannel();
final BoltRequestMessageWriter packer = new BoltRequestMessageWriter( new Neo4jPack.Packer( new
BufferedChannelOutput( rawData )), NO_BOUNDARY_HOOK );
BufferedChannelOutput( rawData ) ), NO_BOUNDARY_HOOK );

for ( RequestMessage message : messages )
{
Expand All @@ -262,7 +262,7 @@ public static byte[] serialize( ResponseMessage... messages ) throws IOException
{
final RecordingByteChannel rawData = new RecordingByteChannel();
final BoltResponseMessageWriter packer = new BoltResponseMessageWriter( new Neo4jPack.Packer( new
BufferedChannelOutput( rawData )), NO_BOUNDARY_HOOK );
BufferedChannelOutput( rawData ) ), NO_BOUNDARY_HOOK );

for ( ResponseMessage message : messages )
{
Expand Down
Expand Up @@ -118,7 +118,7 @@ public double readDouble() throws IOException
public PackInput readBytes( byte[] into, int index, int toRead ) throws IOException
{
int endIndex = index + toRead;
while ( index < endIndex)
while ( index < endIndex )
{
toRead = Math.min( buffer.remaining(), endIndex - index );
buffer.get( into, index, toRead );
Expand Down
Expand Up @@ -786,7 +786,7 @@ private void doTheThing( PackStream.Packer packer, Object value ) throws IOExcep
{
packer.pack( (String) value );
}
else if ( value instanceof Long || value instanceof Integer)
else if ( value instanceof Long || value instanceof Integer )
{
packer.pack( ((Number) value).longValue() );
}
Expand Down
Expand Up @@ -47,13 +47,13 @@ public class BoltConfigIT
public Neo4jWithSocket server = new Neo4jWithSocket( getClass(),
settings ->
{
settings.put( new BoltConnector("bolt").type.name(), "BOLT" );
settings.put( new BoltConnector("bolt").enabled.name(), "true" );
settings.put( new BoltConnector("bolt").address.name(), "localhost:7888" );
settings.put( new BoltConnector("1").type.name(), "BOLT" );
settings.put( new BoltConnector("1").enabled.name(), "true" );
settings.put( new BoltConnector("1").address.name(), "localhost:7687" );
settings.put( new BoltConnector("1").encryption_level.name(), REQUIRED.name() );
settings.put( new BoltConnector( "bolt" ).type.name(), "BOLT" );
settings.put( new BoltConnector( "bolt" ).enabled.name(), "true" );
settings.put( new BoltConnector( "bolt" ).address.name(), "localhost:7888" );
settings.put( new BoltConnector( "1" ).type.name(), "BOLT" );
settings.put( new BoltConnector( "1" ).enabled.name(), "true" );
settings.put( new BoltConnector( "1" ).address.name(), "localhost:7687" );
settings.put( new BoltConnector( "1" ).encryption_level.name(), REQUIRED.name() );
} );
@Rule
public SuppressOutput suppressOutput = SuppressOutput.suppressAll();
Expand Down
Expand Up @@ -38,7 +38,7 @@

import static java.util.Arrays.asList;

@RunWith(Parameterized.class)
@RunWith( Parameterized.class )
public class ConnectionIT
{
@Rule
Expand All @@ -47,10 +47,10 @@ public class ConnectionIT
@Rule
public Neo4jWithSocket server = new Neo4jWithSocket( getClass() );

@Parameterized.Parameter(0)
@Parameterized.Parameter( 0 )
public TransportConnection connection;

@Parameterized.Parameter(1)
@Parameterized.Parameter( 1 )
public HostnamePort address;

@Parameterized.Parameters
Expand Down
Expand Up @@ -19,17 +19,17 @@
*/
package org.neo4j.bolt.v1.transport.integration;

import org.junit.rules.ExternalResource;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Consumer;
import java.util.function.Supplier;

import org.junit.rules.ExternalResource;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;

import org.neo4j.bolt.BoltKernelExtension;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction;
Expand Down Expand Up @@ -110,7 +110,7 @@ public void shutdownDatabase()
{
try
{
if ( gdb != null)
if ( gdb != null )
{
gdb.shutdown();
}
Expand Down

0 comments on commit 0f9b33a

Please sign in to comment.