ruby-concurrency/thread_safe

View on GitHub

Showing 329 of 329 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/org/jruby/ext/thread_safe/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

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/org/jruby/ext/thread_safe/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

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/
 */
Severity: Major
Found in ext/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.java - About 6 days to fix

    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;
      Severity: Minor
      Found in ext/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.java - About 3 days 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 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;
      Severity: Minor
      Found in ext/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.java - About 2 days 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 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;
      Severity: Minor
      Found in ext/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.java - About 2 days 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 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 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;
      Severity: Minor
      Found in ext/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.java - About 2 days 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 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;
      Severity: Minor
      Found in ext/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.java - About 2 days 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 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;
      Severity: Minor
      Found in ext/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.java - About 1 day 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 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;
      Severity: Minor
      Found in ext/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.java - About 1 day 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 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

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

          static abstract class CHMView<K, V> {
              final ConcurrentHashMapV8<K, V> map;
              CHMView(ConcurrentHashMapV8<K, V> map)  { this.map = map; }
      
              /**
      ext/org/jruby/ext/thread_safe/jsr166e/nounsafe/ConcurrentHashMapV8.java on lines 3489..3620

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

      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 abstract class CHMView<K, V> {
              final ConcurrentHashMapV8<K, V> map;
              CHMView(ConcurrentHashMapV8<K, V> map)  { this.map = map; }
      
              /**
      ext/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.java on lines 3497..3628

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

      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