Skip to content

Commit

Permalink
Added MethodParamPad checkstyle rule
Browse files Browse the repository at this point in the history
  • Loading branch information
lutovich committed Jul 12, 2016
1 parent eb531ee commit 1bbb110
Show file tree
Hide file tree
Showing 26 changed files with 77 additions and 174 deletions.
1 change: 1 addition & 0 deletions build/checkstyle.xml
Expand Up @@ -52,6 +52,7 @@
<module name="RedundantImport"/>
<module name="MissingSwitchDefault"/>
<module name="DefaultComesLast"/>
<module name="MethodParamPad"/>
<module name="EmptyCatchBlock">
<property name="exceptionVariableName" value="ignore|ignored"/>
</module>
Expand Down
Expand Up @@ -274,7 +274,7 @@ public <E extends Exception> void read( MessageHandler<E> output ) throws IOExce
catch( PackStream.PackStreamException e )
{
throw new BoltIOException( Status.Request.InvalidFormat,
"Unable to read " + messageTypeName (type) + " message. " +
"Unable to read " + messageTypeName( type ) + " message. " +
"Error was: " + e.getMessage(), e );
}
}
Expand Down
Expand Up @@ -58,9 +58,9 @@ public void checkReference( RECORD record, NodeRecord nodeRecord,
DynamicNodeLabels dynamicNodeLabels = (DynamicNodeLabels) nodeLabels;
long firstRecordId = dynamicNodeLabels.getFirstDynamicRecordId();
RecordReference<DynamicRecord> firstRecordReference = records.nodeLabels( firstRecordId );
engine.comparativeCheck( firstRecordReference,
new LabelChainWalker<RECORD, REPORT>
(new ExpectedNodeLabelsChecker( nodeRecord )) );
ExpectedNodeLabelsChecker expectedNodeLabelsChecker = new ExpectedNodeLabelsChecker( nodeRecord );
LabelChainWalker<RECORD,REPORT> checker = new LabelChainWalker<>( expectedNodeLabelsChecker );
engine.comparativeCheck( firstRecordReference, checker );
nodeRecord.getDynamicLabelRecords(); // I think this is empty in production
}
else
Expand Down
Expand Up @@ -81,7 +81,7 @@ public void shouldReportInvalidLabelReferences() throws Exception
IndexRule rule = IndexRule.indexRule( schemaRuleId, labelId, propertyKeyId, providerDescriptor );
when( checker().ruleAccess.loadSingleSchemaRule( schemaRuleId ) ).thenReturn( rule );

LabelTokenRecord labelTokenRecord = add ( notInUse( new LabelTokenRecord( labelId ) ) );
LabelTokenRecord labelTokenRecord = add( notInUse( new LabelTokenRecord( labelId ) ) );
add(inUse( new PropertyKeyTokenRecord( propertyKeyId ) ) );

// when
Expand Down
Expand Up @@ -48,14 +48,12 @@
import org.neo4j.storageengine.api.schema.IndexReader;
import org.neo4j.storageengine.api.schema.IndexSampler;

import static java.util.Arrays.asList;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;

import static java.util.Arrays.asList;

import static org.neo4j.collection.primitive.PrimitiveLongCollections.emptyIterator;
import static org.neo4j.kernel.api.properties.Property.stringProperty;
import static org.neo4j.kernel.impl.store.record.IndexRule.constraintIndexRule;
Expand Down Expand Up @@ -160,10 +158,8 @@ private IndexAccessors indexContaining( IndexRule indexRule, Map<Object, long[]>
{
IndexAccessorStub reader = new IndexAccessorStub( entries );
IndexAccessors indexes = mock( IndexAccessors.class );
when( indexes.accessorFor( any( IndexRule.class ) ) )
.thenReturn( reader );
when (indexes.rules() )
.thenReturn( asList(indexRule) );
when( indexes.accessorFor( any( IndexRule.class ) ) ).thenReturn( reader );
when( indexes.rules() ).thenReturn( asList( indexRule ) );
return indexes;
}

Expand Down
Expand Up @@ -141,7 +141,7 @@ public static File targetDirectory( Class<?> klass, String suffix )

private static File obtainTargetDirectory( boolean create, String specSuiteName, String suffix )
{
File directory = new File( new File ( new File( "target" ), specSuiteName ), suffix ).getAbsoluteFile();
File directory = new File( new File( new File( "target" ), specSuiteName ), suffix ).getAbsoluteFile();
if ( !directory.exists() )
{
if ( !(create && directory.mkdirs()) )
Expand Down
Expand Up @@ -196,7 +196,7 @@ public void import4097Labels() throws Exception

tx.success();
ResourceIterator<Node> nodes = dbRule.findNodes( DynamicLabel.label( "FIRST 4096" ) );
assertEquals (1, Iterators.asList(nodes).size() );
assertEquals( 1, Iterators.asList( nodes ).size() );
nodes = dbRule.findNodes( DynamicLabel.label( "SECOND 4096" ) );
assertEquals( 1, Iterators.asList( nodes ).size() );
}
Expand Down
97 changes: 0 additions & 97 deletions community/io/src/test/java/org/neo4j/test/TraceCounter.java

This file was deleted.

Expand Up @@ -46,7 +46,7 @@ public void call( IndexManager indexManager )
}
};

