Skip to content

Commit

Permalink
Enforce standard java variable names
Browse files Browse the repository at this point in the history
Apparently, it's hard to remember how standard java
variable name should look like, while the temptation
to surprise future code reader is irresistible.
  • Loading branch information
MishaDemianenko committed Mar 7, 2018
1 parent 7118397 commit cac0e7a
Show file tree
Hide file tree
Showing 37 changed files with 191 additions and 195 deletions.
3 changes: 3 additions & 0 deletions build/checkstyle.xml
Expand Up @@ -96,6 +96,9 @@
<module name="IllegalImport">
<property name="illegalPkgs" value="junit.framework"/>
</module>
<module name="LocalVariableName">
<property name="allowOneCharVarInForLoop" value="true"/>
</module>
</module>

</module>
Expand Up @@ -49,9 +49,9 @@ public class RequiredTransportEncryptionIT
public Neo4jWithSocket server = new Neo4jWithSocket( getClass(),
settings ->
{
Setting<BoltConnector.EncryptionLevel> encryption_level =
Setting<BoltConnector.EncryptionLevel> encryptionLevel =
new BoltConnector( DEFAULT_CONNECTOR_KEY ).encryption_level;
settings.put( encryption_level.name(), REQUIRED.name() );
settings.put( encryptionLevel.name(), REQUIRED.name() );
} );

@Parameterized.Parameter( 0 )
Expand Down
Expand Up @@ -231,10 +231,10 @@ protected void consolidate()
// arraySize = (int) Math.log( (double) nrNodes )+1;
// FibonacciHeapNode[] A = (FibonacciHeapNode[]) new Object[arraySize];
// FibonacciHeapNode[] A = new FibonacciHeapNode[arraySize];
ArrayList<FibonacciHeapNode> A = new ArrayList<>( arraySize );
ArrayList<FibonacciHeapNode> nodes = new ArrayList<>( arraySize );
for ( int i = 0; i < arraySize; ++i )
{
A.add( null );
nodes.add( null );
}
List<FibonacciHeapNode> rootNodes = new LinkedList<>();
rootNodes.add( minimum );
Expand All @@ -250,9 +250,9 @@ protected void consolidate()
continue;
}
int d = node.degree;
while ( A.get( d ) != null )
while ( nodes.get( d ) != null )
{
FibonacciHeapNode y = A.get( d );
FibonacciHeapNode y = nodes.get( d );
// swap?
if ( keyComparator.compare( node.key, y.key ) > 0 )
{
Expand All @@ -261,15 +261,15 @@ protected void consolidate()
y = tmp;
}
link( y, node );
A.set( d, null );
nodes.set( d, null );
++d;
}
A.set( d, node );
nodes.set( d, node );
}
// throw away the root list
minimum = null;
// and rebuild it from A
for ( FibonacciHeapNode node : A )
for ( FibonacciHeapNode node : nodes )
{
if ( node != null )
{
Expand Down
Expand Up @@ -66,14 +66,14 @@ private double distance( double latitude1, double longitude1,
latitude2 = Math.toRadians( latitude2 );
longitude2 = Math.toRadians( longitude2 );
double cLa1 = Math.cos( latitude1 );
double x_A = EARTH_RADIUS * cLa1 * Math.cos( longitude1 );
double y_A = EARTH_RADIUS * cLa1 * Math.sin( longitude1 );
double z_A = EARTH_RADIUS * Math.sin( latitude1 );
double xA = EARTH_RADIUS * cLa1 * Math.cos( longitude1 );
double yA = EARTH_RADIUS * cLa1 * Math.sin( longitude1 );
double zA = EARTH_RADIUS * Math.sin( latitude1 );
double cLa2 = Math.cos( latitude2 );
double x_B = EARTH_RADIUS * cLa2 * Math.cos( longitude2 );
double y_B = EARTH_RADIUS * cLa2 * Math.sin( longitude2 );
double z_B = EARTH_RADIUS * Math.sin( latitude2 );
return Math.sqrt( ( x_A - x_B ) * ( x_A - x_B ) + ( y_A - y_B )
* ( y_A - y_B ) + ( z_A - z_B ) * ( z_A - z_B ) );
double xB = EARTH_RADIUS * cLa2 * Math.cos( longitude2 );
double yB = EARTH_RADIUS * cLa2 * Math.sin( longitude2 );
double zB = EARTH_RADIUS * Math.sin( latitude2 );
return Math.sqrt( ( xA - xB ) * ( xA - xB ) + ( yA - yB )
* ( yA - yB ) + ( zA - zB ) * ( zA - zB ) );
}
}
Expand Up @@ -247,9 +247,9 @@ public void betterTentativePath()
graph.makeEdge( "3", "4", "weight", 0.013d );

// WHEN
WeightedPath best1_4 = finder.findSinglePath( node1, node4 );
WeightedPath best14 = finder.findSinglePath( node1, node4 );
// THEN
assertPath( best1_4, node1, node2, node3, node4 );
assertPath( best14, node1, node2, node3, node4 );
}

