exonum-java-binding icon indicating copy to clipboard operation
exonum-java-binding copied to clipboard

Add strict formatter [ECR-4138]

Open dmitry-timofeev opened this issue 5 years ago • 2 comments

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

dmitry-timofeev avatar Jan 23 '20 11:01 dmitry-timofeev

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

bullet-tooth avatar Jan 23 '20 16:01 bullet-tooth

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 avatar Jan 23 '20 16:01 dmitry-timofeev