private static final FacadeMethod<IndexManager> FOR_NODES_WITH_CONFIGURATION = new FacadeMethod<IndexManager>(
private static final FacadeMethod<IndexManager> FOR_NODES_WITH_CONFIG = new FacadeMethod<IndexManager>(
"Index<Node> forNodes( String indexName, Map<String, String> customConfiguration )" )
{
@Override
Expand Down Expand Up @@ -89,9 +89,8 @@ public void call( IndexManager indexManager )
}
};

private static final FacadeMethod<IndexManager> FOR_RELATIONSHIPS_WITH_CONFIGURATION = new
FacadeMethod<IndexManager>
( "RelationshipIndex forRelationships( String indexName, Map<String, String> customConfiguration )" )
private static final FacadeMethod<IndexManager> FOR_RELATIONSHIPS_WITH_CONFIG = new FacadeMethod<IndexManager>(
"RelationshipIndex forRelationships( String indexName, Map<String, String> customConfiguration )" )
{
@Override
public void call( IndexManager indexManager )
Expand All @@ -117,11 +116,11 @@ public void call( IndexManager indexManager )
unmodifiableCollection( asList(
EXISTS_FOR_NODES,
FOR_NODES,
FOR_NODES_WITH_CONFIGURATION,
FOR_NODES_WITH_CONFIG,
NODE_INDEX_NAMES,
EXISTS_FOR_RELATIONSHIPS,
FOR_RELATIONSHIPS,
FOR_RELATIONSHIPS_WITH_CONFIGURATION,
FOR_RELATIONSHIPS_WITH_CONFIG,
RELATIONSHIP_INDEX_NAMES
) );
}
Expand Up @@ -19,6 +19,8 @@
*/
package org.neo4j.helpers;

import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
Expand All @@ -27,8 +29,6 @@
import java.util.List;
import java.util.Map;

import org.junit.Test;

import org.neo4j.helpers.Args.Option;
import org.neo4j.kernel.impl.util.Converters;
import org.neo4j.kernel.impl.util.Validator;
Expand All @@ -41,7 +41,6 @@
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;

import static org.neo4j.helpers.collection.MapUtil.stringMap;

public class TestArgs
Expand Down Expand Up @@ -80,7 +79,7 @@ public void testParameterWithDashValue()
String [] line = { "-file", "-" };
Args args = Args.parse( line );
assertEquals( 1, args.asMap().size() );
assertEquals( "-", args.get ( "file", null ) );
assertEquals( "-", args.get( "file", null ) );
assertTrue( args.orphans().isEmpty() );
}

Expand Down
Expand Up @@ -47,7 +47,7 @@ public class TestPlaceboTransaction
@Before
public void before() throws Exception
{
ThreadToStatementContextBridge bridge = mock (ThreadToStatementContextBridge.class );
ThreadToStatementContextBridge bridge = mock( ThreadToStatementContextBridge.class );
when( bridge.get() ).thenReturn( mock( Statement.class ) );
kernelTransaction = spy( KernelTransaction.class );
Statement statement = mock( Statement.class );
Expand Down
Expand Up @@ -170,7 +170,7 @@ private int compare( DefinedProperty leftProperty, DefinedProperty rightProperty
{
int leftComparison = DefinedProperty.COMPARATOR.compare( leftProperty, rightProperty );
int rightComparison = DefinedProperty.COMPARATOR.compare( rightProperty, leftProperty );
assertThat( sign ( leftComparison ) , equalTo( -sign( rightComparison ) ) );
assertThat( sign( leftComparison ), equalTo( -sign( rightComparison ) ) );
return leftComparison;
}

Expand Down
Expand Up @@ -241,7 +241,7 @@ public void shouldDeliverUpdatesThatOccurDuringPopulationToPopulator() throws Ex
InOrder order = inOrder( populator, accessor, updater);
order.verify( populator ).create();
order.verify( populator ).includeSample( add( 1, "value1" ) );
order.verify( populator ).add( Mockito.anyListOf (NodePropertyUpdate.class));
order.verify( populator ).add( Mockito.anyListOf( NodePropertyUpdate.class ) );

// invoked from indexAllNodes(), empty because the id we added (2) is bigger than the one we indexed (1)
//
Expand Down
Expand Up @@ -227,7 +227,7 @@ public void before() throws Exception
mock( ConstraintIndexCreator.class ), mock( LegacyIndexStore.class ) );

storeStatement = mock(StoreStatement.class);
when (state.getStoreStatement()).thenReturn( storeStatement );
when( state.getStoreStatement() ).thenReturn( storeStatement );
}