static EstimateEvaluator<Double> ESTIMATE_EVALUATOR = ( node, goal ) ->
Expand Down
Expand Up @@ -101,8 +101,8 @@ public UpdateResult call() throws Exception
while ( !shouldStop.get() )
{
boolean updateCounter = rng.nextBoolean();
int pf_flags = updateCounter ? PF_SHARED_WRITE_LOCK : PF_SHARED_READ_LOCK;
performReadOrUpdate( rng, updateCounter, pf_flags );
int pfFlags = updateCounter ? PF_SHARED_WRITE_LOCK : PF_SHARED_READ_LOCK;
performReadOrUpdate( rng, updateCounter, pfFlags );
}

return new UpdateResult( threadId, pageCounts );
Expand Down Expand Up @@ -512,10 +512,10 @@ public void pageCacheMustRemainInternallyConsistentWhenGettingRandomFailures() t
long maxPageId = pagedFile.getLastPageId();
boolean performingRead = rng.nextBoolean() && maxPageId != -1;
long startingPage = maxPageId < 0 ? 0 : rng.nextLong( maxPageId + 1 );
int pf_flags = performingRead ? PF_SHARED_READ_LOCK : PF_SHARED_WRITE_LOCK;
int pfFlags = performingRead ? PF_SHARED_READ_LOCK : PF_SHARED_WRITE_LOCK;
int pageSize = pagedFile.pageSize();

