Skip to content

Conversation

@dmitry-timofeev
Copy link
Contributor

Overview

  • Review c4eef90 for changes in configuration and Contributing guide.
  • edbf7d7 shows what it does:
    • Some builder/stream chains are compressed in a single line:
      .setPayload(ExonumMessage.newBuilder().setAnyTx(anyTx(payload)).build().toByteString()) is too much.
    • Some artifacts in array initializers.
  • Subsequent commits fix some artifacts.

See: https://jira.bf.local/browse/ECR-4138

Definition of Done

  • There are no TODOs left in the code
  • Change is covered by automated tests
  • The coding guidelines are followed
  • Public API has Javadoc
  • Method preconditions are checked and documented in the Javadoc of the method
  • Changelog is updated if needed (in case of notable or breaking changes)
  • The continuous integration build passes
Comment on lines +69 to +82
new byte[] {
(byte) 0xef,
(byte) 0xcd,
(byte) 0xab,
(byte) 0x89,
(byte) 0x67,
(byte) 0x45,
(byte) 0x23,
(byte) 0x01, // up to here, same bytes as above
(byte) 0x01,
(byte) 0x02,
(byte) 0x03,
(byte) 0x04,
(byte) 0x05,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another unfortunate artifactj.

Java code must follow the [Google code style](https://google.github.io/styleguide/javaguide.html).
[Checkstyle](http://checkstyle.sourceforge.net/index.html) checks the project
during `validate` phase (i.e., _before_ compilation) of the build. You can also run it manually:
[The format plugin](https://github.com/coveooss/fmt-maven-plugin) checks the project
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hope it works well with IDEA's code format feature 🙃

version, revision, buildTime);
ZonedDateTime buildTime =
ZonedDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneOffset.UTC);
logger.info(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💩

/**
* Provides factory methods to concisely create
* {@link com.exonum.core.messages.Blockchain.CallInBlock}s.
* Provides factory methods to concisely create {@link
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

questionable improvement

* @param txPosition a zero-based position of the transaction in the block
* @throws IndexOutOfBoundsException if position is negative or greater than
* {@value Integer#MAX_VALUE}
* @throws IndexOutOfBoundsException if position is negative or greater than {@value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

questionable improvement

public static final ExecutionStatus SUCCESS = ExecutionStatus.newBuilder()
.setOk(Empty.getDefaultInstance())
.build();
/** A successful execution status. */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

public static TypeAdapter<TransactionLocation> typeAdapter(Gson gson) {
return new AutoValue_TransactionLocation.GsonTypeAdapter(gson);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

* <p>A map entry contains <em>a copy</em> of the data in the corresponding map index.
* Unlike {@link java.util.Map.Entry}, it does not reflect the changes made to the map
* since this entry had been created.
* <p>A map entry contains <em>a copy</em> of the data in the corresponding map index. Unlike {@link
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO: code reading experience becomes worse here

public KeyPair generateKeyPair(byte[] seed) {
checkArgument(hasLength(seed, SEED_BYTES),
"Seed byte array has invalid size (%s), must be %s", seed.length, SEED_BYTES);
checkArgument(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👎

public boolean verify(byte[] message, byte[] signature, PublicKey publicKey) {
checkArgument(hasLength(publicKey.toBytesNoCopy(), PUBLIC_KEY_BYTES),
"Public key has invalid size (%s), must be %s", publicKey.size(), PUBLIC_KEY_BYTES);
checkArgument(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👎

/**
* Creates a {@code KeyPair} from two byte arrays, representing {@code privateKey}
* and {@code publicKey}. All arrays are defensively copied.
* Creates a {@code KeyPair} from two byte arrays, representing {@code privateKey} and {@code
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't like such splitting tags

@bullet-tooth
Copy link
Contributor

overall looks ok. There are the following major points to notice (to summarize):

  • One-line chains in builders, streams, etc. Will be difficult to analyze traces in case of exceptions
  • checkArguments statements become more complex, new param at new line
@dmitry-timofeev
Copy link
Contributor Author

Will be difficult to analyze traces in case of exceptions

I'd add that it sometimes hurts readability, e.g.,

 HashCode valueHash = HASH_FUNCTION.newHasher().putByte(BLOB_PREFIX).putBytes(value.toByteArray()).hash();

or

 Stream<String> packageDirs = artifactClasses.stream().map(Class::getPackage).distinct().map(this::getPath);
@dmitry-timofeev dmitry-timofeev added the experimental ⚖️ Experimental PRs usually shall not be merged — they show some approach to get feedback from the team label Jan 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

experimental ⚖️ Experimental PRs usually shall not be merged — they show some approach to get feedback from the team

3 participants