Skip to content

Commit

Permalink
Checkstyle line length rule
Browse files Browse the repository at this point in the history
Enable line length rule.
Set limit to be a bit higher then official code style (120 symbols)
because of too many violations, and editors that are not that strict
with reformatting lines that are over limit.
  • Loading branch information
MishaDemianenko committed May 14, 2017
1 parent 0a3a9ff commit 6cc2ebb
Show file tree
Hide file tree
Showing 284 changed files with 1,833 additions and 1,191 deletions.
4 changes: 4 additions & 0 deletions build/checkstyle.xml
Expand Up @@ -88,6 +88,10 @@
<module name="MultipleVariableDeclarations"/> <module name="MultipleVariableDeclarations"/>
<module name="GenericWhitespace"/> <module name="GenericWhitespace"/>
<module name="ExplicitInitialization"/> <module name="ExplicitInitialization"/>
<module name="LineLength">
<property name="max" value="140"/>
<property name="ignorePattern" value="a href|href|http://|https://"/>
</module>
</module> </module>


</module> </module>
Expand Up @@ -65,7 +65,8 @@


public class Certificates public class Certificates
{ {
/** Generating SSL certificates takes a long time. This non-official setting allows us to use a fast source of randomness when running tests */ /* Generating SSL certificates takes a long time.
* This non-official setting allows us to use a fast source of randomness when running tests */
private static final boolean useInsecureCertificateGeneration = Boolean.getBoolean( "org.neo4j.useInsecureCertificateGeneration" ); private static final boolean useInsecureCertificateGeneration = Boolean.getBoolean( "org.neo4j.useInsecureCertificateGeneration" );
private static final String CERTIFICATE_TYPE = "X.509"; private static final String CERTIFICATE_TYPE = "X.509";
private static final String DEFAULT_ENCRYPTION = "RSA"; private static final String DEFAULT_ENCRYPTION = "RSA";
Expand Down
Expand Up @@ -105,7 +105,6 @@ public void start() throws Throwable
// throw checked exceptions, but they actually do. The compiler won't let us catch them explicitly because in theory // throw checked exceptions, but they actually do. The compiler won't let us catch them explicitly because in theory
// they shouldn't be possible, so we have to catch Throwable and do our own checks to grab them // they shouldn't be possible, so we have to catch Throwable and do our own checks to grab them


// In any case, we do all this just in order to throw a more helpful bind exception, oh, and here's that part coming right now!
if ( e instanceof BindException ) if ( e instanceof BindException )
{ {
throw new PortBindException( initializer.address(), (BindException) e ); throw new PortBindException( initializer.address(), (BindException) e );
Expand Down
Expand Up @@ -65,7 +65,8 @@ public static ValueRelationship unpack( Neo4jPack.Unpacker unpacker )
char signature = unpacker.unpackStructSignature(); char signature = unpacker.unpackStructSignature();
if ( signature != Neo4jPack.RELATIONSHIP ) if ( signature != Neo4jPack.RELATIONSHIP )
{ {
throw new BoltIOException( Status.Request.InvalidFormat, "Expected a relationship structure, recieved 0x" + Integer.toHexString( signature ) ); throw new BoltIOException( Status.Request.InvalidFormat,
"Expected a relationship structure, recieved 0x" + Integer.toHexString( signature ) );
} }
if ( numFields != STRUCT_FIELD_COUNT ) if ( numFields != STRUCT_FIELD_COUNT )
{ {
Expand Down
Expand Up @@ -295,7 +295,8 @@ private BoltResultHandle execute( MutableTransactionState ctx, SPI spi,
} }


@Override @Override
void streamResult( MutableTransactionState ctx, ThrowingConsumer<BoltResult, Exception> resultConsumer ) throws Exception void streamResult( MutableTransactionState ctx,
ThrowingConsumer<BoltResult,Exception> resultConsumer ) throws Exception
{ {
assert ctx.currentResult != null; assert ctx.currentResult != null;
resultConsumer.accept( ctx.currentResult ); resultConsumer.accept( ctx.currentResult );
Expand Down
Expand Up @@ -110,23 +110,24 @@ private BoltV1Dechunker createDechunker( BoltResponseMessageWriter responseHandl
} }


/* /*
* Ths methods below are used to track in-flight messages (messages the client has sent us that are waiting to be processed). We use this information * Ths methods below are used to track in-flight messages (messages the client has sent us that are waiting
* to determine when to explicitly flush our output buffers - if there are no more pending messages when a message is done processing, we should flush * to be processed). We use this information to determine when to explicitly flush our output buffers - if there
* the buffers for the session. * are no more pending messages when a message is done processing, we should flush the buffers for the session.
*/ */
private void onMessageStarted() private void onMessageStarted()
{ {
inFlight.incrementAndGet(); inFlight.incrementAndGet();
} }


// Note: This will get called from another thread; specifically, while most of the code in this class runs in an IO Thread, this method gets // Note: This will get called from another thread; specifically, while most of the code in this class runs in an
// called from a the session worker thread. This smells bad, and can likely be resolved by moving this whole "when to flush" logic to something // IO Thread, this method gets called from a the session worker thread. This smells bad, and can likely be
// that hooks into ThreadedSessions somehow, since that class has a lot of knowledge about when there are no pending requests. // resolved by moving this whole "when to flush" logic to something that hooks into ThreadedSessions somehow,
// since that class has a lot of knowledge about when there are no pending requests.
private void onMessageDone() private void onMessageDone()
{ {
// If this is the last in-flight message, and we're not in the middle of reading another message over the wire // If this is the last in-flight message, and we're not in the middle of reading another message over the wire
// If we are in the middle of a message, we assume there's no need for us to flush partial outbound buffers, we simply // If we are in the middle of a message, we assume there's no need for us to flush partial outbound buffers,
// wait for more stuff to do to fill the buffers up in order to use network buffers maximally. // we simply wait for more stuff to do to fill the buffers up in order to use network buffers maximally.
if ( inFlight.decrementAndGet() == 0 && !dechunker.isInMiddleOfAMessage() ) if ( inFlight.decrementAndGet() == 0 && !dechunker.isInMiddleOfAMessage() )
{ {
try try
Expand Down
Expand Up @@ -123,8 +123,10 @@ public synchronized PackOutput writeDouble( double value ) throws IOException
@Override @Override
public PackOutput writeBytes( ByteBuffer data ) throws IOException public PackOutput writeBytes( ByteBuffer data ) throws IOException
{ {
// TODO: If data is larger than our chunk size or so, we're very likely better off just passing this ByteBuffer on rather than doing the copy here // TODO: If data is larger than our chunk size or so, we're very likely better off just passing this ByteBuffer
// TODO: *however* note that we need some way to find out when the data has been written (and thus the buffer can be re-used) if we take that approach // on rather than doing the copy here
// TODO: *however* note that we need some way to find out when the data has been written (and thus the buffer
// can be re-used) if we take that approach
// See the comment in #newBuffer for an approach that would allow that // See the comment in #newBuffer for an approach that would allow that
while ( data.remaining() > 0 ) while ( data.remaining() > 0 )
{ {
Expand Down Expand Up @@ -193,9 +195,11 @@ private synchronized void closeChunkIfOpen()
private void newBuffer() private void newBuffer()
{ {
// Assumption: We're using nettys buffer pooling here // Assumption: We're using nettys buffer pooling here
// If we wanted to, we can optimize this further and restrict memory usage by using our own ByteBuf impl. Each Output instance would have, say, 3 // If we wanted to, we can optimize this further and restrict memory usage by using our own ByteBuf impl.
// buffers that it rotates. Fill one up, send it to be async flushed, fill the next one up, etc. When release is called by Netty, push buffer back // Each Output instance would have, say, 3 buffers that it rotates. Fill one up, send it to be async flushed,
// onto our local stack. That way there are no global data structures for managing memory, no fragmentation and a fixed amount of RAM per session used. // fill the next one up, etc. When release is called by Netty, push buffer back onto our local stack. That
// way there are no global data structures for managing memory, no fragmentation and a fixed amount of
// RAM per session used.
buffer = channel.alloc().buffer( bufferSize, bufferSize ); buffer = channel.alloc().buffer( bufferSize, bufferSize );
chunkOpen = false; chunkOpen = false;
} }
Expand Down
Expand Up @@ -35,7 +35,9 @@ public void shouldEncodeDecode() throws Throwable
assertEncodes( "a" ); assertEncodes( "a" );
assertEncodes( "ä" ); assertEncodes( "ä" );
assertEncodes( "äa" ); assertEncodes( "äa" );
assertEncodes( "基本上,電腦只是處理數位。它們指定一個數位,來儲存字母或其他字元。在創造Unicode之前,有數百種指定這些數位的編碼系統。沒有一個編碼可以包含足夠的字元,例如:單單歐洲共同體就需要好幾種不同的編碼來包括所有的語言。即使是單一種語言,例如英語,也沒有哪一個編碼可以適用於所有的字母、標點符號,和常用的技術符號" ); assertEncodes( "基本上,電腦只是處理數位。它們指定一個數位,來儲存字母或其他字元。在創造Unicode之前," +
"有數百種指定這些數位的編碼系統。沒有一個編碼可以包含足夠的字元,例如:單單歐洲共同體就需要好幾種不同的編碼來包括所有的語言。" +
"即使是單一種語言,例如英語,也沒有哪一個編碼可以適用於所有的字母、標點符號,和常用的技術符號" );
assertEncodes( new String( new byte[(int) Math.pow( 2, 18 )] ) ); // bigger than default buffer size assertEncodes( new String( new byte[(int) Math.pow( 2, 18 )] ) ); // bigger than default buffer size
} }


Expand Down
Expand Up @@ -125,7 +125,9 @@ public void shouldIncludePlanIfPresent() throws Throwable
Map<String,Object> meta = metadataOf( stream ); Map<String,Object> meta = metadataOf( stream );


// Then // Then
assertThat( meta.get( "plan" ).toString(), equalTo( "{args={arg1=1}, children=[{args={arg2=1}, children=[], identifiers=[id2], operatorType=Scan}], identifiers=[id1], operatorType=Join}" ) ); assertThat( meta.get( "plan" ).toString(),
equalTo( "{args={arg1=1}, children=[{args={arg2=1}, children=[], " +
"identifiers=[id2], operatorType=Scan}], identifiers=[id1], operatorType=Join}" ) );
} }


@Test @Test
Expand Down Expand Up @@ -179,7 +181,12 @@ public void shouldIncludeNotificationsIfPresent() throws Throwable


// Then // Then
assertThat( meta.get( "notifications" ).toString(), equalTo( assertThat( meta.get( "notifications" ).toString(), equalTo(
"[{severity=WARNING, description=The hinted index does not exist, please check the schema, code=Neo.ClientError.Schema.IndexNotFound, title=The request (directly or indirectly) referred to an index that does not exist.}, {severity=WARNING, description=Using COST planner is unsupported for this query, please use RULE planner instead, code=Neo.ClientNotification.Statement.PlannerUnsupportedWarning, position={offset=4, column=6, line=5}, title=This query is not supported by the COST planner.}]" "[{severity=WARNING, description=The hinted index does not exist, please check the schema, " +
"code=Neo.ClientError.Schema.IndexNotFound, title=The request (directly or indirectly) referred to an " +
"index that does not exist.}, {severity=WARNING, description=Using COST planner is unsupported for " +
"this query, please use RULE planner instead, " +
"code=Neo.ClientNotification.Statement.PlannerUnsupportedWarning, position={offset=4, column=6, line=5}, " +
"title=This query is not supported by the COST planner.}]"
) ); ) );
} }


Expand Down Expand Up @@ -235,13 +242,15 @@ public long getPageCacheMisses()
}, children ); }, children );
} }


private static ExecutionPlanDescription plan( final String name, final Map<String, Object> args, final List<String> identifiers, final ExecutionPlanDescription ... children ) private static ExecutionPlanDescription plan( final String name, final Map<String, Object> args,
final List<String> identifiers, final ExecutionPlanDescription ... children )
{ {
return plan( name, args, identifiers, null, children ); return plan( name, args, identifiers, null, children );
} }


private static ExecutionPlanDescription plan( final String name, final Map<String, Object> args, final List<String> identifiers, final private static ExecutionPlanDescription plan( final String name, final Map<String, Object> args,
ExecutionPlanDescription.ProfilerStatistics profile, final ExecutionPlanDescription ... children ) final List<String> identifiers, final ExecutionPlanDescription.ProfilerStatistics profile,
final ExecutionPlanDescription ... children )
{ {
return new ExecutionPlanDescription() return new ExecutionPlanDescription()
{ {
Expand Down
Expand Up @@ -59,7 +59,8 @@ public static BoltStateMachine newMachine( BoltStateMachine.State state ) throws
return machine; return machine;
} }


public static BoltStateMachine newMachineWithTransaction( BoltStateMachine.State state ) throws AuthenticationException, BoltConnectionFatality public static BoltStateMachine newMachineWithTransaction( BoltStateMachine.State state )
throws AuthenticationException, BoltConnectionFatality
{ {
BoltStateMachine machine = newMachine(); BoltStateMachine machine = newMachine();
init( machine ); init( machine );
Expand Down
Expand Up @@ -19,17 +19,17 @@
*/ */
package org.neo4j.bolt.v1.runtime.integration; package org.neo4j.bolt.v1.runtime.integration;


import org.hamcrest.CoreMatchers;
import org.junit.Rule;
import org.junit.Test;

import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;


import org.hamcrest.CoreMatchers;
import org.junit.Rule;
import org.junit.Test;

import org.neo4j.bolt.testing.BoltResponseRecorder; import org.neo4j.bolt.testing.BoltResponseRecorder;
import org.neo4j.bolt.testing.RecordedBoltResponse; import org.neo4j.bolt.testing.RecordedBoltResponse;
import org.neo4j.bolt.v1.runtime.BoltConnectionDescriptor; import org.neo4j.bolt.v1.runtime.BoltConnectionDescriptor;
Expand Down Expand Up @@ -469,7 +469,8 @@ public void shouldSupportUsingPeriodicCommitInSession() throws Exception
"USING PERIODIC COMMIT " + batch + "\n" + "USING PERIODIC COMMIT " + batch + "\n" +
"LOAD CSV WITH HEADERS FROM {csvFileUrl} AS l\n" + "LOAD CSV WITH HEADERS FROM {csvFileUrl} AS l\n" +
"MATCH (c:Class {name: l.class_name})\n" + "MATCH (c:Class {name: l.class_name})\n" +
"CREATE (s:Sample {sepal_length: l.sepal_length, sepal_width: l.sepal_width, petal_length: l.petal_length, petal_width: l.petal_width})\n" + "CREATE (s:Sample {sepal_length: l.sepal_length, sepal_width: l.sepal_width, " +
"petal_length: l.petal_length, petal_width: l.petal_width})\n" +
"CREATE (c)<-[:HAS_CLASS]-(s)\n" + "CREATE (c)<-[:HAS_CLASS]-(s)\n" +
"RETURN count(*) AS c", "RETURN count(*) AS c",
params params
Expand Down
Expand Up @@ -70,7 +70,8 @@ public void evaluate() throws Throwable
config.put( GraphDatabaseSettings.auth_enabled, Boolean.toString( authEnabled ) ); config.put( GraphDatabaseSettings.auth_enabled, Boolean.toString( authEnabled ) );
gdb = (GraphDatabaseAPI) new TestGraphDatabaseFactory().newImpermanentDatabase( config ); gdb = (GraphDatabaseAPI) new TestGraphDatabaseFactory().newImpermanentDatabase( config );
DependencyResolver resolver = gdb.getDependencyResolver(); DependencyResolver resolver = gdb.getDependencyResolver();
Authentication authentication = authentication( resolver.resolveDependency( AuthManager.class ), resolver.resolveDependency( UserManagerSupplier.class ) ); Authentication authentication = authentication( resolver.resolveDependency( AuthManager.class ),
resolver.resolveDependency( UserManagerSupplier.class ) );
boltFactory = new BoltFactoryImpl( boltFactory = new BoltFactoryImpl(
gdb, gdb,
new UsageData( null ), new UsageData( null ),
Expand Down
Expand Up @@ -68,7 +68,8 @@ public void shouldNotTalkToChannelDirectlyOnFatalError() throws Throwable
// When // When
protocol.handle( mock(ChannelHandlerContext.class), bomb ); protocol.handle( mock(ChannelHandlerContext.class), bomb );


// Then the protocol should not mess with the channel (because it runs on the IO thread, and only the worker thread should produce writes) // Then the protocol should not mess with the channel (because it runs on the IO thread,
// and only the worker thread should produce writes)
verifyNoMoreInteractions( outputChannel ); verifyNoMoreInteractions( outputChannel );


// But instead make sure the state machine is shut down // But instead make sure the state machine is shut down
Expand Down
Expand Up @@ -150,7 +150,8 @@ public void visit(
@Override @Override
public FieldVisitor visitField( int access, String name, String desc, String signature, Object value ) public FieldVisitor visitField( int access, String name, String desc, String signature, Object value )
{ {
printf( " %s %s %s%s;%n", Modifier.toString( access ), getType( desc ).getClassName(), name, value == null ? "" : (" = " + value) ); printf( " %s %s %s%s;%n", Modifier.toString( access ), getType( desc ).getClassName(), name,
value == null ? "" : (" = " + value) );
return super.visitField( access, name, desc, signature, value ); return super.visitField( access, name, desc, signature, value );
} }


Expand Down
Expand Up @@ -160,16 +160,26 @@ public static TypeReference[] typeReferences( Class<?>[] types )
private final String declaringClassName; private final String declaringClassName;
private final int modifiers; private final int modifiers;


public static final TypeReference VOID = new TypeReference( "", "void", true, false, false, "", void.class.getModifiers() ); public static final TypeReference VOID =
public static final TypeReference OBJECT = new TypeReference( "java.lang", "Object", false, false, false, "", Object.class.getModifiers() ); new TypeReference( "", "void", true, false, false, "", void.class.getModifiers() );
public static final TypeReference BOOLEAN = new TypeReference( "", "boolean", true, false, false, "", boolean.class.getModifiers() ); public static final TypeReference OBJECT =
public static final TypeReference INT = new TypeReference( "", "int", true, false, false, "", int.class.getModifiers() ); new TypeReference( "java.lang", "Object", false, false, false, "", Object.class.getModifiers() );
public static final TypeReference LONG = new TypeReference( "", "long", true, false, false, "", long.class.getModifiers() ); public static final TypeReference BOOLEAN =
public static final TypeReference DOUBLE = new TypeReference( "", "double", true, false, false, "", double.class.getModifiers() ); new TypeReference( "", "boolean", true, false, false, "", boolean.class.getModifiers() );
public static final TypeReference BOOLEAN_ARRAY = new TypeReference( "", "boolean", false, true, false, "", boolean.class.getModifiers() ); public static final TypeReference INT =
public static final TypeReference INT_ARRAY = new TypeReference( "", "int", false, true, false, "", int.class.getModifiers() ); new TypeReference( "", "int", true, false, false, "", int.class.getModifiers() );
public static final TypeReference LONG_ARRAY = new TypeReference( "", "long", false, true, false, "", long.class.getModifiers() ); public static final TypeReference LONG =
public static final TypeReference DOUBLE_ARRAY = new TypeReference( "", "double", false, true, false, "", double.class.getModifiers() ); new TypeReference( "", "long", true, false, false, "", long.class.getModifiers() );
public static final TypeReference DOUBLE =
new TypeReference( "", "double", true, false, false, "", double.class.getModifiers() );
public static final TypeReference BOOLEAN_ARRAY =
new TypeReference( "", "boolean", false, true, false, "", boolean.class.getModifiers() );
public static final TypeReference INT_ARRAY =
new TypeReference( "", "int", false, true, false, "", int.class.getModifiers() );
public static final TypeReference LONG_ARRAY =
new TypeReference( "", "long", false, true, false, "", long.class.getModifiers() );
public static final TypeReference DOUBLE_ARRAY =
new TypeReference( "", "double", false, true, false, "", double.class.getModifiers() );
static final TypeReference[] NO_TYPES = new TypeReference[0]; static final TypeReference[] NO_TYPES = new TypeReference[0];


TypeReference( String packageName, String name, boolean isPrimitive, boolean isArray, TypeReference( String packageName, String name, boolean isPrimitive, boolean isArray,
Expand Down
Expand Up @@ -20,8 +20,9 @@
package org.neo4j.function; package org.neo4j.function;


/** /**
* Represents an operation on a single operand that produces a result of the same type as its operand. This is a specialization of {@link ThrowingBiFunction} * Represents an operation on a single operand that produces a result of the same type as its operand.
* for the case where the operand and result are of the same type. * This is a specialization of {@link ThrowingBiFunction} for the case where the operand and result are of the same
* type.
* *
* @param <T> the type of the operand and result of the operator * @param <T> the type of the operand and result of the operator
* @param <E> the type of exception that may be thrown from the operator * @param <E> the type of exception that may be thrown from the operator
Expand Down
Expand Up @@ -20,8 +20,8 @@
package org.neo4j.function; package org.neo4j.function;


/** /**
* Represents an operation that accepts a single input argument and returns no result. Unlike most other functional interfaces, ThrowingConsumer is expected to * Represents an operation that accepts a single input argument and returns no result.
* operate via side-effects. * Unlike most other functional interfaces, ThrowingConsumer is expected to operate via side-effects.
* *
* @param <T> the type of the input to the operation * @param <T> the type of the input to the operation
* @param <E> the type of exception that may be thrown from the function * @param <E> the type of exception that may be thrown from the function
Expand Down

0 comments on commit 6cc2ebb

Please sign in to comment.