ReactiveX/RxJava

View on GitHub
src/main/java/rx/internal/operators/OperatorMerge.java

Summary

Maintainability
F
1 wk
Test Coverage

Method emitLoop has a Cognitive Complexity of 165 (exceeds 5 allowed). Consider refactoring.
Open

        void emitLoop() {
            boolean skipFinal = false;
            try {
                final Subscriber<? super T> child = this.child;
                for (;;) {
Severity: Minor
Found in src/main/java/rx/internal/operators/OperatorMerge.java - About 3 days 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

File OperatorMerge.java has 654 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * Copyright 2014 Netflix, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
Severity: Major
Found in src/main/java/rx/internal/operators/OperatorMerge.java - About 1 day to fix

    Method emitLoop has 186 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            void emitLoop() {
                boolean skipFinal = false;
                try {
                    final Subscriber<? super T> child = this.child;
                    for (;;) {
    Severity: Major
    Found in src/main/java/rx/internal/operators/OperatorMerge.java - About 7 hrs to fix

      Method queueScalar has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

              protected void queueScalar(T value) {
                  /*
                   * If the attempt to make a fast-path emission failed
                   * due to lack of requests or an ongoing emission,
                   * enqueue the value and try the slow emission path.
      Severity: Minor
      Found in src/main/java/rx/internal/operators/OperatorMerge.java - About 1 hr 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

      Method emitScalar has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              protected void emitScalar(T value, long r) {
                  boolean skipFinal = false;
                  try {
                      try {
                          child.onNext(value);
      Severity: Minor
      Found in src/main/java/rx/internal/operators/OperatorMerge.java - About 1 hr to fix

        Method emitScalar has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                protected void emitScalar(InnerSubscriber<T> subscriber, T value, long r) {
                    boolean skipFinal = false;
                    try {
                        try {
                            child.onNext(value);
        Severity: Minor
        Found in src/main/java/rx/internal/operators/OperatorMerge.java - About 1 hr to fix

          Method tryEmit has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

                  void tryEmit(InnerSubscriber<T> subscriber, T value) {
                      boolean success = false;
                      long r = producer.get();
                      if (r != 0L) {
                          synchronized (this) {
          Severity: Minor
          Found in src/main/java/rx/internal/operators/OperatorMerge.java - About 1 hr 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

          Method tryEmit has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

                  void tryEmit(T value) {
                      boolean success = false;
                      long r = producer.get();
                      if (r != 0L) {
                          synchronized (this) {
          Severity: Minor
          Found in src/main/java/rx/internal/operators/OperatorMerge.java - About 1 hr 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

          Method removeInner has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  void removeInner(InnerSubscriber<T> inner) {
                      RxRingBuffer q = inner.queue;
                      if (q != null) {
                          q.release();
                      }
          Severity: Minor
          Found in src/main/java/rx/internal/operators/OperatorMerge.java - About 1 hr to fix

            Avoid deeply nested control flow statements.
            Open

                                            if (o == null) {
                                                break;
                                            }
            Severity: Major
            Found in src/main/java/rx/internal/operators/OperatorMerge.java - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                              if (checkTerminate()) {
                                                  skipFinal = true;
                                                  return;
                                              }
              Severity: Major
              Found in src/main/java/rx/internal/operators/OperatorMerge.java - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                                if (inner[j].id == startId) {
                                                    break;
                                                }
                Severity: Major
                Found in src/main/java/rx/internal/operators/OperatorMerge.java - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                                      if (!delayErrors) {
                                                          Exceptions.throwIfFatal(t);
                                                          skipFinal = true;
                                                          unsubscribe();
                                                          child.onError(t);
                  Severity: Major
                  Found in src/main/java/rx/internal/operators/OperatorMerge.java - About 45 mins to fix

                    Method emitScalar has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                            protected void emitScalar(T value, long r) {
                                boolean skipFinal = false;
                                try {
                                    try {
                                        child.onNext(value);
                    Severity: Minor
                    Found in src/main/java/rx/internal/operators/OperatorMerge.java - About 45 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

                    Avoid deeply nested control flow statements.
                    Open

                                                    while (r > 0) {
                                                        // eagerly check if child unsubscribed or we reached a terminal state.
                                                        if (checkTerminate()) {
                                                            skipFinal = true;
                                                            return;
                    Severity: Major
                    Found in src/main/java/rx/internal/operators/OperatorMerge.java - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                                      if (checkTerminate()) {
                                                          skipFinal = true;
                                                          return;
                                                      }
                      Severity: Major
                      Found in src/main/java/rx/internal/operators/OperatorMerge.java - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                        if (unbounded) {
                                                            r = Long.MAX_VALUE;
                                                        } else {
                                                            r = producer.produced(scalarEmission);
                                                        }
                        Severity: Major
                        Found in src/main/java/rx/internal/operators/OperatorMerge.java - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                          if (produced > 0) {
                                                              if (!unbounded) {
                                                                  r = producer.produced(produced);
                                                              } else {
                                                                  r = Long.MAX_VALUE;
                          Severity: Major
                          Found in src/main/java/rx/internal/operators/OperatorMerge.java - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                            if (r == 0 || o == null) {
                                                                break;
                                                            }
                            Severity: Major
                            Found in src/main/java/rx/internal/operators/OperatorMerge.java - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                              if (j == n) {
                                                                  j = 0;
                                                              }
                              Severity: Major
                              Found in src/main/java/rx/internal/operators/OperatorMerge.java - About 45 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                                                        return;
                                Severity: Major
                                Found in src/main/java/rx/internal/operators/OperatorMerge.java - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                                                      return;
                                  Severity: Major
                                  Found in src/main/java/rx/internal/operators/OperatorMerge.java - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                                                            return;
                                    Severity: Major
                                    Found in src/main/java/rx/internal/operators/OperatorMerge.java - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                                                      return;
                                      Severity: Major
                                      Found in src/main/java/rx/internal/operators/OperatorMerge.java - About 30 mins to fix

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

                                                protected void emitScalar(InnerSubscriber<T> subscriber, T value, long r) {
                                                    boolean skipFinal = false;
                                                    try {
                                                        try {
                                                            child.onNext(value);
                                        Severity: Minor
                                        Found in src/main/java/rx/internal/operators/OperatorMerge.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

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

                                                void removeInner(InnerSubscriber<T> inner) {
                                                    RxRingBuffer q = inner.queue;
                                                    if (q != null) {
                                                        q.release();
                                                    }
                                        Severity: Minor
                                        Found in src/main/java/rx/internal/operators/OperatorMerge.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

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

                                                    synchronized (innerGuard) {
                                                        InnerSubscriber<?>[] a = innerSubscribers;
                                                        int n = a.length;
                                                        InnerSubscriber<?>[] b = new InnerSubscriber<?>[n + 1];
                                                        System.arraycopy(a, 0, b, 0, n);
                                        Severity: Major
                                        Found in src/main/java/rx/internal/operators/OperatorMerge.java and 1 other location - About 1 hr to fix
                                        src/main/java/rx/internal/operators/CachedObservable.java on lines 126..133

                                        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 76.

                                        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

                                                    if (r != 0L) {
                                                        synchronized (this) {
                                                            // if nobody is emitting and child has available requests
                                                            r = producer.get();
                                                            if (!emitting && r != 0L) {
                                        Severity: Minor
                                        Found in src/main/java/rx/internal/operators/OperatorMerge.java and 1 other location - About 50 mins to fix
                                        src/main/java/rx/internal/operators/OperatorMerge.java on lines 342..351

                                        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 58.

                                        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

                                                    if (r != 0L) {
                                                        synchronized (this) {
                                                            // if nobody is emitting and child has available requests
                                                            r = producer.get();
                                                            if (!emitting && r != 0L) {
                                        Severity: Minor
                                        Found in src/main/java/rx/internal/operators/OperatorMerge.java and 1 other location - About 50 mins to fix
                                        src/main/java/rx/internal/operators/OperatorMerge.java on lines 453..462

                                        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 58.

                                        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

                                                        synchronized (this) {
                                                            skipFinal = true;
                                                            if (!missed) {
                                                                emitting = false;
                                                                return;
                                        Severity: Minor
                                        Found in src/main/java/rx/internal/operators/OperatorMerge.java and 1 other location - About 30 mins to fix
                                        src/main/java/rx/internal/operators/OperatorMerge.java on lines 411..418

                                        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 40.

                                        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

                                                            synchronized (this) {
                                                                if (!missed) {
                                                                    skipFinal = true;
                                                                    emitting = false;
                                                                    break;
                                        Severity: Minor
                                        Found in src/main/java/rx/internal/operators/OperatorMerge.java and 1 other location - About 30 mins to fix
                                        src/main/java/rx/internal/operators/OperatorOnBackpressureLatest.java on lines 178..185

                                        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 40.

                                        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

                                                        synchronized (this) {
                                                            skipFinal = true;
                                                            if (!missed) {
                                                                emitting = false;
                                                                return;
                                        Severity: Minor
                                        Found in src/main/java/rx/internal/operators/OperatorMerge.java and 1 other location - About 30 mins to fix
                                        src/main/java/rx/internal/operators/OperatorMerge.java on lines 535..542

                                        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 40.

                                        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

                                        There are no issues that match your filters.

                                        Category
                                        Status