ReactiveX/RxJava

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

Summary

Maintainability
F
4 days
Test Coverage

Method dispatch has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring.
Open

        void dispatch() {
            // standard construct of emitter loop (blocking)
            // if there is an emission going on, indicate that more work needs to be done
            // the exact nature of this work needs to be determined from other data structures
            synchronized (this) {
Severity: Minor
Found in src/main/java/rx/internal/operators/OperatorPublish.java - About 1 day 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 OperatorPublish.java has 408 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. You may obtain a copy of
Severity: Minor
Found in src/main/java/rx/internal/operators/OperatorPublish.java - About 5 hrs to fix

    Method dispatch has 92 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            void dispatch() {
                // standard construct of emitter loop (blocking)
                // if there is an emission going on, indicate that more work needs to be done
                // the exact nature of this work needs to be determined from other data structures
                synchronized (this) {
    Severity: Major
    Found in src/main/java/rx/internal/operators/OperatorPublish.java - About 3 hrs to fix

      Method remove has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

              void remove(InnerProducer<T> producer) {
                  // the state can change so we do a CAS loop to achieve atomicity
                  for (;;) {
                      // let's read the current producers array
                      InnerProducer[] c = producers.get();
      Severity: Minor
      Found in src/main/java/rx/internal/operators/OperatorPublish.java - About 2 hrs 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 request has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

              @Override
              public void request(long n) {
                  // ignore negative requests
                  if (n < 0) {
                      return;
      Severity: Minor
      Found in src/main/java/rx/internal/operators/OperatorPublish.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 checkTerminated has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

              boolean checkTerminated(Object term, boolean empty) {
                  // first of all, check if there is actually a terminal event
                  if (term != null) {
                      // is it a completion event (impl. note, this is much cheaper than checking for isError)
                      if (NotificationLite.isCompleted(term)) {
      Severity: Minor
      Found in src/main/java/rx/internal/operators/OperatorPublish.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 create has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          public static <T> ConnectableObservable<T> create(Observable<? extends T> source) {
              // the current connection to source needs to be shared between the operator and its onSubscribe call
              final AtomicReference<PublishSubscriber<T>> curr = new AtomicReference<PublishSubscriber<T>>();
              OnSubscribe<T> onSubscribe = new OnSubscribe<T>() {
                  @Override
      Severity: Minor
      Found in src/main/java/rx/internal/operators/OperatorPublish.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 create has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static <T, R> Observable<R> create(final Observable<? extends T> source,
                  final Func1<? super Observable<T>, ? extends Observable<R>> selector, final boolean delayError) {
              return unsafeCreate(new OnSubscribe<R>() {
                  @Override
                  public void call(final Subscriber<? super R> child) {
      Severity: Minor
      Found in src/main/java/rx/internal/operators/OperatorPublish.java - About 1 hr to fix

        Method remove has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                void remove(InnerProducer<T> producer) {
                    // the state can change so we do a CAS loop to achieve atomicity
                    for (;;) {
                        // let's read the current producers array
                        InnerProducer[] c = producers.get();
        Severity: Minor
        Found in src/main/java/rx/internal/operators/OperatorPublish.java - About 1 hr to fix

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

                  public long produced(long n) {
                      // we don't allow producing zero or less: it would be a bug in the operator
                      if (n <= 0) {
                          throw new IllegalArgumentException("Cant produce zero or less");
                      }
          Severity: Minor
          Found in src/main/java/rx/internal/operators/OperatorPublish.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 checkTerminated has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  boolean checkTerminated(Object term, boolean empty) {
                      // first of all, check if there is actually a terminal event
                      if (term != null) {
                          // is it a completion event (impl. note, this is much cheaper than checking for isError)
                          if (NotificationLite.isCompleted(term)) {
          Severity: Minor
          Found in src/main/java/rx/internal/operators/OperatorPublish.java - About 1 hr to fix

            Method connect has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                @Override
                public void connect(Action1<? super Subscription> connection) {
                    boolean doConnect;
                    PublishSubscriber<T> ps;
                    // we loop because concurrent connect/disconnect and termination may change the state
            Severity: Minor
            Found in src/main/java/rx/internal/operators/OperatorPublish.java - About 55 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 call has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                        @Override
                        public void call(Subscriber<? super T> child) {
                            // concurrent connection/disconnection may change the state,
                            // we loop to be atomic while the child subscribes
                            for (;;) {
            Severity: Minor
            Found in src/main/java/rx/internal/operators/OperatorPublish.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

                                            if (ip.get() > 0L) {
                                                try {
                                                    ip.child.onNext(value);
                                                } catch (Throwable t) {
                                                    // we bounce back exceptions and kick out the child subscriber
            Severity: Major
            Found in src/main/java/rx/internal/operators/OperatorPublish.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/OperatorPublish.java - About 30 mins to fix

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

                        boolean add(InnerProducer<T> producer) {
                            if (producer == null) {
                                throw new NullPointerException();
                            }
                            // the state can change so we do a CAS loop to achieve atomicity
                Severity: Minor
                Found in src/main/java/rx/internal/operators/OperatorPublish.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

                            if (ps == null || ps.isUnsubscribed()) {
                                // create a new subscriber-to-source
                                PublishSubscriber<T> u = new PublishSubscriber<T>(current);
                                // initialize out the constructor to avoid 'this' to escape
                                u.init();
                Severity: Minor
                Found in src/main/java/rx/internal/operators/OperatorPublish.java and 1 other location - About 45 mins to fix
                src/main/java/rx/internal/operators/OperatorPublish.java on lines 59..72

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

                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 == null || r.isUnsubscribed()) {
                                        // create a new subscriber to source
                                        PublishSubscriber<T> u = new PublishSubscriber<T>(curr);
                                        // perform extra initialization to avoid 'this' to escape during construction
                                        u.init();
                Severity: Minor
                Found in src/main/java/rx/internal/operators/OperatorPublish.java and 1 other location - About 45 mins to fix
                src/main/java/rx/internal/operators/OperatorPublish.java on lines 181..193

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

                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 == NOT_REQUESTED) {
                                    // let the new request value this (no overflow check needed)
                                    u = n;
                                } else {
                                    // otherwise, increase the request count
                Severity: Minor
                Found in src/main/java/rx/internal/operators/OperatorPublish.java and 1 other location - About 40 mins to fix
                src/main/java/rx/internal/operators/OperatorOnBackpressureLatest.java on lines 87..94

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

                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 < len; i++) {
                                    if (c[i].equals(producer)) {
                                        j = i;
                                        break;
                                    }
                Severity: Minor
                Found in src/main/java/rx/internal/operators/OperatorPublish.java and 1 other location - About 35 mins to fix
                src/main/java/rx/internal/operators/CachedObservable.java on lines 144..149

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

                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) {
                                        // since missed is changed atomically, if we see it as true
                                        // it means some state has changed and we need to loop again
                                        // and handle that case
                                        if (!missed) {
                Severity: Minor
                Found in src/main/java/rx/internal/operators/OperatorPublish.java and 1 other location - About 30 mins to fix
                src/main/java/rx/internal/operators/CachedObservable.java on lines 436..443

                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