try ( PageCursor cursor = pagedFile.io( startingPage, pf_flags ) )
try ( PageCursor cursor = pagedFile.io( startingPage, pfFlags ) )
{
if ( performingRead )
{
Expand Down
Expand Up @@ -140,7 +140,7 @@ public void shouldReadLabels()
assertTrue( "should access defined node", nodes.next() );
labels = nodes.labels();
assertEquals( "number of labels", 1, labels.numberOfLabels() );
int _foo = labels.label( 0 );
int fooLabel = labels.label( 0 );
assertFalse( "should only access a single node", nodes.next() );

// when
Expand All @@ -150,7 +150,7 @@ public void shouldReadLabels()
assertTrue( "should access defined node", nodes.next() );
labels = nodes.labels();
assertEquals( "number of labels", 1, labels.numberOfLabels() );
int _bar = labels.label( 0 );
int barLabel = labels.label( 0 );
assertFalse( "should only access a single node", nodes.next() );

// when
Expand All @@ -160,12 +160,12 @@ public void shouldReadLabels()
assertTrue( "should access defined node", nodes.next() );
labels = nodes.labels();
assertEquals( "number of labels", 1, labels.numberOfLabels() );
int _baz = labels.label( 0 );
int bazLabel = labels.label( 0 );
assertFalse( "should only access a single node", nodes.next() );

assertNotEquals( "distinct labels", _foo, _bar );
assertNotEquals( "distinct labels", _foo, _baz );
assertNotEquals( "distinct labels", _bar, _baz );
assertNotEquals( "distinct labels", fooLabel, barLabel );
assertNotEquals( "distinct labels", fooLabel, bazLabel );
assertNotEquals( "distinct labels", barLabel, bazLabel );

// when
read.singleNode( barbaz, nodes );
Expand All @@ -174,14 +174,14 @@ public void shouldReadLabels()
assertTrue( "should access defined node", nodes.next() );
labels = nodes.labels();
assertEquals( "number of labels", 2, labels.numberOfLabels() );
if ( labels.label( 0 ) == _bar )
if ( labels.label( 0 ) == barLabel )
{
assertEquals( _baz, labels.label( 1 ) );
assertEquals( bazLabel, labels.label( 1 ) );
}
else
{
assertEquals( _baz, labels.label( 0 ) );
assertEquals( _bar, labels.label( 1 ) );
assertEquals( bazLabel, labels.label( 0 ) );
assertEquals( barLabel, labels.label( 1 ) );
}
assertFalse( "should only access a single node", nodes.next() );

Expand Down
Expand Up @@ -267,13 +267,13 @@ public static long[] encodePoint( int keyId, CoordinateReferenceSystem crs, doub
int idBits = StandardFormatSettings.PROPERTY_TOKEN_MAXIMUM_ID_BITS;

long keyAndType = keyId | (((long) (PropertyType.GEOMETRY.intValue()) << idBits));
long gtype_bits = GeometryType.GEOMETRY_POINT.gtype << (idBits + 4);
long dimension_bits = ((long) coordinate.length) << (idBits + 8);
long crsTableId_bits = ((long) crs.getTable().getTableId()) << (idBits + 12);
long crsCode_bits = ((long) crs.getCode()) << (idBits + 16);
long gtypeBits = GeometryType.GEOMETRY_POINT.gtype << (idBits + 4);
long dimensionBits = ((long) coordinate.length) << (idBits + 8);
long crsTableIdBits = ((long) crs.getTable().getTableId()) << (idBits + 12);
long crsCodeBits = ((long) crs.getCode()) << (idBits + 16);

long[] data = new long[1 + coordinate.length];
data[0] = keyAndType | gtype_bits | dimension_bits | crsTableId_bits | crsCode_bits;
data[0] = keyAndType | gtypeBits | dimensionBits | crsTableIdBits | crsCodeBits;
for ( int i = 0; i < coordinate.length; i++ )
{
data[1 + i] = Double.doubleToLongBits( coordinate[i] );
Expand Down
Expand Up @@ -71,7 +71,7 @@ public static Set<String> supportedTimeZones()
static
{
String latestVersion = "";
Pattern VERSION = Pattern.compile( "# tzdata([0-9]{4}[a-z])" );
Pattern version = Pattern.compile( "# tzdata([0-9]{4}[a-z])" );
try ( BufferedReader reader = new BufferedReader( new InputStreamReader( TimeZoneMapping.class.getResourceAsStream( "/TZIDS" ) ) ) )
{
for ( String line; (line = reader.readLine()) != null; )
Expand All @@ -82,7 +82,7 @@ public static Set<String> supportedTimeZones()
}
else if ( line.startsWith( "#" ) )
{
Matcher matcher = VERSION.matcher( line );
Matcher matcher = version.matcher( line );
if ( matcher.matches() )
{
latestVersion = matcher.group( 1 );
Expand Down
Expand Up @@ -99,8 +99,8 @@ public void groupToScopeSetting()

// when
BoltConnector boltConnector = new BoltConnector( scoping );
Setting<AdvertisedSocketAddress> advertised_address = boltConnector.advertised_address;
AdvertisedSocketAddress advertisedSocketAddress = advertised_address.apply( config::get );
Setting<AdvertisedSocketAddress> advertisedAddress = boltConnector.advertised_address;
AdvertisedSocketAddress advertisedSocketAddress = advertisedAddress.apply( config::get );

// then
assertEquals( hostname, advertisedSocketAddress.getHostname() );
Expand Down
Expand Up @@ -134,7 +134,7 @@ public void shouldEncodeArrays()
public void shouldEncodeProperlyWithMultipleThreadsRacing() throws Throwable
{
// given
String[] INPUT = {
final String[] INPUT = {
"These strings need to be longer than 57 bytes, because that is the line wrapping length of BASE64.",
"This next line is also long. The number of strings in this array is the number of threads to use.",
"Each thread will get a different string as input to encode, and ensure the result is always the same.",
Expand Down
Expand Up @@ -82,24 +82,24 @@ public void testIndexSeekAndScanByPoint() throws Exception
{
PointValue gps = Values.pointValue( CoordinateReferenceSystem.WGS84, 12.6, 56.7 );
PointValue car = Values.pointValue( CoordinateReferenceSystem.Cartesian, 12.6, 56.7 );
PointValue gps_3d = Values.pointValue( CoordinateReferenceSystem.WGS84_3D, 12.6, 56.7, 100.0 );
PointValue car_3d = Values.pointValue( CoordinateReferenceSystem.Cartesian_3D, 12.6, 56.7, 100.0 );
PointValue gps3d = Values.pointValue( CoordinateReferenceSystem.WGS84_3D, 12.6, 56.7, 100.0 );
PointValue car3d = Values.pointValue( CoordinateReferenceSystem.Cartesian_3D, 12.6, 56.7, 100.0 );

updateAndCommit( asList(
add( 1L, descriptor.schema(), gps, gps ),
add( 2L, descriptor.schema(), car, car ),
add( 3L, descriptor.schema(), gps, car ),
add( 4L, descriptor.schema(), gps_3d, gps_3d ),
add( 5L, descriptor.schema(), car_3d, car_3d ),
add( 6L, descriptor.schema(), gps, car_3d )
add( 4L, descriptor.schema(), gps3d, gps3d ),
add( 5L, descriptor.schema(), car3d, car3d ),
add( 6L, descriptor.schema(), gps, car3d )
) );

assertThat( query( exact( 0, gps ), exact( 1, gps ) ), equalTo( singletonList( 1L ) ) );
assertThat( query( exact( 0, car ), exact( 1, car ) ), equalTo( singletonList( 2L ) ) );
assertThat( query( exact( 0, gps ), exact( 1, car ) ), equalTo( singletonList( 3L ) ) );
assertThat( query( exact( 0, gps_3d ), exact( 1, gps_3d ) ), equalTo( singletonList( 4L ) ) );
assertThat( query( exact( 0, car_3d ), exact( 1, car_3d ) ), equalTo( singletonList( 5L ) ) );
assertThat( query( exact( 0, gps ), exact( 1, car_3d ) ), equalTo( singletonList( 6L ) ) );
assertThat( query( exact( 0, gps3d ), exact( 1, gps3d ) ), equalTo( singletonList( 4L ) ) );
assertThat( query( exact( 0, car3d ), exact( 1, car3d ) ), equalTo( singletonList( 5L ) ) );
assertThat( query( exact( 0, gps ), exact( 1, car3d ) ), equalTo( singletonList( 6L ) ) );
assertThat( query( exists( 1 ) ), equalTo( asList( 1L, 2L, 3L, 4L, 5L, 6L ) ) );
}

Expand Down
Expand Up @@ -155,12 +155,12 @@ public void shouldSeekWhenThereAreManyEntriesWithTheSameValues()
public void shouldSeekInComplexMix()
{
// GIVEN
ValueTuple[] values2_1 = Iterators.array(
ValueTuple[] values21 = Iterators.array(
ValueTuple.of( "hi", 3 ),
ValueTuple.of( 9L, 33L ),
ValueTuple.of( "sneaker", false ) );

ValueTuple[] values2_2 = Iterators.array(
ValueTuple[] values22 = Iterators.array(
ValueTuple.of( true, false ),
ValueTuple.of( new int[]{ 10,100}, "array-buddy" ),
ValueTuple.of( 40.1, 40.2 ) );
Expand All @@ -170,12 +170,12 @@ public void shouldSeekInComplexMix()
ValueTuple.of( true, new long[]{4L}, 33L ),
ValueTuple.of( 2, false, 1 ) );

addEntries( indexOn_1_1_2, values2_1, 10 );
addEntries( indexOn_2_2_3, values2_2, 100 );
addEntries( indexOn_1_1_2, values21, 10 );
addEntries( indexOn_2_2_3, values22, 100 );
addEntries( indexOn_2_2_3_4, values3, 1000 );

assertSeek( indexOn_1_1_2, values2_1, 10 );
assertSeek( indexOn_2_2_3, values2_2, 100 );
assertSeek( indexOn_1_1_2, values21, 10 );
assertSeek( indexOn_2_2_3, values22, 100 );
assertSeek( indexOn_2_2_3_4, values3, 1000 );
}

Expand Down
Expand Up @@ -772,9 +772,9 @@ public void makeSureLazyLoadingRelationshipsWorksEvenIfOtherIteratorAlsoLoadsInT
/* create 256 nodes */
GraphDatabaseService graphDB = getGraphDb();
Node[] nodes = new Node[256];
for ( int num_nodes = 0; num_nodes < nodes.length; num_nodes += 1 )
for ( int numNodes = 0; numNodes < nodes.length; numNodes += 1 )
{
nodes[num_nodes] = graphDB.createNode();
nodes[numNodes] = graphDB.createNode();
}
newTransaction();

Expand Down
Expand Up @@ -191,14 +191,14 @@ public void highestEverSeenTest()
public void shouldBeAbleToTimeoutWaitingForNumber() throws Exception
{
// given
long TIMEOUT = 10;
long timeout = 10;
final OutOfOrderSequence sequence = new ArrayQueueOutOfOrderSequence( 3, 5, EMPTY_META );

long startTime = System.currentTimeMillis();
try
{
// when
sequence.await( 4, TIMEOUT );
sequence.await( 4, timeout );
fail();
}
catch ( TimeoutException e )
Expand All @@ -207,7 +207,7 @@ public void shouldBeAbleToTimeoutWaitingForNumber() throws Exception
}

long endTime = System.currentTimeMillis();
assertThat( endTime - startTime, greaterThanOrEqualTo( TIMEOUT ) );
assertThat( endTime - startTime, greaterThanOrEqualTo( timeout ) );
}

@Test
Expand Down
Expand Up @@ -63,7 +63,7 @@ public void shouldGrowAFileWhileContinuingToMemoryMapNewRegions()
assumeTrue( !SystemUtils.IS_OS_WINDOWS );

// given
int NUMBER_OF_RECORDS = 1000000;
final int NUMBER_OF_RECORDS = 1000000;

File storeDir = testDirectory.graphDbDir();
Config config = Config.defaults( pagecache_memory, mmapSize( NUMBER_OF_RECORDS, NodeRecordFormat.RECORD_SIZE ) );
Expand Down
Expand Up @@ -115,9 +115,9 @@ public void shouldWriteByte()
public void shouldCompareByteArrays()
{
// given
Matcher<Integer> LESS_THAN = lessThan( 0 );
Matcher<Integer> GREATER_THAN = greaterThan( 0 );
Matcher<Integer> EQUAL_TO = equalTo( 0 );
final Matcher<Integer> LESS_THAN = lessThan( 0 );
final Matcher<Integer> GREATER_THAN = greaterThan( 0 );
final Matcher<Integer> EQUAL_TO = equalTo( 0 );

// then
assertCompare( new byte[0], EQUAL_TO, new byte[0] );
Expand Down

0 comments on commit cac0e7a

Please sign in to comment.