jdantonio/concurrent-ruby

View on GitHub

Showing 498 of 498 total issues

Method retryUpdate has 73 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    final void retryUpdate(long x, HashCode hc, boolean wasUncontended) {
        int h = hc.code;
        boolean collide = false;                // True if last slot nonempty
        for (;;) {
            Cell[] as; Cell a; int n; long v;
Severity: Major
Found in ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/Striped64.java - About 2 hrs to fix

    Method retryUpdate has 73 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        final void retryUpdate(long x, HashCode hc, boolean wasUncontended) {
            int h = hc.code;
            boolean collide = false;                // True if last slot nonempty
            for (;;) {
                Cell[] as; Cell a; int n; long v;

      Method tryPresize has a Cognitive Complexity of 21 (exceeds 5 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) {

      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 a Cognitive Complexity of 21 (exceeds 5 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) {

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

          def acquire_write_lock
            if (held = @HeldCount.value) >= WRITE_LOCK_HELD
              # if we already have a write (exclusive) lock, there's no need to wait
              @HeldCount.value = held + WRITE_LOCK_HELD
              return true
      Severity: Minor
      Found in lib/concurrent-ruby/concurrent/atomic/reentrant_read_write_lock.rb - 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 ns_initialize has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

            def ns_initialize(opts)
              min_length       = opts.fetch(:min_threads, DEFAULT_MIN_POOL_SIZE).to_i
              max_length       = opts.fetch(:max_threads, DEFAULT_MAX_POOL_SIZE).to_i
              idletime         = opts.fetch(:idletime, DEFAULT_THREAD_IDLETIMEOUT).to_i
              @max_queue       = opts.fetch(:max_queue, DEFAULT_MAX_QUEUE_SIZE).to_i
      Severity: Minor
      Found in lib/concurrent-ruby/concurrent/executor/java_thread_pool_executor.rb - 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 readObject has 71 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          @SuppressWarnings("unchecked") private void readObject(java.io.ObjectInputStream s)
                  throws java.io.IOException, ClassNotFoundException {
              s.defaultReadObject();
              this.segments = null; // unneeded
              // initialize transient final field

        Method readObject has 71 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            @SuppressWarnings("unchecked") private void readObject(java.io.ObjectInputStream s)
                    throws java.io.IOException, ClassNotFoundException {
                s.defaultReadObject();
                this.segments = null; // unneeded
                // initialize transient final field

          Method acquire_write_lock has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

              def acquire_write_lock
                while true
                  c = @Counter.value
                  raise ResourceLimitError.new('Too many writer threads') if max_writers?(c)
          
          
          Severity: Minor
          Found in lib/concurrent-ruby/concurrent/atomic/read_write_lock.rb - 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 wait_until_resolved has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

                def wait_until_resolved(timeout)
                  return true if resolved?
          
                  touch
          
          
          Severity: Minor
          Found in lib/concurrent-ruby/concurrent/promises.rb - 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

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

                      else if ((f = tabAt(tab, i = (tab.length - 1) & h)) == null) {
                          if (onlyIfPresent)
                              break;
                          Node node = new Node(fh = h | LOCKED, k, null, null);
                          if (casTabAt(tab, i, null, node)) {
          ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/nounsafe/ConcurrentHashMapV8.java on lines 1702..1724

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

          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

                      else if ((f = tabAt(tab, i = (tab.length() - 1) & h)) == null) {
                          if (onlyIfPresent)
                              break;
                          Node node = new Node(fh = h | LOCKED, k, null, null);
                          if (casTabAt(tab, i, null, node)) {
          ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/ConcurrentHashMapV8.java on lines 1710..1732

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

          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

          Method equals has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

              public boolean equals(Object o) {
                  if (o != this) {
                      if (!(o instanceof Map))
                          return false;
                      Map<?,?> m = (Map<?,?>) o;

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

              private final Object internalGet(Object k) {
                  int h = spread(k.hashCode());
                  retry: for (Node[] tab = table; tab != null;) {
                      Node e, p; Object ek, ev; int eh;      // locals to read fields once
                      for (e = tabAt(tab, (tab.length - 1) & h); e != null; e = e.next) {

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

              private final Object internalGet(Object k) {
                  int h = spread(k.hashCode());
                  retry: for (AtomicReferenceArray<Node> tab = table; tab != null;) {
                      Node e, p; Object ek, ev; int eh;      // locals to read fields once
                      for (e = tabAt(tab, (tab.length() - 1) & h); e != null; e = e.next) {

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

              public boolean equals(Object o) {
                  if (o != this) {
                      if (!(o instanceof Map))
                          return false;
                      Map<?,?> m = (Map<?,?>) o;

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

                def canonical_rules(rules, timeout, timeout_value, given_block)
                  block = given_block || -> v { v }
                  case rules.size
                  when 0
                    rules.push(on(ANY, &block))
          Severity: Minor
          Found in lib/concurrent-ruby-edge/concurrent/edge/erlang_actor.rb - 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 internal_receive has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

                def internal_receive
                  raise if @behaviour.empty?
                  rules_matcher  = Or[*@behaviour.map(&:first)]
                  matcher        = -> m { m.is_a?(Ask) ? rules_matcher === m.message : rules_matcher === m }
                  start          = nil
          Severity: Minor
          Found in lib/concurrent-ruby-edge/concurrent/edge/erlang_actor.rb - 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

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

                      else if ((fh = f.hash) == MOVED) {
                          if ((fk = f.key) instanceof TreeBin) {
                              TreeBin t = (TreeBin)fk;
                              Object oldVal = null;
                              t.acquire(0);
          ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/ConcurrentHashMapV8.java on lines 1396..1421

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

          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

                      else if ((fh = f.hash) == MOVED) {
                          if ((fk = f.key) instanceof TreeBin) {
                              TreeBin t = (TreeBin)fk;
                              Object oldVal = null;
                              t.acquire(0);
          ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/nounsafe/ConcurrentHashMapV8.java on lines 1388..1413

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

          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

          Severity
          Category
          Status
          Source
          Language