jdantonio/concurrent-ruby

View on GitHub

Showing 303 of 498 total issues

Method internalComputeIfAbsent has 123 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private final Object internalComputeIfAbsent(K k,
                                                 Fun<? super K, ?> mf) {
        int h = spread(k.hashCode());
        Object val = null;
        int count = 0;

    Method getTreeNode has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    Open

            @SuppressWarnings("unchecked") final TreeNode getTreeNode
            (int h, RubyObject k, TreeNode p) {
                RubyClass c = k.getMetaClass(); boolean kNotComparable = !k.respondsTo("<=>");
                while (p != null) {
                    int dir, ph;  RubyObject pk; RubyClass pc;

    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 getTreeNode has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    Open

            @SuppressWarnings("unchecked") final TreeNode getTreeNode
            (int h, RubyObject k, TreeNode p) {
                RubyClass c = k.getMetaClass(); boolean kNotComparable = !k.respondsTo("<=>");
                while (p != null) {
                    int dir, ph;  RubyObject pk; RubyClass pc;

    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

    Class Channel has 36 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class Channel < Concurrent::Synchronization::Object
    
          # TODO (pitr-ch 06-Jan-2019): rename to Conduit?, to be able to place it into Concurrent namespace?
          # TODO (pitr-ch 14-Jan-2019): better documentation, do few examples from go
          # TODO (pitr-ch 12-Dec-2018): implement channel closing,
    Severity: Minor
    Found in lib/concurrent-ruby-edge/concurrent/edge/channel.rb - About 4 hrs to fix

      Method ns_pop_op has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
      Open

            def ns_pop_op(matcher, probe, include_channel)
              message = ns_shift_message matcher
      
              # got message from buffer
              if message != NOTHING
      Severity: Minor
      Found in lib/concurrent-ruby-edge/concurrent/edge/channel.rb - About 4 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

      Class Channel has 33 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class Channel
          extend Forwardable
          include Enumerable
      
          # NOTE: Move to global IO pool once stable
      Severity: Minor
      Found in lib/concurrent-ruby-edge/concurrent/channel.rb - About 4 hrs to fix

        Method internalMerge has 103 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            @SuppressWarnings("unchecked") private final Object internalMerge
            (K k, V v, BiFun<? super V, ? super V, ? extends V> mf) {
                int h = spread(k.hashCode());
                Object val = null;
                int delta = 0;

          Method internalMerge has 103 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              @SuppressWarnings("unchecked") private final Object internalMerge
              (K k, V v, BiFun<? super V, ? super V, ? extends V> mf) {
                  int h = spread(k.hashCode());
                  Object val = null;
                  int delta = 0;

            Method single_test has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
            Open

            def single_test(lock, n_readers, n_writers, reader_iterations=50, writer_iterations=50, reader_sleep=0.001, writer_sleep=0.001)
              puts "Testing #{lock.class} with #{n_readers} readers and #{n_writers} writers. Readers iterate #{reader_iterations} times, sleeping #{reader_sleep}s each time, writers iterate #{writer_iterations} times, sleeping #{writer_sleep}s each time"
              mutex = Mutex.new
              bad   = false
              data  = 0
            Severity: Minor
            Found in examples/benchmark_read_write_lock.rb - About 4 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

            Class AbstractEventFuture has 32 methods (exceeds 20 allowed). Consider refactoring.
            Open

                class AbstractEventFuture < Synchronization::Object
                  safe_initialization!
                  attr_atomic(:internal_state)
                  private :internal_state=, :swap_internal_state, :compare_and_set_internal_state, :update_internal_state
                  # @!method internal_state
            Severity: Minor
            Found in lib/concurrent-ruby/concurrent/promises.rb - About 4 hrs to fix

              Method internalPutAll has 99 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private final void internalPutAll(Map<?, ?> m) {
                      tryPresize(m.size());
                      long delta = 0L;     // number of uncommitted additions
                      boolean npe = false; // to throw exception on exit for nulls
                      try {                // to clean up counts on other exceptions

                Method internalPutAll has 99 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private final void internalPutAll(Map<?, ?> m) {
                        tryPresize(m.size());
                        long delta = 0L;     // number of uncommitted additions
                        boolean npe = false; // to throw exception on exit for nulls
                        try {                // to clean up counts on other exceptions

                  Method acquire_read_lock has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def acquire_read_lock
                        if (held = @HeldCount.value) > 0
                          # If we already have a lock, there's no need to wait
                          if held & READ_LOCK_MASK == 0
                            # But we do need to update the counter, if we were holding a write
                  Severity: Minor
                  Found in lib/concurrent-ruby/concurrent/atomic/reentrant_read_write_lock.rb - About 3 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 internalPutIfAbsent has 97 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private final Object internalPutIfAbsent(Object k, Object v) {
                          int h = spread(k.hashCode());
                          int count = 0;
                          for (Node[] tab = table;;) {
                              int i; Node f; int fh; Object fk, fv;

                    Method internalPutIfAbsent has 97 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private final Object internalPutIfAbsent(Object k, Object v) {
                            int h = spread(k.hashCode());
                            int count = 0;
                            for (AtomicReferenceArray<Node> tab = table;;) {
                                int i; Node f; int fh; Object fk, fv;

                      Method rebuild has 94 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private static final Node[] rebuild(Node[] tab) {
                              int n = tab.length;
                              Node[] nextTab = new Node[n << 1];
                              Node fwd = new Node(MOVED, nextTab, null, null);
                              int[] buffer = null;       // holds bins to revisit; null until needed

                        Method rebuild has 94 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            private static final AtomicReferenceArray<Node> rebuild(AtomicReferenceArray<Node> tab) {
                                int n = tab.length();
                                AtomicReferenceArray<Node> nextTab = new AtomicReferenceArray<Node>(n << 1);
                                Node fwd = new Node(MOVED, nextTab, null, null);
                                int[] buffer = null;       // holds bins to revisit; null until needed

                          Method signature_types has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
                          Open

                                def signature_types(meth, link = true)
                                  meth = convert_method_to_overload(meth)
                                  if meth.respond_to?(:object) && !meth.has_tag?(:return)
                                    meth = meth.object
                                  end
                          Severity: Minor
                          Found in support/yard_full_types.rb - About 3 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 do_exchange has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def do_exchange(value, timeout)
                          
                                # ALGORITHM
                                #
                                # From the original Java version:
                          Severity: Minor
                          Found in lib/concurrent-ruby/concurrent/exchanger.rb - About 3 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 putTreeNode has 93 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                                  @SuppressWarnings("unchecked") final TreeNode putTreeNode
                                  (int h, RubyObject k, Object v) {
                                      RubyClass c = k.getMetaClass();
                                      boolean kNotComparable = !k.respondsTo("<=>");
                                      TreeNode pp = root, p = null;
                            Severity
                            Category
                            Status
                            Source
                            Language