ruby-concurrency/thread_safe

View on GitHub

Showing 181 of 329 total issues

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

        @SuppressWarnings("unchecked") public final <T> T[] toArray(T[] a) {
            long sz = map.mappingCount();
            if (sz > (long)(MAX_ARRAY_SIZE))
                throw new OutOfMemoryError(oomeMsg);
            int m = (int)sz;

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

        @SuppressWarnings("unchecked") public final <T> T[] toArray(T[] a) {
            long sz = map.mappingCount();
            if (sz > (long)(MAX_ARRAY_SIZE))
                throw new OutOfMemoryError(oomeMsg);
            int m = (int)sz;
Severity: Minor
Found in ext/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.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 compute_if_absent has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def compute_if_absent(key)
      hash          = key_hash(key)
      current_table = table || initialize_table
      while true
        if !(node = current_table.volatile_get(i = current_table.hash_to_index(hash)))
Severity: Minor
Found in lib/thread_safe/atomic_reference_cache_backend.rb - 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 rebuild has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def rebuild(table)
      old_table_size = table.size
      new_table      = table.next_in_size_table
      # puts "#{old_table_size} -> #{new_table.size}"
      forwarder      = Node.new(MOVED, new_table, NULL)
Severity: Minor
Found in lib/thread_safe/atomic_reference_cache_backend.rb - About 1 hr to fix

    Method internal_replace has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def internal_replace(key, expected_old_value = NULL, &block)
          hash          = key_hash(key)
          current_table = table
          while current_table
            if !(node = current_table.volatile_get(i = current_table.hash_to_index(hash)))
    Severity: Minor
    Found in lib/thread_safe/atomic_reference_cache_backend.rb - 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 clear has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def clear
          return self unless current_table = table
          current_table_size = current_table.size
          deleted_count = i = 0
          while i < current_table_size
    Severity: Minor
    Found in lib/thread_safe/atomic_reference_cache_backend.rb - 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 attempt_internal_replace has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def attempt_internal_replace(key, expected_old_value, hash, current_table, i, node, node_hash)
          current_table.try_lock_via_hash(i, node, node_hash) do
            predecessor_node = nil
            old_value        = NULL
            begin
    Severity: Minor
    Found in lib/thread_safe/atomic_reference_cache_backend.rb - 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 splitTreeBin has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private static void splitTreeBin(Node[] nextTab, int i, TreeBin t) {
            int bit = nextTab.length >>> 1;
            TreeBin lt = new TreeBin();
            TreeBin ht = new TreeBin();
            int lc = 0, hc = 0;
    Severity: Minor
    Found in ext/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.java - About 1 hr to fix

      Method splitTreeBin has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private static void splitTreeBin(AtomicReferenceArray<Node> nextTab, int i, TreeBin t) {
              int bit = nextTab.length() >>> 1;
              TreeBin lt = new TreeBin();
              TreeBin ht = new TreeBin();
              int lc = 0, hc = 0;

        Method retry_update has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def retry_update(x, hash_code, was_uncontended) # :yields: current_value
                hash     = hash_code
                collided = false # True if last slot nonempty
                while true
                  if current_cells = cells
        Severity: Minor
        Found in lib/thread_safe/util/striped64.rb - About 1 hr to fix

          Method initTable has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              private final AtomicReferenceArray<Node> initTable() {
                  AtomicReferenceArray<Node> tab; int sc;
                  while ((tab = table) == null) {
                      if ((sc = sizeCtl) < 0)
                          Thread.yield(); // lost initialization race; just spin

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

              private final Node[] initTable() {
                  Node[] tab; int sc;
                  while ((tab = table) == null) {
                      if ((sc = sizeCtl) < 0)
                          Thread.yield(); // lost initialization race; just spin
          Severity: Minor
          Found in ext/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.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 toArray has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

                  public final Object[] toArray() {
                      long sz = map.mappingCount();
                      if (sz > (long)(MAX_ARRAY_SIZE))
                          throw new OutOfMemoryError(oomeMsg);
                      int n = (int)sz;
          Severity: Minor
          Found in ext/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.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 toArray has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

                  public final Object[] toArray() {
                      long sz = map.mappingCount();
                      if (sz > (long)(MAX_ARRAY_SIZE))
                          throw new OutOfMemoryError(oomeMsg);
                      int n = (int)sz;

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

              def attempt_internal_compute_if_absent(key, hash, current_table, i, node, node_hash)
                added = false
                current_table.try_lock_via_hash(i, node, node_hash) do
                  while true
                    if node.matches?(key, hash) && NULL != (value = node.value)
          Severity: Minor
          Found in lib/thread_safe/atomic_reference_cache_backend.rb - 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 tryPresize has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private final void tryPresize(int size) {
                  int c = (size >= (MAXIMUM_CAPACITY >>> 1)) ? MAXIMUM_CAPACITY :
                          tableSizeFor(size + (size >>> 1) + 1);
                  int sc;
                  while ((sc = sizeCtl) >= 0) {
          Severity: Minor
          Found in ext/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.java - About 1 hr to fix

            Method tryPresize has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private final void tryPresize(int size) {
                    int c = (size >= (MAXIMUM_CAPACITY >>> 1)) ? MAXIMUM_CAPACITY :
                            tableSizeFor(size + (size >>> 1) + 1);
                    int sc;
                    while ((sc = sizeCtl) >= 0) {

              Method advance has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      final V advance() {
                          Node e = next;
                          V ev = null;
                          outer: do {
                              if (e != null)                  // advance past used/skipped node

                Method advance has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        final V advance() {
                            Node e = next;
                            V ev = null;
                            outer: do {
                                if (e != null)                  // advance past used/skipped node
                Severity: Minor
                Found in ext/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.java - About 1 hr to fix

                  Method attr_volatile has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                        def attr_volatile(*attr_names)
                          return if attr_names.empty?
                          include(Module.new do
                            atomic_ref_setup = attr_names.map {|attr_name| "@__#{attr_name} = ThreadSafe::Util::AtomicReference.new"}
                            initialize_copy_setup = attr_names.zip(atomic_ref_setup).map do |attr_name, ref_setup|
                  Severity: Minor
                  Found in lib/thread_safe/util/volatile.rb - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language