private static <T> Answer<Iterator<T>> asAnswer( final Iterable<T> values )
Expand Down
Expand Up @@ -332,7 +332,7 @@ public void shouldKernelPanicIfNotAbleToWriteACheckPoint() throws Throwable
// Given
IOException ioex = new IOException( "boom!" );
FlushablePositionAwareChannel channel = mock( FlushablePositionAwareChannel.class, RETURNS_MOCKS );
when (channel.put( anyByte() ) ).thenReturn( channel );
when( channel.put( anyByte() ) ).thenReturn( channel );
when( channel.putLong( anyLong() ) ).thenThrow( ioex );
when( channel.put( anyByte() ) ).thenThrow( ioex );
when( logFile.getWriter() ).thenReturn( channel );
Expand Down
Expand Up @@ -1009,8 +1009,8 @@ public Response addToNodeIndex( @PathParam("indexName") String indexName, @Query
String.valueOf( entityBody.get( "key" ) ),
getOrCreateValue, extractNodeIdOrNull( getStringOrNull(
entityBody, "uri" ) ), getMapOrNull( entityBody, "properties" ) );
return result.other() ? output.created( result.first() ) : output.okIncludeLocation( result.first
() );
return result.other() ? output.created( result.first() )
: output.okIncludeLocation( result.first() );

case CreateOrFail:
entityBody = input.readMap( postBody, "key", "value" );
Expand Down Expand Up @@ -1107,8 +1107,8 @@ public Response addToRelationshipIndex( @PathParam("indexName") String indexName
entityBody = input.readMap( postBody, "key", "value" );
result = actions.getOrCreateIndexedRelationship( indexName,
String.valueOf( entityBody.get( "key" ) ),
String.valueOf( entityBody.get( "value" ) ), extractRelationshipIdOrNull( getStringOrNull
( entityBody, "uri" ) ),
String.valueOf( entityBody.get( "value" ) ),
extractRelationshipIdOrNull( getStringOrNull( entityBody, "uri" ) ),
extractNodeIdOrNull( getStringOrNull( entityBody, "start" ) ),
getStringOrNull( entityBody, "type" ), extractNodeIdOrNull( getStringOrNull( entityBody,
"end" ) ),
Expand All @@ -1119,8 +1119,8 @@ public Response addToRelationshipIndex( @PathParam("indexName") String indexName
entityBody = input.readMap( postBody, "key", "value" );
result = actions.getOrCreateIndexedRelationship( indexName,
String.valueOf( entityBody.get( "key" ) ),
String.valueOf( entityBody.get( "value" ) ), extractRelationshipIdOrNull( getStringOrNull
( entityBody, "uri" ) ),
String.valueOf( entityBody.get( "value" ) ),
extractRelationshipIdOrNull( getStringOrNull( entityBody, "uri" ) ),
extractNodeIdOrNull( getStringOrNull( entityBody, "start" ) ),
getStringOrNull( entityBody, "type" ), extractNodeIdOrNull( getStringOrNull( entityBody,
"end" ) ),
Expand Down
Expand Up @@ -135,9 +135,10 @@ public void shouldReturn404WhenPropertyWhichDoesNotExistRemovedFromRelationshipS
{
data.get();
Relationship loves = getFirstRelationshipFromRomeoNode();
gen().withHeader( StreamingFormat.STREAM_HEADER, "true" ).expectedStatus( Status.NOT_FOUND.getStatusCode
() ).delete(
getPropertiesUri( loves ) + "/non-existent" ).entity();
gen().withHeader( StreamingFormat.STREAM_HEADER, "true" )
.expectedStatus( Status.NOT_FOUND.getStatusCode() )
.delete( getPropertiesUri( loves ) + "/non-existent" )
.entity();
}

@Test
Expand Down
Expand Up @@ -168,8 +168,8 @@ public void listeningAt( URI me )
}
} );

stateMachines.addMessageProcessor( new HeartbeatRefreshProcessor( stateMachines.getOutgoing
(), context.getClusterContext() ) );
stateMachines.addMessageProcessor( new HeartbeatRefreshProcessor( stateMachines.getOutgoing(),
context.getClusterContext() ) );
input.addMessageProcessor( new HeartbeatIAmAliveProcessor( stateMachines.getOutgoing(),
context.getClusterContext() ) );

Expand Down
Expand Up @@ -167,8 +167,9 @@ private StateMachine getStateMachine( Class<?> proxyInterface )
if ( foundMatch )
// State machine could only partially handle this interface
{
exception = new IllegalArgumentException( "State machine for " + stateMachine.getMessageType
().getName() + " cannot handle method:" + method.getName() );
exception = new IllegalArgumentException(
"State machine for " + stateMachine.getMessageType().getName() +
" cannot handle method:" + method.getName() );
}

// Continue searching
Expand Down

0 comments on commit 1bbb110

Please sign in to comment.