ruby-concurrency/thread_safe

View on GitHub

Showing 181 of 329 total issues

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

    def attempt_compute(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

    Method lock_and_clean_up_reverse_forwarders has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def lock_and_clean_up_reverse_forwarders(old_table, old_table_size, new_table, i, forwarder)
    Severity: Minor
    Found in lib/thread_safe/atomic_reference_cache_backend.rb - About 35 mins to fix

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

              public final boolean remove(Object o) {
                  if (o != null) {
                      Iterator<V> it = new ValueIterator<K,V>(map);
                      while (it.hasNext()) {
                          if (o.equals(it.next())) {
      Severity: Minor
      Found in ext/org/jruby/ext/thread_safe/jsr166e/nounsafe/ConcurrentHashMapV8.java - About 35 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 splitBin has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          private static void splitBin(AtomicReferenceArray<Node> nextTab, int i, Node e) {
              int bit = nextTab.length() >>> 1; // bit to split on
              int runBit = e.hash & bit;
              Node lastRun = e, lo = null, hi = null;
              for (Node p = e.next; p != null; p = p.next) {
      Severity: Minor
      Found in ext/org/jruby/ext/thread_safe/jsr166e/nounsafe/ConcurrentHashMapV8.java - About 35 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 toString has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public String toString() {
              Traverser<K,V,Object> it = new Traverser<K,V,Object>(this);
              StringBuilder sb = new StringBuilder();
              sb.append('{');
              Object v;
      Severity: Minor
      Found in ext/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.java - About 35 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 containsAll has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              public final boolean containsAll(Collection<?> c) {
                  if (c != this) {
                      for (Iterator<?> it = c.iterator(); it.hasNext();) {
                          Object e = it.next();
                          if (e == null || !contains(e))
      Severity: Minor
      Found in ext/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.java - About 35 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 fetch_or_store has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def fetch_or_store(key, default_value = NULL)
            fetch(key) do
              put(key, block_given? ? yield(key) : (NULL == default_value ? raise_fetch_no_key : default_value))
            end
          end
      Severity: Minor
      Found in lib/thread_safe/cache.rb - About 35 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 getValue has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              final Object getValue(int h, Object k) {
                  Node r = null;
                  int c = getState(); // Must read lock state first
                  for (Node e = first; e != null; e = e.next) {
                      if (c <= 0 && compareAndSetState(c, c - 1)) {
      Severity: Minor
      Found in ext/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.java - About 35 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 containsAll has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              public final boolean containsAll(Collection<?> c) {
                  if (c != this) {
                      for (Iterator<?> it = c.iterator(); it.hasNext();) {
                          Object e = it.next();
                          if (e == null || !contains(e))
      Severity: Minor
      Found in ext/org/jruby/ext/thread_safe/jsr166e/nounsafe/ConcurrentHashMapV8.java - About 35 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 splitBin has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          private static void splitBin(Node[] nextTab, int i, Node e) {
              int bit = nextTab.length >>> 1; // bit to split on
              int runBit = e.hash & bit;
              Node lastRun = e, lo = null, hi = null;
              for (Node p = e.next; p != null; p = p.next) {
      Severity: Minor
      Found in ext/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.java - About 35 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 toString has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              public final String toString() {
                  StringBuilder sb = new StringBuilder();
                  sb.append('[');
                  Iterator<?> it = iterator();
                  if (it.hasNext()) {
      Severity: Minor
      Found in ext/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.java - About 35 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 getValue has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              final Object getValue(int h, Object k) {
                  Node r = null;
                  int c = getState(); // Must read lock state first
                  for (Node e = first; e != null; e = e.next) {
                      if (c <= 0 && compareAndSetState(c, c - 1)) {
      Severity: Minor
      Found in ext/org/jruby/ext/thread_safe/jsr166e/nounsafe/ConcurrentHashMapV8.java - About 35 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 toString has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              public final String toString() {
                  StringBuilder sb = new StringBuilder();
                  sb.append('[');
                  Iterator<?> it = iterator();
                  if (it.hasNext()) {
      Severity: Minor
      Found in ext/org/jruby/ext/thread_safe/jsr166e/nounsafe/ConcurrentHashMapV8.java - About 35 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 remove has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              public final boolean remove(Object o) {
                  if (o != null) {
                      Iterator<V> it = new ValueIterator<K,V>(map);
                      while (it.hasNext()) {
                          if (o.equals(it.next())) {
      Severity: Minor
      Found in ext/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.java - About 35 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 toCHM has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              private ConcurrentHashMap<IRubyObject, IRubyObject> toCHM(ThreadContext context, IRubyObject options) {
                  Ruby runtime = context.getRuntime();
                  if (!options.isNil() && options.respondsTo("[]")) {
                      IRubyObject rInitialCapacity = options.callMethod(context, "[]", runtime.newSymbol("initial_capacity"));
                      IRubyObject rLoadFactor      = options.callMethod(context, "[]", runtime.newSymbol("load_factor"));
      Severity: Minor
      Found in ext/org/jruby/ext/thread_safe/JRubyCacheBackendLibrary.java - About 35 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 toString has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public String toString() {
              Traverser<K,V,Object> it = new Traverser<K,V,Object>(this);
              StringBuilder sb = new StringBuilder();
              sb.append('{');
              Object v;
      Severity: Minor
      Found in ext/org/jruby/ext/thread_safe/jsr166e/nounsafe/ConcurrentHashMapV8.java - About 35 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 find_value_in_node_list has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def find_value_in_node_list(node, key, hash, pure_hash)
            do_check_for_resize = false
            while true
              if pure_hash == hash && node.key?(key) && NULL != (value = node.value)
                return value
      Severity: Minor
      Found in lib/thread_safe/atomic_reference_cache_backend.rb - About 35 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 compute_if_present has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def compute_if_present(key)
            new_value = nil
            internal_replace(key) do |old_value|
              if (new_value = yield(NULL == old_value ? nil : old_value)).nil?
                NULL
      Severity: Minor
      Found in lib/thread_safe/atomic_reference_cache_backend.rb - About 35 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 compute has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def compute(key)
            internal_compute(key) do |old_value|
              if (new_value = yield(NULL == old_value ? nil : old_value)).nil?
                NULL
              else
      Severity: Minor
      Found in lib/thread_safe/atomic_reference_cache_backend.rb - About 35 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 try_to_cas_in_computed has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def try_to_cas_in_computed(i, hash, key)
              succeeded = false
              new_value = nil
              new_node  = Node.new(locked_hash = hash | LOCKED, key, NULL)
              if cas(i, nil, new_node)
      Severity: Minor
      Found in lib/thread_safe/atomic_reference_cache_backend.rb - About 35 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

      Severity
      Category
      Status
      Source
      Language