Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Upgrade GoogleJavaFormat to 1.7 #795

Merged
merged 2 commits into from
Feb 7, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -118,9 +118,7 @@ public ProposalsConfig removeProposal(final PantheonNode node) {

public Condition build() {
final Map<Address, Boolean> proposalsAsAddress =
this.proposals
.entrySet()
.stream()
this.proposals.entrySet().stream()
.collect(Collectors.toMap(p -> p.getKey().getAddress(), Entry::getValue));
return new ExpectProposals(clique, proposalsAsAddress);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,7 @@ public PendingVotesConfig removeProposal(final PantheonNode node) {

public Condition build() {
final Map<Address, Boolean> proposalsAsAddress =
this.proposals
.entrySet()
.stream()
this.proposals.entrySet().stream()
.collect(Collectors.toMap(p -> p.getKey().getAddress(), Entry::getValue));
return new tech.pegasys.pantheon.tests.acceptance.dsl.condition.ibft.ExpectProposals(
ibft, proposalsAsAddress);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,7 @@ String p2pListenAddress() {
}

List<URI> bootnodes() {
return bootnodes
.stream()
return bootnodes.stream()
.filter(node -> !node.equals(this.enodeUrl()))
.map(URI::create)
.collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,7 @@ public void verify(final Condition expected) {
}

public void verifyOnActiveNodes(final Condition condition) {
nodes
.values()
.stream()
nodes.values().stream()
.filter(node -> pantheonNodeRunner.isActive(node.getName()))
.forEach(condition::verify);
}
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ allprojects {
exclude '**/.gradle/**'
}
removeUnusedImports()
googleJavaFormat()
googleJavaFormat('1.7')
importOrder 'tech.pegasys', 'java', ''
trimTrailingWhitespace()
endWithNewline()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ public GenesisConfigOptions getConfigOptions() {

public Stream<GenesisAllocation> getAllocations() {
final JsonObject allocations = configRoot.getJsonObject("alloc");
return allocations
.fieldNames()
.stream()
return allocations.fieldNames().stream()
.map(key -> new GenesisAllocation(key, allocations.getJsonObject(key)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ public void addressToExtraDataString() {
}

final List<Address> addresses =
nodeKeys
.stream()
nodeKeys.stream()
.map(KeyPair::getPublicKey)
.map(Util::publicKeyToAddress)
.collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ public AbstractVoteProposerMethod(final VoteProposer voteProposer) {

public JsonRpcResponse response(final JsonRpcRequest request) {
final Map<String, Boolean> proposals =
voteProposer
.getProposals()
.entrySet()
.stream()
voteProposer.getProposals().entrySet().stream()
.collect(
Collectors.toMap(
proposal -> proposal.getKey().toString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ public ValidatorPeer getNonProposing(final int index) {

public List<SignedData<RoundChangePayload>> roundChangeForNonProposing(
final ConsensusRoundIdentifier targetRound) {
return nonProposingPeers
.stream()
return nonProposingPeers.stream()
.map(peer -> peer.injectRoundChange(targetRound, empty()).getSignedPayload())
.collect(Collectors.toList());
}
Expand All @@ -102,16 +101,14 @@ public List<SignedData<RoundChangePayload>> roundChange(final ConsensusRoundIden

public List<SignedData<RoundChangePayload>> createSignedRoundChangePayload(
final ConsensusRoundIdentifier roundId) {
return peers
.stream()
return peers.stream()
.map(p -> p.getMessageFactory().createRoundChange(roundId, empty()).getSignedPayload())
.collect(Collectors.toList());
}

public List<SignedData<RoundChangePayload>> createSignedRoundChangePayload(
final ConsensusRoundIdentifier roundId, final PreparedRoundArtifacts preparedRoundArtifacts) {
return peers
.stream()
return peers.stream()
.map(
p ->
p.getMessageFactory()
Expand All @@ -130,8 +127,7 @@ public void commitForNonProposing(final ConsensusRoundIdentifier roundId, final

public Collection<SignedData<PreparePayload>> createSignedPreparePayloadOfNonProposing(
final ConsensusRoundIdentifier preparedRound, final Hash hash) {
return nonProposingPeers
.stream()
return nonProposingPeers.stream()
.map(role -> role.getMessageFactory().createPrepare(preparedRound, hash).getSignedPayload())
.collect(Collectors.toList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ public void send(final MessageData message) {

@Override
public void send(final MessageData message, final Collection<Address> blackList) {
validatorNodes
.stream()
validatorNodes.stream()
.filter(peer -> !blackList.contains(peer.getNodeAddress()))
.forEach(peer -> peer.handleReceivedMessage(message));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,7 @@ public TestContext build() {
// NOTE: the remotePeers needs to be ordered based on Address (as this is used to determine
// the proposer order which must be managed in test).
final Map<Address, ValidatorPeer> remotePeers =
networkNodes
.getRemotePeers()
.stream()
networkNodes.getRemotePeers().stream()
.collect(
Collectors.toMap(
NodeParams::getAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ public static PreparedRoundArtifacts createValidPreparedRoundArtifacts(

return new PreparedRoundArtifacts(
peers.getProposer().getMessageFactory().createProposal(preparedRound, block),
peers
.createSignedPreparePayloadOfNonProposing(preparedRound, block.getHash())
.stream()
peers.createSignedPreparePayloadOfNonProposing(preparedRound, block.getHash()).stream()
.map(Prepare::new)
.collect(Collectors.toList()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ public static List<Address> recoverCommitterAddresses(
final Hash committerHash =
IbftBlockHashing.calculateDataHashForCommittedSeal(header, ibftExtraData);

return ibftExtraData
.getSeals()
.stream()
return ibftExtraData.getSeals().stream()
.map(p -> Util.signatureToAddress(p, committerHash))
.collect(Collectors.toList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ private Object blockResult(final JsonRpcRequest request) {
return blockHeader
.map(
header ->
blockInterface
.validatorsInBlock(header)
.stream()
blockInterface.validatorsInBlock(header).stream()
.map(validator -> validator.toString())
.collect(Collectors.toList()))
.orElse(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ protected Object resultByBlockNumber(final JsonRpcRequest request, final long bl
return blockHeader
.map(
header ->
blockInterface
.validatorsInBlock(header)
.stream()
blockInterface.validatorsInBlock(header).stream()
.map(validator -> validator.toString())
.collect(Collectors.toList()))
.orElse(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ public void send(final MessageData message) {
@Override
public void send(final MessageData message, final Collection<Address> blackList) {
final Collection<Address> includedValidators =
validatorProvider
.getValidators()
.stream()
validatorProvider.getValidators().stream()
.filter(a -> !blackList.contains(a))
.collect(Collectors.toSet());
sendMessageToSpecificAddresses(includedValidators, message);
Expand All @@ -77,8 +75,7 @@ private void sendMessageToSpecificAddresses(
final Collection<Address> recipients, final MessageData message) {
LOG.trace(
"Sending message to peers messageCode={} recipients={}", message.getCode(), recipients);
recipients
.stream()
recipients.stream()
.map(peerConnections::get)
.filter(Objects::nonNull)
.forEach(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ public void appendRoundChangeMessage(final RoundChange msg) {

public RoundChangeCertificate buildCertificate() {
return new RoundChangeCertificate(
roundChangePayloads
.stream()
roundChangePayloads.stream()
.map(RoundChange::getSignedPayload)
.collect(Collectors.toList()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ public RoundChangeCertificate getRoundChangeCertificate() {
public static RoundChangeArtifacts create(final Collection<RoundChange> roundChanges) {

final Collection<SignedData<RoundChangePayload>> payloads =
roundChanges
.stream()
roundChanges.stream()
.map(roundChange -> roundChange.getSignedPayload())
.collect(Collectors.toList());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ public boolean isCommitted() {
}

public Collection<Signature> getCommitSeals() {
return commitMessages
.stream()
return commitMessages.stream()
.map(cp -> cp.getSignedPayload().getPayload().getCommitSeal())
.collect(Collectors.toList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,7 @@ private boolean validateRoundChangeMessagesAndEnsureTargetRoundMatchesRoot(
return false;
}

if (!roundChangeCert
.getRoundChangePayloads()
.stream()
if (!roundChangeCert.getRoundChangePayloads().stream()
.allMatch(p -> p.getPayload().getRoundIdentifier().equals(expectedRound))) {
LOG.info(
"Invalid NewRound message, not all embedded RoundChange messages have a "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ public void testRecoverCommitterAddresses() {
HEADER_TO_BE_HASHED, IbftExtraData.decode(HEADER_TO_BE_HASHED.getExtraData()));

List<Address> expectedCommitterAddresses =
COMMITTERS_KEY_PAIRS
.stream()
COMMITTERS_KEY_PAIRS.stream()
.map(keyPair -> Util.publicKeyToAddress(keyPair.getPublicKey()))
.collect(Collectors.toList());

Expand All @@ -79,8 +78,7 @@ public void testCalculateDataHashForCommittedSeal() {
BlockHeaderBuilder builder = setHeaderFieldsExceptForExtraData();

List<Signature> commitSeals =
COMMITTERS_KEY_PAIRS
.stream()
COMMITTERS_KEY_PAIRS.stream()
.map(keyPair -> SECP256K1.sign(dataHahsForCommittedSeal, keyPair))
.collect(Collectors.toList());

Expand Down Expand Up @@ -151,8 +149,7 @@ private static BlockHeader headerToBeHashed() {
builder.buildBlockHeader().writeTo(rlpForHeaderFroCommittersSigning);

List<Signature> commitSeals =
COMMITTERS_KEY_PAIRS
.stream()
COMMITTERS_KEY_PAIRS.stream()
.map(
keyPair ->
SECP256K1.sign(Hash.hash(rlpForHeaderFroCommittersSigning.encoded()), keyPair))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ public void correctlyConstructedHeaderPassesValidation() {
IntStream.range(0, 2).mapToObj(i -> KeyPair.generate()).collect(Collectors.toList());

final List<Address> committerAddresses =
committerKeyPairs
.stream()
committerKeyPairs.stream()
.map(keyPair -> Util.publicKeyToAddress(keyPair.getPublicKey()))
.sorted()
.collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@ private RoundChange makeRoundChangeMessageWithPreparedCert(
final Proposal proposal = messageFactory.createProposal(proposalRound, block);

final List<Prepare> preparePayloads =
prepareProviders
.stream()
prepareProviders.stream()
.map(
k -> {
final MessageFactory prepareFactory = new MessageFactory(k);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,7 @@ public static List<Address> recoverCommitterAddresses(
final Hash committerHash =
IbftBlockHashing.calculateDataHashForCommittedSeal(header, ibftExtraData);

return ibftExtraData
.getSeals()
.stream()
return ibftExtraData.getSeals().stream()
.map(p -> Util.signatureToAddress(p, committerHash))
.collect(Collectors.toList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ private IbftExtraData createExtraDataWithCommitSeals(
IbftBlockHashing.calculateDataHashForCommittedSeal(header, extraDataInHeader);

final List<Signature> commitSeals =
committerKeyPairs
.stream()
committerKeyPairs.stream()
.map(keys -> SECP256K1.sign(headerHashForCommitters, keys))
.collect(Collectors.toList());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,10 @@

@AutoService(BugChecker.class)
@BugPattern(
name = "DoNotCreateSecureRandomDirectly",
summary = "Do not create SecureRandom directly.",
category = JDK,
severity = WARNING
)
name = "DoNotCreateSecureRandomDirectly",
summary = "Do not create SecureRandom directly.",
category = JDK,
severity = WARNING)
public class DoNotCreateSecureRandomDirectly extends BugChecker
implements MethodInvocationTreeMatcher, NewClassTreeMatcher {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@

@AutoService(BugChecker.class)
@BugPattern(
name = "DoNotInvokeMessageDigestDirectly",
summary = "Do not invoke MessageDigest.getInstance directly.",
category = JDK,
severity = WARNING
)
name = "DoNotInvokeMessageDigestDirectly",
summary = "Do not invoke MessageDigest.getInstance directly.",
category = JDK,
severity = WARNING)
public class DoNotInvokeMessageDigestDirectly extends BugChecker
implements MethodInvocationTreeMatcher {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,10 @@

@AutoService(BugChecker.class) // the service descriptor
@BugPattern(
name = "DoNotReturnNullOptionals",
summary = "Do not return null optionals.",
category = JDK,
severity = SUGGESTION
)
name = "DoNotReturnNullOptionals",
summary = "Do not return null optionals.",
category = JDK,
severity = SUGGESTION)
public class DoNotReturnNullOptionals extends BugChecker implements MethodTreeMatcher {

private static class ReturnNullMatcher implements Matcher<Tree> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@

@AutoService(BugChecker.class)
@BugPattern(
name = "MethodInputParametersMustBeFinal",
summary = "Method input parameters must be final.",
category = JDK,
severity = WARNING
)
name = "MethodInputParametersMustBeFinal",
summary = "Method input parameters must be final.",
category = JDK,
severity = WARNING)
public class MethodInputParametersMustBeFinal extends BugChecker
implements MethodTreeMatcher, ClassTreeMatcher {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,7 @@ public void shouldTraceSStoreOperation() {
blockHashLookup);
assertThat(result.isSuccessful()).isTrue();
final Account createdContract =
createTransactionUpdater
.getTouchedAccounts()
.stream()
createTransactionUpdater.getTouchedAccounts().stream()
.filter(account -> !account.getCode().isEmpty())
.findAny()
.get();
Expand Down
Loading