jdantonio/concurrent-ruby

View on GitHub

Showing 498 of 498 total issues

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

    static final class TreeBin extends AbstractQueuedSynchronizer {
        private static final long serialVersionUID = 2249069246763182397L;
        transient TreeNode root;  // root of tree
        transient TreeNode first; // head of next-pointer list

ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/ConcurrentHashMapV8.java on lines 769..1197

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

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

    static final class TreeBin extends AbstractQueuedSynchronizer {
        private static final long serialVersionUID = 2249069246763182397L;
        transient TreeNode root;  // root of tree
        transient TreeNode first; // head of next-pointer list

ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/nounsafe/ConcurrentHashMapV8.java on lines 761..1189

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

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

File ConcurrentHashMapV8.java has 2355 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 * Written by Doug Lea with assistance from members of JCP JSR-166
 * Expert Group and released to the public domain, as explained at
 * http://creativecommons.org/publicdomain/zero/1.0/
 */

    File ConcurrentHashMapV8.java has 2304 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /*
     * Written by Doug Lea with assistance from members of JCP JSR-166
     * Expert Group and released to the public domain, as explained at
     * http://creativecommons.org/publicdomain/zero/1.0/
     */

      Method deleteTreeNode has a Cognitive Complexity of 193 (exceeds 5 allowed). Consider refactoring.
      Open

              final void deleteTreeNode(TreeNode p) {
                  TreeNode next = (TreeNode)p.next; // unlink traversal pointers
                  TreeNode pred = p.prev;
                  if (pred == null)
                      first = 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 deleteTreeNode has a Cognitive Complexity of 193 (exceeds 5 allowed). Consider refactoring.
      Open

              final void deleteTreeNode(TreeNode p) {
                  TreeNode next = (TreeNode)p.next; // unlink traversal pointers
                  TreeNode pred = p.prev;
                  if (pred == null)
                      first = 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

      File promises.rb has 1196 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require 'concurrent/synchronization/object'
      require 'concurrent/atomic/atomic_boolean'
      require 'concurrent/atomic/atomic_fixnum'
      require 'concurrent/collection/lock_free_stack'
      require 'concurrent/configuration'
      Severity: Major
      Found in lib/concurrent-ruby/concurrent/promises.rb - About 3 days to fix

        Method internalComputeIfAbsent has a Cognitive Complexity of 132 (exceeds 5 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;

        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 internalComputeIfAbsent has a Cognitive Complexity of 132 (exceeds 5 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;

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

            @SuppressWarnings("unchecked") private final Object internalCompute
            (K k, boolean onlyIfPresent, BiFun<? super K, ? super V, ? extends V> mf) {
                int h = spread(k.hashCode());
                Object val = null;
                int delta = 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 internalCompute has a Cognitive Complexity of 123 (exceeds 5 allowed). Consider refactoring.
        Open

            @SuppressWarnings("unchecked") private final Object internalCompute
            (K k, boolean onlyIfPresent, BiFun<? super K, ? super V, ? extends V> mf) {
                int h = spread(k.hashCode());
                Object val = null;
                int delta = 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

        File erlang_actor.rb has 899 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require 'set'
        require 'concurrent/atomic/count_down_latch'
        require 'concurrent/concern/logging'
        require 'concurrent/edge/channel'
        require 'concurrent/errors'
        Severity: Major
        Found in lib/concurrent-ruby-edge/concurrent/edge/erlang_actor.rb - About 2 days to fix

          Method internalPutIfAbsent has a Cognitive Complexity of 106 (exceeds 5 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;

          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 a Cognitive Complexity of 106 (exceeds 5 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;

          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 a Cognitive Complexity of 102 (exceeds 5 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;

          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 a Cognitive Complexity of 102 (exceeds 5 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;

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

              private final Object internalReplace(Object k, Object v, Object cv) {
                  int h = spread(k.hashCode());
                  Object oldVal = null;
                  for (AtomicReferenceArray<Node> tab = table;;) {
                      Node f; int i, fh; Object fk;

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

              private final Object internalReplace(Object k, Object v, Object cv) {
                  int h = spread(k.hashCode());
                  Object oldVal = null;
                  for (Node[] tab = table;;) {
                      Node f; int i, fh; Object fk;

          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 internalMerge has a Cognitive Complexity of 91 (exceeds 5 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;

          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 internalMerge has a Cognitive Complexity of 91 (exceeds 5 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;

          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