ruby-concurrency/thread_safe

View on GitHub

Showing 181 of 329 total issues

Avoid deeply nested control flow statements.
Open

                        if (busy == 0 && casBusy()) {
                            boolean created = false;
                            try {               // Recheck under lock
                                Cell[] rs; int m, j;
                                if ((rs = cells) != null &&
Severity: Major
Found in ext/org/jruby/ext/thread_safe/jsr166e/nounsafe/Striped64.java - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                                        if ((e.val = v) == null) {
                                            deleted = true;
                                            Node en = e.next;
                                            if (pred != null)
                                                pred.next = en;
    Severity: Major
    Found in ext/org/jruby/ext/thread_safe/jsr166e/nounsafe/ConcurrentHashMapV8.java - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                                          if (count >= TREE_THRESHOLD)
                                              replaceWithTreeBin(tab, i, k);
      Severity: Major
      Found in ext/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.java - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                for (Node e = tabAt(tab, i); e != null; e = e.next) {
                                    if (++c > TREE_THRESHOLD &&
                                            (e.key instanceof Comparable)) {
                                        replaceWithTreeBin(tab, i, e.key);
                                        break;
        Severity: Major
        Found in ext/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.java - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                                  if (count >= TREE_THRESHOLD)
                                                      replaceWithTreeBin(tab, i, k);
          Severity: Major
          Found in ext/org/jruby/ext/thread_safe/jsr166e/nounsafe/ConcurrentHashMapV8.java - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                        if ((pr = p.right) != null && h >= pr.hash && (r = getTreeNode(h, k, pr)) != null)
                                            return r;
                                        // try to continue iterating on the left side
                                        else if ((pl = p.left) != null && h <= pl.hash)
                                            dir = -1;
            Severity: Major
            Found in ext/org/jruby/ext/thread_safe/jsr166e/nounsafe/ConcurrentHashMapV8.java - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      for (Node e = tabAt(tab, i); e != null; e = e.next) {
                                          if (++c > TREE_THRESHOLD &&
                                                  (e.key instanceof Comparable)) {
                                              replaceWithTreeBin(tab, i, e.key);
                                              break;
              Severity: Major
              Found in ext/org/jruby/ext/thread_safe/jsr166e/nounsafe/ConcurrentHashMapV8.java - About 45 mins to fix

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

                    @SuppressWarnings("unchecked") private void writeObject(java.io.ObjectOutputStream s)
                            throws java.io.IOException {
                        if (segments == null) { // for serialization compatibility
                            segments = (Segment<K,V>[])
                                    new Segment<?,?>[DEFAULT_CONCURRENCY_LEVEL];
                Severity: Minor
                Found in ext/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.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 ((pr = p.right) != null && h >= pr.hash && (r = getTreeNode(h, k, pr)) != null)
                                                return r;
                                            else // continue descending down the left subtree
                                                dir = -1;
                Severity: Major
                Found in ext/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.java - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                              if (!collide && q != null && q.hash == p.hash)
                                                  collide = true;
                  Severity: Major
                  Found in ext/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.java - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if (busy == 0 && casBusy()) {
                                                boolean created = false;
                                                try {               // Recheck under lock
                                                    Cell[] rs; int m, j;
                                                    if ((rs = cells) != null &&
                    Severity: Major
                    Found in ext/org/jruby/ext/thread_safe/jsr166e/Striped64.java - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                                  if ((pr = p.right) != null && h >= pr.hash && (r = getTreeNode(h, k, pr)) != null)
                                                      return r;
                                                  else // continue descending down the left subtree
                                                      dir = -1;
                      Severity: Major
                      Found in ext/org/jruby/ext/thread_safe/jsr166e/nounsafe/ConcurrentHashMapV8.java - About 45 mins to fix

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

                                    def compare_and_set(old_value, new_value)
                                      return false unless @___mutex.try_lock
                                      begin
                                        return false unless @___value.equal? old_value
                                        @___value = new_value
                        Severity: Minor
                        Found in lib/thread_safe/util/atomic_reference.rb - 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 ((p.val = v) == null) {
                                                                deleted = true;
                                                                t.deleteTreeNode(p);
                                                            }
                        Severity: Major
                        Found in ext/org/jruby/ext/thread_safe/jsr166e/nounsafe/ConcurrentHashMapV8.java - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                      if (!collide && q != null && q.hash == p.hash)
                                                          collide = true;
                          Severity: Major
                          Found in ext/org/jruby/ext/thread_safe/jsr166e/nounsafe/ConcurrentHashMapV8.java - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                                if ((e.val = v) == null) {
                                                                    deleted = true;
                                                                    Node en = e.next;
                                                                    if (pred != null)
                                                                        pred.next = en;
                            Severity: Major
                            Found in ext/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.java - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                          if ((pr = p.right) != null && h >= pr.hash && (r = getTreeNode(h, k, pr)) != null)
                                                              return r;
                                                          // try to continue iterating on the left side
                                                          else if ((pl = p.left) != null && h <= pl.hash)
                                                              dir = -1;
                              Severity: Major
                              Found in ext/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.java - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                if (spins -= 1) == 0
                                                  Thread.pass # yield before blocking
                                                else
                                                  randomizer = base_randomizer = Util::XorShiftRandom.xorshift(base_randomizer) if randomizer.zero?
                                                end
                                Severity: Major
                                Found in lib/thread_safe/atomic_reference_cache_backend.rb - About 45 mins to fix

                                  Method split_old_bin has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                      def split_old_bin(table, new_table, i, node, node_hash, forwarder)
                                  Severity: Minor
                                  Found in lib/thread_safe/atomic_reference_cache_backend.rb - About 45 mins to fix

                                    Method attempt_internal_compute_if_absent has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                    Open

                                        def attempt_internal_compute_if_absent(key, hash, current_table, i, node, node_hash)
                                    Severity: Minor
                                    Found in lib/thread_safe/atomic_reference_cache_backend.rb - About 45 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language