seancarroll/fdb-java-es

View on GitHub

Showing 19 of 19 total issues

File EventStoreLayer.java has 433 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package com.eventfully.foundationdb.eventstore;

import com.apple.foundationdb.Database;
import com.apple.foundationdb.KeySelector;
import com.apple.foundationdb.KeyValue;

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

            return kvs.thenCompose(keyValues -> {
                if (keyValues.isEmpty()) {
                    return completedFuture(ReadStreamSlice.notFound(streamId, fromVersionInclusive, ReadDirection.BACKWARD, readNext));
                }
    
    
    src/main/java/com/eventfully/foundationdb/eventstore/EventStoreLayer.java on lines 402..430

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 190.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

            return kvs.thenCompose(keyValues -> {
                if (keyValues.isEmpty()) {
                    return completedFuture(ReadStreamSlice.notFound(streamId, fromVersionInclusive, ReadDirection.FORWARD, readNext));
                }
    
    
    src/main/java/com/eventfully/foundationdb/eventstore/EventStoreLayer.java on lines 462..490

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 190.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    EventStoreLayer has 25 methods (exceeds 20 allowed). Consider refactoring.
    Open

    public class EventStoreLayer implements EventStore {
    
        private static final Logger LOG = LoggerFactory.getLogger(EventStoreLayer.class);
    
        public static final int MAX_READ_SIZE = 4096;

      Method readAllBackwardInternal has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private CompletableFuture<ReadAllSlice> readAllBackwardInternal(ReadTransaction tr, Versionstamp fromPositionInclusive, int maxCount) {
              Subspace globalSubspace = getGlobalSubspace();
      
              // add one so we can determine if we are at the end of the stream
              int rangeCount = maxCount + 1;

        Method readAllForwardInternal has 51 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private CompletableFuture<ReadAllSlice> readAllForwardInternal(ReadTransaction tr, Versionstamp fromPositionInclusive, int maxCount) {
                Subspace globalSubspace = getGlobalSubspace();
        
                // add one so we can determine if we are at the end of the stream
                int rangeCount = maxCount + 1;

          Method readStreamForwardsInternal has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private CompletableFuture<ReadStreamSlice> readStreamForwardsInternal(ReadTransaction tr,
                                                                                    StreamId streamId,
                                                                                    long fromVersionInclusive,
                                                                                    int maxCount) {
                  Subspace streamSubspace = getStreamSubspace(streamId);

            Method readStreamBackwardsInternal has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private CompletableFuture<ReadStreamSlice> readStreamBackwardsInternal(ReadTransaction tr,
                                                                                       StreamId streamId,
                                                                                       long fromVersionInclusive,
                                                                                       int maxCount) {
                    Subspace streamSubspace = getStreamSubspace(streamId);

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  @Override
                  public CompletableFuture<ReadStreamSlice> readStreamBackwards(String streamId, long fromVersionInclusive, int maxCount) {
                      Preconditions.checkNotNull(streamId);
                      Preconditions.checkArgument(fromVersionInclusive >= -1, "fromVersionInclusive must greater than -1");
                      Preconditions.checkArgument(maxCount > 0, "maxCount must be greater than 0");
              src/main/java/com/eventfully/foundationdb/eventstore/EventStoreLayer.java on lines 368..376

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 82.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  @Override
                  public CompletableFuture<ReadStreamSlice> readStreamForwards(String streamId, long fromVersionInclusive, int maxCount) {
                      Preconditions.checkNotNull(streamId);
                      Preconditions.checkArgument(fromVersionInclusive >= -1, "fromVersionInclusive must greater than -1");
                      Preconditions.checkArgument(maxCount > 0, "maxCount must be greater than 0");
              src/main/java/com/eventfully/foundationdb/eventstore/EventStoreLayer.java on lines 433..441

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 82.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                          for (int i = 0; i < limit; i++) {
                              KeyValue kv = keyValues.get(i);
                              Tuple t = Tuple.fromBytes(kv.getValue());
                              completableFutures.add(readEvent(t.getString(0), t.getLong(1)));
                          }
              src/main/java/com/eventfully/foundationdb/eventstore/EventStoreLayer.java on lines 259..263

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 66.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                          for (int i = 0; i < limit; i++) {
                              KeyValue kv = keyValues.get(i);
                              Tuple t = Tuple.fromBytes(kv.getValue());
                              completableFutures.add(readEvent(t.getString(0), t.getLong(1)));
                          }
              src/main/java/com/eventfully/foundationdb/eventstore/EventStoreLayer.java on lines 337..341

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 66.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  @Override
                  public CompletableFuture<ReadAllSlice> readAllForwards(Versionstamp fromPositionInclusive, int maxCount) {
                      Preconditions.checkNotNull(fromPositionInclusive);
                      Preconditions.checkArgument(maxCount > 0, "maxCount must be greater than 0");
                      Preconditions.checkArgument(maxCount <= MAX_READ_SIZE, "maxCount should be less than %d", MAX_READ_SIZE);
              src/main/java/com/eventfully/foundationdb/eventstore/EventStoreLayer.java on lines 215..222

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 61.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  @Override
                  public CompletableFuture<ReadAllSlice> readAllBackwards(Versionstamp fromPositionInclusive, int maxCount) {
                      Preconditions.checkNotNull(fromPositionInclusive);
                      Preconditions.checkArgument(maxCount > 0, "maxCount must be greater than 0");
                      Preconditions.checkArgument(maxCount <= MAX_READ_SIZE, "maxCount should be less than %d", MAX_READ_SIZE);
              src/main/java/com/eventfully/foundationdb/eventstore/EventStoreLayer.java on lines 206..213

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 61.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  @Override
                  public String toString() {
                      return MoreObjects.toStringHelper(this)
                          .add("fromStreamVersion", getFromStreamVersion())
                          .add("lastStreamVersion", getLastStreamVersion())
              src/main/java/com/eventfully/foundationdb/eventstore/StreamMessage.java on lines 87..97

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 49.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  @Override
                  public String toString() {
                      return MoreObjects.toStringHelper(this)
                          .add("messageId", getMessageId())
                          .add("streamId", getStreamId())
              src/main/java/com/eventfully/foundationdb/eventstore/ReadStreamSlice.java on lines 144..154

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 49.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Method setStreamMetadata has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  public SetStreamMetadataResult setStreamMetadata(String streamId,
                                                                   long expectedStreamMetadataVersion,
                                                                   Integer maxAge,
                                                                   Integer maxCount,
                                                                   String metadataJson) {

                Method setStreamMetadata has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    SetStreamMetadataResult setStreamMetadata(String streamId,
                                                              long expectedStreamMetadataVersion,
                                                              Integer maxAge,
                                                              Integer maxCount,
                                                              String metadataJson);
                Severity: Minor
                Found in src/main/java/com/eventfully/foundationdb/eventstore/EventStore.java - About 35 mins to fix

                  Method equals has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      @Override
                      public boolean equals(Object obj) {
                          if (this == obj) {
                              return true;
                          }
                  Severity: Minor
                  Found in src/main/java/com/eventfully/foundationdb/eventstore/StreamId.java - About 25 mins to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Severity
                  Category
                  Status
                  Source
                  Language